diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2021-01-11 17:39:43 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-11 17:39:43 +0100 |
commit | eeb63b8901a9c049f1bb594abb9ce9b4a9c47620 (patch) | |
tree | b07daae788f918b83eeb0bdbd51e49292f1c8d88 /src/OSSupport/GZipFile.h | |
parent | Fixed switch-ups regarding some slab and stair recipes (#5099) (diff) | |
download | cuberite-eeb63b8901a9c049f1bb594abb9ce9b4a9c47620.tar cuberite-eeb63b8901a9c049f1bb594abb9ce9b4a9c47620.tar.gz cuberite-eeb63b8901a9c049f1bb594abb9ce9b4a9c47620.tar.bz2 cuberite-eeb63b8901a9c049f1bb594abb9ce9b4a9c47620.tar.lz cuberite-eeb63b8901a9c049f1bb594abb9ce9b4a9c47620.tar.xz cuberite-eeb63b8901a9c049f1bb594abb9ce9b4a9c47620.tar.zst cuberite-eeb63b8901a9c049f1bb594abb9ce9b4a9c47620.zip |
Diffstat (limited to '')
-rw-r--r-- | src/OSSupport/GZipFile.h | 41 |
1 files changed, 7 insertions, 34 deletions
diff --git a/src/OSSupport/GZipFile.h b/src/OSSupport/GZipFile.h index 00a2fd717..dd4999339 100644 --- a/src/OSSupport/GZipFile.h +++ b/src/OSSupport/GZipFile.h @@ -1,7 +1,7 @@ // GZipFile.h -// Declares the cGZipFile class representing a RAII wrapper over zlib's GZip file routines +// Declares the GZipFile namespace representing a wrapper over a file stream that can read and write to GZip'd files @@ -9,44 +9,17 @@ #pragma once -#include "zlib/zlib.h" +#include "StringCompression.h" -class cGZipFile +namespace GZipFile { -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 - } ; + /** Reads the rest of the file and returns the decompressed contents. */ + Compression::Result ReadRestOfFile(const std::string & a_FileName); - 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(), static_cast<int>(a_Contents.size())); } - - bool Write(const char * a_Data, int a_Size); - -protected: - gzFile m_File; - eMode m_Mode; + /** Writes a_Contents into file, compressing it along the way. */ + void Write(const std::string & a_FileName, ContiguousByteBufferView a_Contents); } ; - - - - - |