ScummVM API documentation
fileio.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
/*
23
* This code is based on original Soltys source code
24
* Copyright (c) 1994-1995 Janusz B. Wisniewski and L.K. Avalon
25
*/
26
27
#ifndef CGE_FILEIO_H
28
#define CGE_FILEIO_H
29
30
#include "cge/general.h"
31
#include "common/stream.h"
32
33
namespace
CGE {
34
35
#define kBtSize 1024
36
#define kBtKeySize 13
37
#define kBtLevel 2
38
#define kBtInnerCount ((kBtSize - 4
/*sizeof(Hea) */
) / (kBtKeySize + 2
/*sizeof(Inner) */
))
39
#define kBtLeafCount ((kBtSize - 4
/*sizeof(Hea) */
) / (kBtKeySize + 4 + 2
/*sizeof(BtKeypack) */
))
40
#define kBtValNone 0xFFFF
41
#define kBtValRoot 0
42
#define kCatName "VOL.CAT"
43
#define kDatName "VOL.DAT"
44
45
struct
BtKeypack
{
46
char
_key[kBtKeySize];
47
uint32 _pos;
48
uint16 _size;
49
};
50
51
struct
Inner
{
52
uint8 _key[kBtKeySize];
53
uint16 _down;
54
};
55
56
struct
Header
{
57
uint16 _count;
58
uint16 _down;
59
};
60
61
struct
BtPage
{
62
Header
_header;
63
union
{
64
// dummy filler to make proper size of union
65
uint8 _data[kBtSize - 4];
/* 4 is the size of struct Header */
66
// inner version of data: key + word-sized page link
67
Inner
_inner[kBtInnerCount];
68
// leaf version of data: key + all user data
69
BtKeypack
_leaf[kBtLeafCount];
70
};
71
72
void
readBTree(
Common::ReadStream
&s);
73
};
74
75
class
ResourceManager
{
76
struct
{
77
BtPage
*_page;
78
uint16 _pageNo;
79
int
_index;
80
} _buff[kBtLevel];
81
82
BtPage
*getPage(
int
level, uint16 pageId);
83
uint16 catRead(
byte
*buf, uint16 length);
84
Common::File
*_catFile;
85
Common::File
*_datFile;
86
void
XCrypt(
byte
*buf, uint16 length);
87
public
:
88
89
ResourceManager
();
90
~ResourceManager
();
91
uint16 read(
byte
*buf, uint16 length);
92
bool
seek(int32 offs,
int
whence = SEEK_SET);
93
94
BtKeypack
*find(
const
char
*key);
95
bool
exist(
const
char
*name);
96
};
97
98
class
EncryptedStream
{
99
private
:
100
Common::SeekableReadStream
*_readStream;
101
bool
_error;
102
public
:
103
EncryptedStream
(
ResourceManager
*resman,
const
char
*name);
104
~EncryptedStream
();
105
bool
err();
106
bool
eos();
107
bool
seek(int32 offset);
108
int32 pos();
109
int32 size();
110
uint32 read(
byte
*dataPtr, uint32 dataSize);
111
Common::String
readLine();
112
};
113
114
}
// End of namespace CGE
115
116
#endif
CGE::EncryptedStream
Definition:
fileio.h:98
CGE::ResourceManager
Definition:
fileio.h:75
Common::File
Definition:
file.h:47
Common::ReadStream
Definition:
stream.h:385
Common::SeekableReadStream
Definition:
stream.h:745
Common::String
Definition:
str.h:59
CGE::BtKeypack
Definition:
fileio.h:45
CGE::BtPage
Definition:
fileio.h:61
CGE::Header
Definition:
fileio.h:56
CGE::Inner
Definition:
fileio.h:51
engines
cge
fileio.h
Generated on Sat Oct 24 2026 09:15:53 for ScummVM API documentation by
1.9.4