Cuberite
A lightweight, fast and extensible game server for Minecraft
GZipFile.h
Go to the documentation of this file.
1 
2 // GZipFile.h
3 
4 // Declares the cGZipFile class representing a RAII wrapper over zlib's GZip file routines
5 
6 
7 
8 
9 
10 #pragma once
11 
12 #include "zlib/zlib.h"
13 
14 
15 
16 
17 
18 class cGZipFile
19 {
20 public:
21  enum eMode
22  {
23  fmRead, // Read-only. If the file doesn't exist, object will not be valid
24  fmWrite, // Write-only. If the file already exists, it will be overwritten
25  } ;
26 
27  cGZipFile(void);
28  ~cGZipFile();
29 
31  bool Open(const AString & a_FileName, eMode a_Mode);
32 
34  void Close(void);
35 
37  int ReadRestOfFile(AString & a_Contents);
38 
40  bool Write(const AString & a_Contents) { return Write(a_Contents.data(), static_cast<int>(a_Contents.size())); }
41 
42  bool Write(const char * a_Data, int a_Size);
43 
44 protected:
45  gzFile m_File;
47 } ;
48 
49 
50 
51 
52 
eMode m_Mode
Definition: GZipFile.h:46
int ReadRestOfFile(AString &a_Contents)
Reads the rest of the file and decompresses it into a_Contents.
Definition: GZipFile.cpp:60
gzFile m_File
Definition: GZipFile.h:45
cGZipFile(void)
Definition: GZipFile.cpp:13
void Close(void)
Closes the file, flushing all buffers.
Definition: GZipFile.cpp:47
~cGZipFile()
Definition: GZipFile.cpp:22
std::string AString
Definition: StringUtils.h:13
bool Write(const AString &a_Contents)
Writes a_Contents into file, compressing it along the way.
Definition: GZipFile.h:40
bool Open(const AString &a_FileName, eMode a_Mode)
Opens the file.
Definition: GZipFile.cpp:31