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