ScummVM API documentation
flex_file.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 ULTIMA8_FILESYS_FLEXFILE_H
23 #define ULTIMA8_FILESYS_FLEXFILE_H
24 
25 namespace Ultima {
26 namespace Ultima8 {
27 
28 class FlexFile {
29 public:
33  ~FlexFile();
34 
36  bool isValid() const {
37  return _valid;
38  }
39 
42  bool exists(uint32 index) {
43  return getSize(index) > 0;
44  }
45 
48  Common::SeekableReadStream *getDataSource(uint32 index, bool is_text = false);
49 
55  uint8 *getObject(uint32 index, uint32 *size = nullptr);
56 
60  uint32 getSize(uint32 index) const;
61 
65  uint32 getCount() const {
66  return _entries.size();
67  }
68 
69  static bool isFlexFile(Common::SeekableReadStream *rs);
70 
71 protected:
73  bool _valid;
74 
75  struct FileEntry {
76  uint32 _offset;
77  uint32 _size;
78  FileEntry() : _offset(0), _size(0) {}
79  };
80 
81  Common::Array<FileEntry> _entries;
82 
83 private:
84  bool readMetadata();
85 };
86 
87 } // End of namespace Ultima8
88 } // End of namespace Ultima
89 
90 #endif
bool exists(uint32 index)
Definition: flex_file.h:42
Definition: flex_file.h:28
Definition: stream.h:745
uint32 getSize(uint32 index) const
bool isValid() const
Check if constructed object is indeed a valid archive.
Definition: flex_file.h:36
uint8 * getObject(uint32 index, uint32 *size=nullptr)
Definition: detection.h:27
FlexFile(Common::SeekableReadStream *rs)
Common::SeekableReadStream * getDataSource(uint32 index, bool is_text=false)
uint32 getCount() const
Definition: flex_file.h:65
size_type size() const
Definition: array.h:315
Definition: flex_file.h:75