ScummVM API documentation
sys_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 M4_FILEIO_SYS_FILE_H
23#define M4_FILEIO_SYS_FILE_H
24
25#include "common/file.h"
26#include "m4/fileio/fileio.h"
27#include "m4/mem/reloc.h"
28
29namespace M4 {
30
32 Common::String filename;
33 byte hagfile;
34 byte disks;
35 uint32 offset;
36 uint32 size;
37};
38
40 bool hag_flag = false;
41 bool first_read_flag = false;
42 Common::Path hash_file;
43 Hag_Name_Record *hag_name_list = nullptr;
44 Hag_Record *hag_file_list = nullptr;
45};
46
47class SysFile {
48private:
49 Common::Stream *_fp = nullptr;
50 FileMode fmode;
51 AccessMode mode = UNOPENED;
52 int hag_success = 0;
53 bool show_error_flag = true;
54 Hag_Record *curr_hag_record = nullptr;
55 Hash_Record curr_hash_record;
56 uint32 last_head_pos = 0;
57
58private:
59 void open_read();
60 void open_read_low_level();
61 bool open_hash_file();
62 Common::String get_last_string(const Common::String &src);
63
67 uint32 key_to_hash_address(const Common::String &src, uint32 hash_table_size);
68
75 int hash_search(const Common::String &fname, Hash_Record *current_hash_record_ptr, Hag_Record *curr_hag_record, uint32 hash_address,
76 Common::SeekableReadStream *hashfp, uint32 hash_table_size, bool show_error_flag);
77
82 Common::Stream *open_by_first_char();
83
84 bool get_local_name_from_hagfile(Common::String &local_name, byte hagfile);
85
87
88public:
89 Common::String filename;
90
91public:
92 SysFile(const Common::String &fname, FileMode myfmode = BINARY);
93
97 bool exists();
98
102 uint32 size();
103
107 uint32 get_pos();
108
112 bool seek(uint32 pos);
113
117 bool seek_ahead(int32 amount);
118
122 uint32 read(MemHandle bufferHandle);
123 int32 read(MemHandle bufferHandle, int32 n);
124 int32 read(byte *bufferHandle, int32 n);
125
129 byte readByte();
130 int8 readSByte() {
131 return (int8)readByte();
132 }
133
137 uint16 readUint16LE();
138 int16 readSint16LE() {
139 return (int16)readUint16LE();
140 }
141
145 uint32 readUint32LE();
146 int32 readSint32LE() {
147 return (int32)readUint32LE();
148 }
149
153 void close();
154};
155
156void sysfile_init(bool in_hag_mode);
157void sysfile_shutdown();
158
159} // namespace M4
160
161#endif
Definition: path.h:52
Definition: stream.h:745
Definition: stream.h:48
Definition: str.h:59
Definition: sys_file.h:47
uint32 read(MemHandle bufferHandle)
uint16 readUint16LE()
byte readByte()
bool seek_ahead(int32 amount)
void close()
bool exists()
uint32 size()
uint32 readUint32LE()
bool seek(uint32 pos)
uint32 get_pos()
Definition: database.h:28
Definition: fileio.h:39
Definition: fileio.h:45
Definition: sys_file.h:39
Definition: sys_file.h:31