Etterna 0.74.4
Loading...
Searching...
No Matches
RageFileDriverZip.h
1#ifndef RAGE_FILE_DRIVER_ZIP_H
2#define RAGE_FILE_DRIVER_ZIP_H
3
4#include "RageFileDriver.h"
5#include "RageUtil/Misc/RageThreads.h"
6
9{
10 public:
12 explicit RageFileDriverZip(const std::string& sPath);
13 bool Load(const std::string& sPath);
14 bool Load(RageFileBasic* pFile);
15
16 ~RageFileDriverZip() override;
17
18 RageFileBasic* Open(const std::string& sPath,
19 int iMode,
20 int& iErr) override;
21 void FlushDirCache(const std::string& sPath) override;
22
23 void DeleteFileWhenFinished() { m_bFileOwned = true; }
24
25 /* Lower-level access: */
26 enum ZipCompressionMethod
27 {
28 STORED = 0,
29 DEFLATED = 8
30 };
31 struct FileInfo
32 {
33 std::string m_sName;
34 int m_iOffset;
35 int m_iDataOffset;
36
37 ZipCompressionMethod m_iCompressionMethod;
38 int m_iCRC32;
39 int m_iCompressedSize, m_iUncompressedSize;
40
41 /* If 0, unknown. */
42 int m_iFilePermissions;
43 };
44 const FileInfo* GetFileInfo(const std::string& sPath) const;
45
46 std::string GetGlobalComment() const { return m_sComment; }
47
48 private:
49 bool m_bFileOwned;
50
51 RageFileBasic* m_pZip;
52 std::vector<FileInfo*> m_pFiles;
53
54 std::string m_sPath;
55 std::string m_sComment;
56
57 /* Open() must be threadsafe. Mutex access to "zip", since we seek
58 * around in it when reading files. */
59 RageMutex m_Mutex;
60
61 bool ParseZipfile();
62 bool ReadEndCentralRecord(int& total_entries_central_dir,
63 int& offset_start_central_directory);
64 int ProcessCdirFileHdr(FileInfo& info);
65 bool SeekToEndCentralRecord();
66 bool ReadLocalFileHeader(FileInfo& info);
67};
68
69#endif
Definition RageFileBasic.h:10
A read-only file driver for ZIPs.
Definition RageFileDriverZip.h:9
Definition RageFileDriver.h:12
Definition RageThreads.h:232
Definition RageFileDriverZip.h:32