16 File(const std::string &filename = std::string(),
17 File::Mode mode = File::Read);
20 bool isOpened() const;
21 File::Mode mode() const;
22 std::string filename() const;
24 bool open(const std::string &filename, File::Mode mode);
25 bool write(const void *buffer, int length);
26 bool read(void *buffer, int length);
32 virtual bool rawOpen(const std::string &filename, File::Mode mode) = 0;
33 virtual bool rawWrite(const void *buffer, int length) = 0;
34 virtual bool rawRead(void *buffer, int length) = 0;
35 virtual char rawGetc() = 0;
36 virtual void rawClose() = 0;
37 virtual void rawFlush() = 0;
40 std::string m_filename;
45 class ZLibFile : public File {
47 ZLibFile(const std::string &filename = std::string(),
48 File::Mode mode = File::Read);
52 virtual bool rawOpen(const std::string &filename, File::Mode mode);
53 virtual bool rawWrite(const void *buffer, int length);
54 virtual bool rawRead(void *buffer, int length);
55 virtual char rawGetc();
56 virtual void rawClose();
57 virtual void rawFlush();
66 #define SNAPPY_CHUNK_SIZE (1 * 1024 * 1024)
67 class SnappyFile : public File {
69 SnappyFile(const std::string &filename = std::string(),
70 File::Mode mode = File::Read);
71 virtual ~SnappyFile();
74 virtual bool rawOpen(const std::string &filename, File::Mode mode);
75 virtual bool rawWrite(const void *buffer, int length);
76 virtual bool rawRead(void *buffer, int length);
77 virtual char rawGetc();
78 virtual void rawClose();
79 virtual void rawFlush();
82 inline int freeCacheSize() const
85 return m_cacheSize - (m_cachePtr - m_cache);
90 void createCache(size_t size);
92 std::fstream m_stream;
97 char *m_compressedCache;