summaryrefslogtreecommitdiffstats
path: root/source/OSSupport/GZipFile.cpp
diff options
context:
space:
mode:
authorAlexander Harkness <bearbin@gmail.com>2013-07-29 13:13:03 +0200
committerAlexander Harkness <bearbin@gmail.com>2013-07-29 13:13:03 +0200
commit53e22b11857fed62e2313d6d84d90f88ed412ffb (patch)
treec61e56725da7dff0154d566722651e2c39c9d6c6 /source/OSSupport/GZipFile.cpp
parentWebAdmin: Removed the duplicate memory usage querying (diff)
downloadcuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.tar
cuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.tar.gz
cuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.tar.bz2
cuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.tar.lz
cuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.tar.xz
cuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.tar.zst
cuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.zip
Diffstat (limited to 'source/OSSupport/GZipFile.cpp')
-rw-r--r--source/OSSupport/GZipFile.cpp214
1 files changed, 107 insertions, 107 deletions
diff --git a/source/OSSupport/GZipFile.cpp b/source/OSSupport/GZipFile.cpp
index c57de5198..cbf6be6c4 100644
--- a/source/OSSupport/GZipFile.cpp
+++ b/source/OSSupport/GZipFile.cpp
@@ -1,107 +1,107 @@
-
-// GZipFile.cpp
-
-// Implements the cGZipFile class representing a RAII wrapper over zlib's GZip file routines
-
-#include "Globals.h"
-#include "GZipFile.h"
-
-
-
-
-
-cGZipFile::cGZipFile(void) :
- m_File(NULL)
-{
-}
-
-
-
-
-
-cGZipFile::~cGZipFile()
-{
- Close();
-}
-
-
-
-
-
-bool cGZipFile::Open(const AString & a_FileName, eMode a_Mode)
-{
- if (m_File != NULL)
- {
- ASSERT(!"A file is already open in this object");
- return false;
- }
- m_File = gzopen(a_FileName.c_str(), (a_Mode == fmRead) ? "r" : "w");
- m_Mode = a_Mode;
- return (m_File != NULL);
-}
-
-
-
-
-
-void cGZipFile::Close(void)
-{
- if (m_File != NULL)
- {
- gzclose(m_File);
- m_File = NULL;
- }
-}
-
-
-
-
-
-int cGZipFile::ReadRestOfFile(AString & a_Contents)
-{
- if (m_File == NULL)
- {
- ASSERT(!"No file has been opened");
- return -1;
- }
-
- if (m_Mode != fmRead)
- {
- ASSERT(!"Bad file mode, cannot read");
- return -1;
- }
-
- // Since the gzip format doesn't really support getting the uncompressed length, we need to read incrementally. Yuck!
- int NumBytesRead = 0;
- char Buffer[64 KiB];
- while ((NumBytesRead = gzread(m_File, Buffer, sizeof(Buffer))) > 0)
- {
- a_Contents.append(Buffer, NumBytesRead);
- }
- return NumBytesRead;
-}
-
-
-
-
-
-bool cGZipFile::Write(const char * a_Contents, int a_Size)
-{
- if (m_File == NULL)
- {
- ASSERT(!"No file has been opened");
- return false;
- }
-
- if (m_Mode != fmWrite)
- {
- ASSERT(!"Bad file mode, cannot write");
- return false;
- }
-
- return (gzwrite(m_File, a_Contents, a_Size) != 0);
-}
-
-
-
-
+
+// GZipFile.cpp
+
+// Implements the cGZipFile class representing a RAII wrapper over zlib's GZip file routines
+
+#include "Globals.h"
+#include "GZipFile.h"
+
+
+
+
+
+cGZipFile::cGZipFile(void) :
+ m_File(NULL)
+{
+}
+
+
+
+
+
+cGZipFile::~cGZipFile()
+{
+ Close();
+}
+
+
+
+
+
+bool cGZipFile::Open(const AString & a_FileName, eMode a_Mode)
+{
+ if (m_File != NULL)
+ {
+ ASSERT(!"A file is already open in this object");
+ return false;
+ }
+ m_File = gzopen(a_FileName.c_str(), (a_Mode == fmRead) ? "r" : "w");
+ m_Mode = a_Mode;
+ return (m_File != NULL);
+}
+
+
+
+
+
+void cGZipFile::Close(void)
+{
+ if (m_File != NULL)
+ {
+ gzclose(m_File);
+ m_File = NULL;
+ }
+}
+
+
+
+
+
+int cGZipFile::ReadRestOfFile(AString & a_Contents)
+{
+ if (m_File == NULL)
+ {
+ ASSERT(!"No file has been opened");
+ return -1;
+ }
+
+ if (m_Mode != fmRead)
+ {
+ ASSERT(!"Bad file mode, cannot read");
+ return -1;
+ }
+
+ // Since the gzip format doesn't really support getting the uncompressed length, we need to read incrementally. Yuck!
+ int NumBytesRead = 0;
+ char Buffer[64 KiB];
+ while ((NumBytesRead = gzread(m_File, Buffer, sizeof(Buffer))) > 0)
+ {
+ a_Contents.append(Buffer, NumBytesRead);
+ }
+ return NumBytesRead;
+}
+
+
+
+
+
+bool cGZipFile::Write(const char * a_Contents, int a_Size)
+{
+ if (m_File == NULL)
+ {
+ ASSERT(!"No file has been opened");
+ return false;
+ }
+
+ if (m_Mode != fmWrite)
+ {
+ ASSERT(!"Bad file mode, cannot write");
+ return false;
+ }
+
+ return (gzwrite(m_File, a_Contents, a_Size) != 0);
+}
+
+
+
+