summaryrefslogtreecommitdiffstats
path: root/source/OSSupport/GZipFile.h
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-02-07 10:15:55 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-02-07 10:15:55 +0100
commite0535ca6dfee3e5680d591e5764529596d4d412d (patch)
tree1cbbc76193f67b9f78c52149afeddaccaf791256 /source/OSSupport/GZipFile.h
parentcBlockArea can now be loaded from a .schematic file. (diff)
downloadcuberite-e0535ca6dfee3e5680d591e5764529596d4d412d.tar
cuberite-e0535ca6dfee3e5680d591e5764529596d4d412d.tar.gz
cuberite-e0535ca6dfee3e5680d591e5764529596d4d412d.tar.bz2
cuberite-e0535ca6dfee3e5680d591e5764529596d4d412d.tar.lz
cuberite-e0535ca6dfee3e5680d591e5764529596d4d412d.tar.xz
cuberite-e0535ca6dfee3e5680d591e5764529596d4d412d.tar.zst
cuberite-e0535ca6dfee3e5680d591e5764529596d4d412d.zip
Diffstat (limited to '')
-rw-r--r--source/OSSupport/GZipFile.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/source/OSSupport/GZipFile.h b/source/OSSupport/GZipFile.h
new file mode 100644
index 000000000..bb8a88ec8
--- /dev/null
+++ b/source/OSSupport/GZipFile.h
@@ -0,0 +1,49 @@
+
+// GZipFile.h
+
+// Declares the cGZipFile class representing a RAII wrapper over zlib's GZip file routines
+
+
+
+
+
+#pragma once
+
+#include "zlib.h"
+
+
+
+
+
+class cGZipFile
+{
+public:
+ enum eMode
+ {
+ fmRead, // Read-only. If the file doesn't exist, object will not be valid
+ fmWrite, // Write-only. If the file already exists, it will be overwritten
+ } ;
+
+ cGZipFile(void);
+ ~cGZipFile();
+
+ /// Opens the file. Returns true if successful. Fails if a file has already been opened through this object.
+ bool Open(const AString & a_FileName, eMode a_Mode);
+
+ /// Closes the file, flushing all buffers. This object may be then reused for a different file and / or mode
+ void Close(void);
+
+ /// Reads the rest of the file and decompresses it into a_Contents. Returns the number of decompressed bytes, <0 for error
+ int ReadRestOfFile(AString & a_Contents);
+
+ /// Writes a_Contents into file, compressing it along the way. Returns the number of decompressed bytes, <0 for error. Multiple writes are supported.
+ int Write(AString & a_Contents);
+
+protected:
+ gzFile m_File;
+} ;
+
+
+
+
+