ScummVM API documentation
resource_intern.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 KYRA_RESOURCE_INTERN_H
23 #define KYRA_RESOURCE_INTERN_H
24 
25 #include "common/archive.h"
26 #include "common/hash-str.h"
27 #include "common/hashmap.h"
28 #include "common/str.h"
29 #include "common/list.h"
30 #include "common/macresman.h"
31 #include "common/stream.h"
32 
33 namespace Kyra {
34 
35 class Resource;
36 
37 class PlainArchive : public Common::Archive {
38 public:
39  struct Entry {
40  Entry() : offset(0), size(0) {}
41  Entry(uint32 o, uint32 s) : offset(o), size(s) {}
42 
43  uint32 offset;
44  uint32 size;
45  };
46 
48 
49  void addFileEntry(const Common::Path &name, const Entry entry);
50  Entry getFileEntry(const Common::Path &name) const;
51 
52  // Common::Archive API implementation
53  bool hasFile(const Common::Path &path) const override;
54  int listMembers(Common::ArchiveMemberList &list) const override;
55  const Common::ArchiveMemberPtr getMember(const Common::Path &path) const override;
57 private:
59 
61  FileMap _files;
62 };
63 
64 class TlkArchive : public Common::Archive {
65 public:
66  TlkArchive(Common::ArchiveMemberPtr file, uint16 entryCount, const uint32 *fileEntries);
67  ~TlkArchive() override;
68 
69  bool hasFile(const Common::Path &path) const override;
70  int listMembers(Common::ArchiveMemberList &list) const override;
71  const Common::ArchiveMemberPtr getMember(const Common::Path &path) const override;
73 private:
75 
76  const uint32 *findFile(const Common::Path &path) const;
77 
78  const uint16 _entryCount;
79  const uint32 *const _fileEntries;
80 };
81 
83 public:
84  struct InputEntry {
85  Common::Path name;
86 
87  byte *data;
88  uint32 size;
89  };
90 
92 
93  CachedArchive(const FileInputList &files);
94  ~CachedArchive() override;
95 
96  bool hasFile(const Common::Path &path) const override;
97  int listMembers(Common::ArchiveMemberList &list) const override;
98  const Common::ArchiveMemberPtr getMember(const Common::Path &path) const override;
100 private:
101  struct Entry {
102  byte *data;
103  uint32 size;
104  };
105 
107  FileMap _files;
108 };
109 
110 
112 public:
113  virtual ~ResArchiveLoader() {}
114  virtual bool checkFilename(const Common::String &filename) const = 0;
115  virtual bool isLoadable(const Common::String &filename, Common::SeekableReadStream &stream) const = 0;
116  virtual Common::Archive *load(Common::ArchiveMemberPtr file, Common::SeekableReadStream &stream) const = 0;
117 };
118 
120 public:
121  bool checkFilename(const Common::String &filename) const override;
122  bool isLoadable(const Common::String &filename, Common::SeekableReadStream &stream) const override;
123  Common::Archive *load(Common::ArchiveMemberPtr file, Common::SeekableReadStream &stream) const override;
124 };
125 
127 public:
128  bool checkFilename(const Common::String &filename) const override;
129  bool isLoadable(const Common::String &filename, Common::SeekableReadStream &stream) const override;
130  Common::Archive *load(Common::ArchiveMemberPtr file, Common::SeekableReadStream &stream) const override;
131 };
132 
134 public:
135  bool checkFilename(const Common::String &filename) const override;
136  bool isLoadable(const Common::String &filename, Common::SeekableReadStream &stream) const override;
137  Common::Archive *load(Common::ArchiveMemberPtr file, Common::SeekableReadStream &stream) const override;
138 };
139 
141 public:
142  static Common::Archive *load(Resource *owner, const Common::Path &filename, const Common::String &extension, const uint8 offset);
143 };
144 
146 public:
147  static Common::Archive *load(Resource *owner, const Common::Path &filename);
148  static Common::Archive *load(Resource *owner, Common::SeekableReadStream *stream, const Common::String &debugName);
149 };
150 
151 } // End of namespace Kyra
152 
153 #endif
Definition: resource_intern.h:140
Definition: str.h:59
Definition: resource_intern.h:145
Definition: resource_intern.h:39
Definition: resource_intern.h:111
Definition: resource.h:48
Definition: resource_intern.h:37
int listMembers(Common::ArchiveMemberList &list) const override
Definition: list.h:44
Definition: path.h:52
Definition: resource_intern.h:82
bool hasFile(const Common::Path &path) const override
const Common::ArchiveMemberPtr getMember(const Common::Path &path) const override
Definition: stream.h:745
Definition: archive.h:141
Definition: resource_intern.h:64
Definition: resource_intern.h:119
Definition: resource_intern.h:126
Definition: detection.h:27
Definition: resource_intern.h:84
Definition: resource_intern.h:133
Common::SeekableReadStream * createReadStreamForMember(const Common::Path &path) const override