ScummVM API documentation
fastfile.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 TRECISION_FASTFILE_H
23 #define TRECISION_FASTFILE_H
24 
25 #include "common/archive.h"
26 #include "common/array.h"
27 #include "common/stream.h"
28 
29 namespace Trecision {
30 
31 class TrecisionEngine;
32 
33 struct FileEntry {
34  Common::Path name;
35  uint32 offset;
36 };
37 
38 class FastFile : public Common::Archive {
39 public:
40  FastFile();
41  ~FastFile() override;
42 
43  bool open(TrecisionEngine *vm, const Common::Path &filename);
44  void close();
45  bool isOpen() const { return _stream != 0; }
46  Common::SeekableReadStream *createReadStreamForCompressedMember(const Common::Path &name);
47 
48  // Common::Archive API implementation
49  bool hasFile(const Common::Path &path) const override;
50  int listMembers(Common::ArchiveMemberList &list) const override;
51  const Common::ArchiveMemberPtr getMember(const Common::Path &path) const override;
52  Common::SeekableReadStream *createReadStreamForMember(const Common::Path &path) const override;
53 
54 private:
56  Common::SeekableReadStream *_compStream;
57  Common::Array<FileEntry> _fileEntries;
58 
59  uint8 *_compBuffer;
60  const FileEntry *getEntry(const Common::Path &name) const;
61  void decompress(const uint8 *src, uint32 srcSize, uint8 *dst, uint32 decompSize);
62 };
63 
64 } // End of namespace Trecision
65 
66 #endif
Definition: fastfile.h:38
Definition: trecision.h:112
Definition: list.h:44
Definition: path.h:52
Definition: stream.h:745
Definition: archive.h:141
Definition: fastfile.h:33
Definition: actor.h:29
Definition: stream.h:944