ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
res_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 GOT_UTILS_RES_ARCHIVE_H
23 #define GOT_UTILS_RES_ARCHIVE_H
24 
25 #include "common/archive.h"
26 #include "common/stream.h"
27 
28 namespace Got {
29 
30 struct ResHeader {
31  Common::String _name;
32  uint32 _offset = 0;
33  uint32 _size = 0;
34  uint32 _originalSize = 0;
35  int _key = 0;
36 
37  void load(Common::SeekableReadStream *src);
38 };
39 
40 #define RES_MAX_ENTRIES 256 // Max # of elements
41 #define RES_HEADER_ENTRY_SIZE 23 // Size of a single header entry
42 class ResArchive : public Common::Archive {
43 private:
44  Common::Array<ResHeader> _headers;
45 
52  void decrypt(byte *buf, size_t len, byte key) const;
53 
57  void lzssDecompress(const byte *src, byte *dest) const;
58 
62  int indexOf(const Common::String &name) const;
63 
64 public:
68  ResArchive();
69 
75  bool hasFile(const Common::Path &path) const override;
76 
83  int listMembers(Common::ArchiveMemberList &list) const override;
84 
88  const Common::ArchiveMemberPtr getMember(const Common::Path &path) const override;
89 
95  Common::SeekableReadStream *createReadStreamForMember(const Common::Path &path) const override;
96 };
97 
98 extern void resInit();
99 
100 } // namespace Got
101 
102 #endif
Definition: str.h:59
Definition: array.h:52
Definition: list.h:44
Definition: path.h:52
Definition: stream.h:745
Definition: archive.h:141
Definition: res_archive.h:30
Definition: res_archive.h:42
Definition: console.h:28