22 #ifndef AGS_LIB_ALLEGRO_FILE_H 23 #define AGS_LIB_ALLEGRO_FILE_H 25 #include "ags/lib/allegro/alconfig.h" 26 #include "ags/shared/core/types.h" 27 #include "common/file.h" 34 #define F_BUF_SIZE 4096 39 unsigned char *buf_pos;
44 unsigned char buf[F_BUF_SIZE];
48 AL_METHOD(
int, pf_fclose, (
void *userdata));
49 AL_METHOD(
int, pf_getc, (
void *userdata));
50 AL_METHOD(
int, pf_ungetc, (
int c,
void *userdata));
51 AL_METHOD(
long, pf_fread, (
void *p,
long n,
void *userdata));
52 AL_METHOD(
int, pf_putc, (
int c,
void *userdata));
53 AL_METHOD(
long, pf_fwrite, (AL_CONST
void *p,
long n,
void *userdata));
54 AL_METHOD(
int, pf_fseek, (
void *userdata,
int offset));
55 AL_METHOD(
int, pf_feof, (
void *userdata));
56 AL_METHOD(
int, pf_ferror, (
void *userdata));
67 virtual void close() {}
68 virtual int pack_fseek(
int offset) = 0;
69 virtual int pack_getc() = 0;
70 virtual int pack_putc(
int c) = 0;
71 virtual int pack_ungetc(
int c) = 0;
72 virtual long pack_fread(
void *p,
long n) = 0;
73 virtual long pack_fwrite(AL_CONST
void *p,
long n) = 0;
74 virtual int pack_feof() = 0;
75 virtual int pack_ferror() = 0;
76 virtual void *pack_get_userdata()
const {
80 PACKFILE *pack_fopen_chunk(
int pack);
84 int pack_iputw(
int w);
85 int32_t pack_iputl(int32_t l);
88 int pack_mputw(
int w);
89 int32_t pack_mputl(int32_t l);
90 char *pack_fgets(
char *p,
int max);
91 int pack_fputs(AL_CONST
char *p);
103 void close()
override {
108 int pack_fseek(
int offset)
override {
109 return _stream->
seek(offset, SEEK_CUR);
112 int pack_getc()
override {
116 int pack_putc(
int c)
override {
117 error(
"pack_putc is not yet supported");
120 int pack_ungetc(
int c)
override {
121 _stream->
seek(-1, SEEK_CUR);
125 long pack_fread(
void *p,
long n)
override {
126 return _stream->
read(p, n);
129 long pack_fwrite(AL_CONST
void *p,
long n)
override {
130 error(
"pack_fwrite is not yet supported");
133 int pack_feof()
override {
134 return _stream->
eos();
137 int pack_ferror()
override {
138 return _stream->
err();
147 _vTable(vTable), _userData(userData) {
150 void close()
override {
151 _vTable->pf_fclose(_userData);
154 int pack_fseek(
int offset)
override {
155 return _vTable->pf_fseek(_userData, offset);
158 int pack_getc()
override {
159 return _vTable->pf_getc(_userData);
162 int pack_putc(
int c)
override {
163 return _vTable->pf_putc(c, _userData);
166 int pack_ungetc(
int c)
override {
167 return _vTable->pf_ungetc(c, _userData);
170 long pack_fread(
void *p,
long n)
override {
171 return _vTable->pf_fread(p, n, _userData);
174 long pack_fwrite(AL_CONST
void *p,
long n)
override {
175 return _vTable->pf_fwrite(p, n, _userData);
178 int pack_feof()
override {
179 return _vTable->pf_feof(_userData);
182 int pack_ferror()
override {
183 return _vTable->pf_ferror(_userData);
186 void *pack_get_userdata()
const override {
191 extern void set_filename_encoding(
int);
192 extern char *fix_filename_case(
char *path);
193 extern char *fix_filename_slashes(
char *path);
194 extern char *append_filename(
char *dest,
const char *path,
const char *filename,
int size);
195 extern char *canonicalize_filename(
char *dest,
const char *filename,
int size);
196 extern char *make_relative_filename(
char *dest,
const char *path,
const char *filename,
int size);
197 extern int is_relative_filename(
const char *filename);
199 AL_FUNC(
void, packfile_password, (AL_CONST
char *password));
200 AL_FUNC(
PACKFILE *, pack_fopen, (AL_CONST
char *filename, AL_CONST
char *mode));
202 AL_FUNC(
int, pack_fclose, (
PACKFILE *f));
203 AL_FUNC(
int, pack_fseek, (
PACKFILE *f,
int offset));
206 AL_FUNC(
int, pack_getc, (
PACKFILE *f));
207 AL_FUNC(
int, pack_putc, (
int c,
PACKFILE *f));
208 AL_FUNC(
int, pack_feof, (
PACKFILE *f));
209 AL_FUNC(
int, pack_ferror, (
PACKFILE *f));
210 AL_FUNC(
int, pack_igetw, (
PACKFILE *f));
211 AL_FUNC(int32_t, pack_igetl, (
PACKFILE *f));
212 AL_FUNC(
int, pack_iputw, (
int w,
PACKFILE *f));
213 AL_FUNC(int32_t, pack_iputl, (int32_t l,
PACKFILE *f));
214 AL_FUNC(
int, pack_mgetw, (
PACKFILE *f));
215 AL_FUNC(int32_t, pack_mgetl, (
PACKFILE *f));
216 AL_FUNC(
int, pack_mputw, (
int w,
PACKFILE *f));
217 AL_FUNC(int32_t, pack_mputl, (int32_t l,
PACKFILE *f));
218 AL_FUNC(
long, pack_fread, (
void *p,
long n,
PACKFILE *f));
219 AL_FUNC(
long, pack_fwrite, (AL_CONST
void *p,
long n,
PACKFILE *f));
220 AL_FUNC(
int, pack_ungetc, (
int c,
PACKFILE *f));
221 AL_FUNC(
char *, pack_fgets, (
char *p,
int max,
PACKFILE *f));
222 AL_FUNC(
int, pack_fputs, (AL_CONST
char *p,
PACKFILE *f));
223 AL_FUNC(
void *, pack_get_userdata, (
PACKFILE *f));
virtual bool err() const
Definition: stream.h:61
virtual bool seek(int64 offset, int whence=SEEK_SET)=0
virtual bool eos() const =0
byte readByte()
Definition: stream.h:434
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
virtual uint32 read(void *dataPtr, uint32 dataSize)=0