ICP  1
SplitFile.h
Go to the documentation of this file.
1 #ifndef SPLIT_FILE
2 #define SPLIT_FILE
3 
4 #include "icp_interfaces.h"
5 
6 class SplitFile : public IFile, public ISIS::Base
7 {
8 private:
9  FILE* m_file;
10  size_t m_count;
12  static const size_t m_bytes_per_file;
13  static const size_t m_files_per_sub_dir;
14 
15  int m_shflag;
16  int m_mode;
17  Poco::Path m_top_directory;
19  SplitFile(const SplitFile&) { }
20  void operator=(const SplitFile&) { m_file = NULL; }
21 
22 public:
23  SplitFile();
24  int open(const std::string& path, IFile::Mode mode, int shflag)
25  {
26  return open(path, mode, shflag, false);
27  }
28  int open(const std::string& path, Mode mode, int shflag, bool toggle_readonly);
29  size_t write(const void* data, size_t element_size, size_t nelement);
30  size_t read(void* data, size_t element_size, size_t nelement);
31  int close();
32  int seek(int64_t offset, int whence);
33  int tell(int64_t& offset);
34  int discardContents();
35  bool isOpen() const;
36  int flush();
37  ~SplitFile();
38  static void removeFile(const std::string& path);
39 
40 private:
41  int open();
42  std::string fileNamefromCount(size_t count) const;
43  std::string getFileName() const;
44  void nextFile();
45  size_t countFromOffset(int64_t offset) const;
46  void findFiles(std::set<std::string>& files) const;
47  static void findFiles(const Poco::Path& path, std::set<std::string>& files);
48  std::string openMode(const std::string& path) const;
49 };
50 
51 #endif /* SPLIT_FILE */
int tell(int64_t &offset)
Definition: SplitFile.cpp:178
int seek(int64_t offset, int whence)
Definition: SplitFile.cpp:154
size_t write(const void *data, size_t element_size, size_t nelement)
Definition: SplitFile.cpp:56
size_t countFromOffset(int64_t offset) const
Definition: SplitFile.cpp:250
FILE * m_file
Definition: SplitFile.h:9
Poco::Path m_top_directory
Definition: SplitFile.h:17
size_t m_count
Definition: SplitFile.h:10
int flush()
Definition: SplitFile.cpp:238
int close()
Definition: SplitFile.cpp:135
std::string fileNamefromCount(size_t count) const
Definition: SplitFile.cpp:260
int m_shflag
Definition: SplitFile.h:15
void operator=(const SplitFile &)
Definition: SplitFile.h:20
int m_mode
Definition: SplitFile.h:16
static const size_t m_files_per_sub_dir
Definition: SplitFile.h:13
int open()
Definition: SplitFile.cpp:28
void nextFile()
Definition: SplitFile.cpp:122
size_t read(void *data, size_t element_size, size_t nelement)
Definition: SplitFile.cpp:85
void findFiles(std::set< std::string > &files) const
Definition: SplitFile.cpp:267
size_t m_current_bytes
Definition: SplitFile.h:11
std::string openMode(const std::string &path) const
determine flags to use for fopen/fsopen
Definition: SplitFile.cpp:282
static void removeFile(const std::string &path)
Definition: SplitFile.cpp:212
SplitFile(const SplitFile &)
Definition: SplitFile.h:19
bool m_toggle_readonly
Definition: SplitFile.h:18
int open(const std::string &path, IFile::Mode mode, int shflag)
Definition: SplitFile.h:24
static const size_t m_bytes_per_file
Definition: SplitFile.h:12
int discardContents()
Definition: SplitFile.cpp:188
std::string getFileName() const
Definition: SplitFile.cpp:255
bool isOpen() const
Definition: SplitFile.cpp:233