ScummVM API documentation
zfs_archive.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef ZVISION_ZFS_ARCHIVE_H
23 #define ZVISION_ZFS_ARCHIVE_H
24 
25 #include "common/archive.h"
26 #include "common/hashmap.h"
27 #include "common/hash-str.h"
28 
29 namespace Common {
30 class String;
31 }
32 
33 namespace ZVision {
34 
35 struct ZfsHeader {
36  uint32 magic;
37  uint32 unknown1;
38  uint32 maxNameLength;
39  uint32 filesPerBlock;
40  uint32 fileCount;
41  uint8 xorKey[4];
42  uint32 fileSectionOffset;
43 };
44 
46  Common::String name;
47  uint32 offset;
48  uint32 id;
49  uint32 size;
50  uint32 time;
51  uint32 unknown;
52 };
53 
55 
56 class ZfsArchive : public Common::Archive {
57 public:
58  ZfsArchive(const Common::Path &fileName);
59  ZfsArchive(const Common::Path &fileName, Common::SeekableReadStream *stream);
60  ~ZfsArchive() override;
61 
67  bool hasFile(const Common::Path &path) const override;
68 
75  int listMembers(Common::ArchiveMemberList &list) const override;
76 
80  const Common::ArchiveMemberPtr getMember(const Common::Path &path) const override;
81 
88  Common::SeekableReadStream *createReadStreamForMember(const Common::Path &path) const override;
89 
90 private:
91  const Common::Path _fileName;
92  ZfsHeader _header;
93  ZfsEntryHeaderMap _entryHeaders;
94 
101  void readHeaders(Common::SeekableReadStream *stream);
102 
110  Common::String readEntryName(Common::SeekableReadStream *stream) const;
111 
119  void unXor(byte *buffer, uint32 length, const byte *xorKey) const;
120 };
121 
122 } // End of namespace ZVision
123 
124 #endif
Definition: zfs_archive.h:56
Definition: str.h:59
Definition: list.h:44
Definition: path.h:52
Definition: zfs_archive.h:35
Definition: stream.h:745
Definition: clock.h:29
Definition: archive.h:141
Definition: algorithm.h:29
Definition: zfs_archive.h:45