ScummVM API documentation
cc_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 MM_SHARED_XEEN_CC_ARCHIVE_H
23 #define MM_SHARED_XEEN_CC_ARCHIVE_H
24 
25 #include "common/archive.h"
26 #include "common/stream.h"
27 
28 namespace MM {
29 namespace Shared {
30 namespace Xeen {
31 
35 struct CCEntry {
36  uint16 _id;
37  int _offset;
38  uint16 _size;
39  int _writeOffset;
40 
41  CCEntry() : _id(0), _offset(0), _size(0), _writeOffset(0) {
42  }
43  CCEntry(uint16 id, uint32 offset, uint32 size)
44  : _id(id), _offset(offset), _size(size) {
45  }
46 };
47 
52 protected:
54 
58  void loadIndex(Common::SeekableReadStream &stream);
59 
63  void saveIndex(Common::WriteStream &stream);
64 
69  virtual bool getHeaderEntry(const Common::Path &resourceName, CCEntry &ccEntry) const;
70 
75  virtual bool getHeaderEntry(uint16 id, CCEntry &ccEntry) const;
76 public:
80  static uint16 convertNameToId(const Common::Path &resourceName);
81 public:
82  BaseCCArchive() {
83  }
84 
85  // Archive implementation
86  bool hasFile(const Common::Path &path) const override;
87  int listMembers(Common::ArchiveMemberList &list) const override;
88  const Common::ArchiveMemberPtr getMember(const Common::Path &path) const override;
89 };
90 
94 class CCArchive : public BaseCCArchive {
95 private:
96  Common::Path _filename;
97  Common::String _prefix;
98  bool _encoded;
99 protected:
100  bool getHeaderEntry(const Common::Path &resourceName, CCEntry &ccEntry) const override;
101 public:
102  CCArchive(const Common::Path &filename, bool encoded);
103  CCArchive(const Common::Path &filename, const Common::String &prefix, bool encoded);
104  ~CCArchive() override;
105 
106  // Archive implementation
107  Common::SeekableReadStream *createReadStreamForMember(const Common::Path &path) const override;
108 };
109 
110 } // namespace Xeen
111 } // namespace Shared
112 } // namespace MM
113 
114 #endif
Definition: str.h:59
Definition: stream.h:77
Definition: array.h:52
Definition: list.h:44
Definition: path.h:52
Definition: stream.h:745
Definition: archive.h:141
Definition: cc_archive.h:35
Definition: detection.h:27
Definition: cc_archive.h:51
Definition: cc_archive.h:94