summaryrefslogtreecommitdiffstats
path: root/src/OSSupport/GZipFile.h
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2013-11-27 22:35:13 +0100
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2013-11-27 22:35:13 +0100
commita6630d32394120a78af56bc612fa3c3449283248 (patch)
tree2c791266b0f213cd56961299da8d2258b8f85d8e /src/OSSupport/GZipFile.h
parentFixed spawn point being generally in an ocean (diff)
parentVoronoi-related biomegens use the new cVoronoiMap class. (diff)
downloadcuberite-a6630d32394120a78af56bc612fa3c3449283248.tar
cuberite-a6630d32394120a78af56bc612fa3c3449283248.tar.gz
cuberite-a6630d32394120a78af56bc612fa3c3449283248.tar.bz2
cuberite-a6630d32394120a78af56bc612fa3c3449283248.tar.lz
cuberite-a6630d32394120a78af56bc612fa3c3449283248.tar.xz
cuberite-a6630d32394120a78af56bc612fa3c3449283248.tar.zst
cuberite-a6630d32394120a78af56bc612fa3c3449283248.zip
Diffstat (limited to 'src/OSSupport/GZipFile.h')
-rw-r--r--src/OSSupport/GZipFile.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/OSSupport/GZipFile.h b/src/OSSupport/GZipFile.h
new file mode 100644
index 000000000..dfb4e8c31
--- /dev/null
+++ b/src/OSSupport/GZipFile.h
@@ -0,0 +1,52 @@
+
+// GZipFile.h
+
+// Declares the cGZipFile class representing a RAII wrapper over zlib's GZip file routines
+
+
+
+
+
+#pragma once
+
+#include "zlib/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 true if successful. Multiple writes are supported.
+ bool Write(const AString & a_Contents) { return Write(a_Contents.data(), (int)(a_Contents.size())); }
+
+ bool Write(const char * a_Data, int a_Size);
+
+protected:
+ gzFile m_File;
+ eMode m_Mode;
+} ;
+
+
+
+
+