ScummVM API documentation
loader.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 MADS_CORE_LOADER_H
23#define MADS_CORE_LOADER_H
24
25#include "common/memstream.h"
26#include "common/stream.h"
27#include "mads/core/general.h"
28#include "mads/core/pack.h"
29
30namespace MADS {
31
32#define LOADER_DISK 0 /* File being read from disk */
33
34
35struct Load {
36 int open; /* Open status (true = open) */
37 int reading; /* Read/Write status (true = reading) */
38 byte mode; /* Access mode (LOADER_DISK) */
39 Common::SeekableReadStream *handle; /* File handle (if LOADER_DISK) */
40 long decompress_size; /* Decompressed size of file */
41 int pack_list_marker; /* Packing list marker */
42 PackList pack; /* Packing list */
43};
44
45typedef Load *LoadHandle;
46
51private:
53
54public:
55 LoaderReadStream(LoadHandle load, long size = -1);
56 ~LoaderReadStream() override;
57
58 int64 pos() const override {
59 return _data->pos();
60 }
61 int64 size() const override {
62 return _data->size();
63 }
64 bool seek(int64 offset, int whence = SEEK_SET) override {
65 return _data->seek(offset, whence);
66 }
67 bool eos() const override {
68 return _data->eos();
69 }
70 uint32 read(void *dataPtr, uint32 dataSize) override {
71 return _data->read(dataPtr, dataSize);
72 }
73};
74
75extern char loader_last[14];
76
77extern int loader_open(LoadHandle handle, const char *filename, const char *options, int flags);
78extern int loader_close(LoadHandle handle);
79extern void loader_set_priority(LoadHandle handle, int priority);
80extern long loader_read(void *target, long record_size, long record_count, LoadHandle handle);
81extern void loader_skip_entries(LoadHandle handle, int count);
82extern long loader_write(void *target, long record_size, long record_count, LoadHandle handle);
83extern long loader_write_2(Common::WriteStream *source_handle, long total_size, LoadHandle handle);
84
85} // namespace MADS
86
87#endif
Definition: memstream.h:43
bool seek(int64 offs, int whence=SEEK_SET) override
int64 size() const override
Definition: memstream.h:93
uint32 read(void *dataPtr, uint32 dataSize) override
bool eos() const override
Definition: memstream.h:89
int64 pos() const override
Definition: memstream.h:92
Definition: stream.h:745
Definition: stream.h:77
Definition: loader.h:50
int64 size() const override
Definition: loader.h:61
int64 pos() const override
Definition: loader.h:58
bool seek(int64 offset, int whence=SEEK_SET) override
Definition: loader.h:64
bool eos() const override
Definition: loader.h:67
uint32 read(void *dataPtr, uint32 dataSize) override
Definition: loader.h:70
Definition: loader.h:35
Definition: pack.h:98