ScummVM API documentation
resources.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 SHERLOCK_RESOURCES_H
23#define SHERLOCK_RESOURCES_H
24
25#include "common/array.h"
26#include "common/file.h"
27#include "common/hashmap.h"
28#include "common/hash-str.h"
29#include "common/rect.h"
30#include "common/str.h"
31#include "common/str-array.h"
32#include "common/stream.h"
33#include "graphics/surface.h"
34
35namespace Sherlock {
36
37typedef Common::Array<byte> CacheEntry;
39
41 uint32 _offset, _size;
42 int _index;
43
44 LibraryEntry() : _index(0), _offset(0), _size(0) {}
45 LibraryEntry(int index, uint32 offset, uint32 size) :
46 _index(index), _offset(offset), _size(size) {}
47};
50
51class SherlockEngine;
52
53class Cache {
54private:
55 SherlockEngine *_vm;
56 CacheHash _resources;
57public:
59
63 bool isCached(const Common::Path &filename) const;
64
70 void load(const Common::Path &name);
71
75 void load(const Common::Path &name, Common::SeekableReadStream &stream);
76
81};
82
83class Resources {
84private:
85 SherlockEngine *_vm;
86 Cache _cache;
87 LibraryIndexes _indexes;
88 int _resourceIndex;
89
93 void loadLibraryIndex(const Common::Path &libFilename, Common::SeekableReadStream *stream, bool isNewStyle);
94public:
96
101 void addToCache(const Common::Path &filename);
102
106 void addToCache(const Common::Path &filename, const Common::Path &libFilename);
107
111 void addToCache(const Common::Path &filename, Common::SeekableReadStream &stream);
112
113 bool isInCache(const Common::Path &filename) const { return _cache.isCached(filename); }
114
119
124
128 Common::SeekableReadStream *load(const Common::Path &filename, const Common::Path &libraryFile, bool suppressErrors = false);
129
133 bool exists(const Common::Path &filename) const;
134
140 int resourceIndex() const;
141
145 void getResourceNames(const Common::Path &libraryFile, Common::StringArray &names);
146
151
156
160 void decompress(Common::SeekableReadStream &source, byte *buffer, uint32 outSize);
161
166
170 static void decompressLZ(Common::SeekableReadStream &source, byte *outBuffer, int32 outSize, int32 inSize);
171};
172
173} // End of namespace Sherlock
174
175#endif
Definition: path.h:52
Definition: stream.h:745
Definition: resources.h:53
void load(const Common::Path &name)
bool isCached(const Common::Path &filename) const
Common::SeekableReadStream * get(const Common::Path &filename) const
void load(const Common::Path &name, Common::SeekableReadStream &stream)
Definition: resources.h:83
static void decompressLZ(Common::SeekableReadStream &source, byte *outBuffer, int32 outSize, int32 inSize)
bool exists(const Common::Path &filename) const
Common::SeekableReadStream * load(const Common::Path &filename, const Common::Path &libraryFile, bool suppressErrors=false)
Common::SeekableReadStream * decompress(Common::SeekableReadStream &source)
void decompressIfNecessary(Common::SeekableReadStream *&stream)
int resourceIndex() const
Common::SeekableReadStream * load(const Common::Path &filename)
void getResourceNames(const Common::Path &libraryFile, Common::StringArray &names)
static Common::SeekableReadStream * decompressLZ(Common::SeekableReadStream &source, uint32 outSize)
void addToCache(const Common::Path &filename, Common::SeekableReadStream &stream)
void decompress(Common::SeekableReadStream &source, byte *buffer, uint32 outSize)
void addToCache(const Common::Path &filename)
void addToCache(const Common::Path &filename, const Common::Path &libFilename)
Common::SeekableReadStream * decompress(Common::SeekableReadStream &source, uint32 outSize)
Definition: sherlock.h:206
Definition: resources.h:40