ScummVM API documentation
resource.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 DGDS_RESOURCE_H
23 #define DGDS_RESOURCE_H
24 
25 #include "common/file.h"
26 #include "common/hashmap.h"
27 #include "common/platform.h"
28 #include "common/stream.h"
29 
30 namespace Dgds {
31 
32 class Decompressor;
33 
34 typedef uint32 DGDS_ID;
35 typedef uint32 DGDS_EX;
36 #define DGDS_TYPENAME_MAX 4
37 
38 struct Resource {
39  byte volume;
40  uint32 pos;
41  uint32 size;
42  uint32 checksum;
43 };
44 
46 
47 #define MAX_VOLUMES 10
48 
50 public:
52  virtual ~ResourceManager();
53 
54  Common::SeekableReadStream *getResource(Common::String name, bool ignorePatches = false);
55  Resource getResourceInfo(Common::String name);
56  bool hasResource(Common::String name) const;
57 
58  const ResourceList &getResources() const { return _resources; }
59 
60 private:
61  Common::File _volumes[MAX_VOLUMES];
62  ResourceList _resources;
63 };
64 
66 public:
68  ~DgdsChunkReader();
69 
70  bool isSection(const Common::String &section) const;
71  bool isSection(DGDS_ID section) const;
72 
73  bool readNextHeader(DGDS_EX ex, const Common::String &filename);
74 
78  bool readContent(Decompressor *decompressor);
79 
82  void skipContent();
83 
86  Common::SeekableReadStream *makeMemoryStream();
87 
88  Common::SeekableReadStream *getContent() { return _contentStream; }
89 
90  bool isContainer() const { return _container; }
91  DGDS_ID getId() const { return _id; }
92  const char *getIdStr() const { return _idStr; }
93  uint32 getSize() const { return _size; }
94 
95  DGDS_EX _ex;
96 
97 private:
98  uint32 _size;
99  uint64 _startPos;
100  char _idStr[DGDS_TYPENAME_MAX + 1];
101  DGDS_ID _id;
102  bool _container;
103  Common::SeekableReadStream *_contentStream;
104  Common::SeekableReadStream *_sourceStream;
105 
106  bool isPacked() const;
107  Common::SeekableReadStream *decodeStream(Decompressor *decompressor);
108  Common::SeekableReadStream *readStream();
109 };
110 
111 } // End of namespace Dgds
112 
113 #endif // DGDS_RESOURCE_H
Definition: str.h:59
Definition: ads.h:28
Definition: stream.h:745
Definition: resource.h:38
Definition: file.h:47
Definition: resource.h:65
Definition: decompress.h:67
Definition: resource.h:49