ScummVM API documentation
nhcarchive.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 NEVERHOOD_NHCARCHIVE_H
23 #define NEVERHOOD_NHCARCHIVE_H
24 
25 #include "common/array.h"
26 #include "common/file.h"
27 #include "common/mutex.h"
28 #include "common/stream.h"
29 #include "common/substream.h"
30 #include "neverhood/neverhood.h"
31 
32 namespace Neverhood {
33 
35  uint32 fileHash;
36  uint32 type;
37  uint32 offset;
38  uint32 size;
39 
40  bool isNormal() const {
41  // Resources 0-10 replace resources with the same ID
42  // Resources 11 and 12 are under custom ID for subtitle font and saveload dialog messages
43  // 13 adds subtitles to a video with the same ID and so should not replace it
44  return type <= 10;
45  }
46 };
47 
48 class NhcArchive {
49 public:
50  NhcArchive() {}
51  ~NhcArchive() {}
52  bool open(const Common::Path &filename, bool isOptional);
53  void load(uint index, byte *buffer, uint32 size);
54  void load(NhcArchiveEntry *entry, byte *buffer, uint32 size);
55  uint32 getSize(uint index) { return _entries[index].size; }
56  NhcArchiveEntry *getEntry(uint index) { return &_entries[index]; }
57  uint getCount() { return _entries.size(); }
58  Common::SeekableReadStream *createStream(uint index);
59  Common::SeekableReadStream *createStream(NhcArchiveEntry *entry);
60 private:
61  Common::File _fd;
62  Common::Mutex _mutex;
64 };
65 
66 } // End of namespace Neverhood
67 
68 #endif /* NEVERHOOD_BLBARCHIVE_H */
Definition: background.h:30
Definition: array.h:52
Definition: nhcarchive.h:34
Definition: nhcarchive.h:48
Definition: path.h:52
Definition: stream.h:745
Definition: file.h:47
Definition: mutex.h:67