16 static bool isZLibCompressed(const std::string &filename);
18 File(const std::string &filename = std::string(),
19 File::Mode mode = File::Read);
22 bool isOpened() const;
23 File::Mode mode() const;
24 std::string filename() const;
26 bool open(const std::string &filename, File::Mode mode);
27 bool write(const void *buffer, int length);
28 bool read(void *buffer, int length);
34 virtual bool rawOpen(const std::string &filename, File::Mode mode) = 0;
35 virtual bool rawWrite(const void *buffer, int length) = 0;
36 virtual bool rawRead(void *buffer, int length) = 0;
37 virtual int rawGetc() = 0;
38 virtual void rawClose() = 0;
39 virtual void rawFlush() = 0;
42 std::string m_filename;
47 class ZLibFile : public File {
49 ZLibFile(const std::string &filename = std::string(),
50 File::Mode mode = File::Read);
54 virtual bool rawOpen(const std::string &filename, File::Mode mode);
55 virtual bool rawWrite(const void *buffer, int length);
56 virtual bool rawRead(void *buffer, int length);
57 virtual int rawGetc();
58 virtual void rawClose();
59 virtual void rawFlush();
68 #define SNAPPY_CHUNK_SIZE (1 * 1024 * 1024)
69 class SnappyFile : public File {
71 SnappyFile(const std::string &filename = std::string(),
72 File::Mode mode = File::Read);
73 virtual ~SnappyFile();
76 virtual bool rawOpen(const std::string &filename, File::Mode mode);
77 virtual bool rawWrite(const void *buffer, int length);
78 virtual bool rawRead(void *buffer, int length);
79 virtual int rawGetc();
80 virtual void rawClose();
81 virtual void rawFlush();
84 inline int freeCacheSize() const
87 return m_cacheSize - (m_cachePtr - m_cache);
92 void createCache(size_t size);
94 std::fstream m_stream;
99 char *m_compressedCache;