Skip to content

Latest commit

 

History

History
273 lines (221 loc) · 8.35 KB

physfs_internal.h

File metadata and controls

273 lines (221 loc) · 8.35 KB
 
Jul 6, 2001
Jul 6, 2001
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/*
* Internal function/structure declaration. Do NOT include in your
* application.
*
* Please see the file LICENSE in the source's root directory.
*
* This file written by Ryan C. Gordon.
*/
#ifndef _INCLUDE_PHYSFS_INTERNAL_H_
#define _INCLUDE_PHYSFS_INTERNAL_H_
#ifndef __PHYSICSFS_INTERNAL__
#error Do not include this header from your applications.
#endif
struct __PHYSFS_DIRREADER__;
Jul 6, 2001
Jul 6, 2001
18
struct __PHYSFS_FILEFUNCTIONS__;
Jul 6, 2001
Jul 6, 2001
19
20
21
22
23
24
25
26
27
typedef struct __PHYSFS_FILEHANDLE__
{
/*
* This is reserved for the driver to store information.
*/
void *opaque;
/*
Jul 6, 2001
Jul 6, 2001
28
* This should be the DirHandle that created this FileHandle.
Jul 6, 2001
Jul 6, 2001
29
*/
Jul 6, 2001
Jul 6, 2001
30
const struct __PHYSFS_DIRREADER__ *dirReader;
Jul 6, 2001
Jul 6, 2001
31
Jul 6, 2001
Jul 6, 2001
32
33
34
35
36
37
38
39
40
/*
* Pointer to the file i/o functions for this filehandle.
*/
const struct __PHYSFS_FILEFUNCTIONS__ *funcs;
} FileHandle;
typedef struct __PHYSFS_FILEFUNCTIONS__
{
Jul 6, 2001
Jul 6, 2001
41
42
43
/*
* Read more from the file.
*/
Jul 6, 2001
Jul 6, 2001
44
int (*read)(FileHandle *handle, void *buffer,
Jul 6, 2001
Jul 6, 2001
45
46
47
48
49
50
unsigned int objSize, unsigned int objCount);
/*
* Write more to the file. Archives don't have to implement this.
* (Set it to NULL if not implemented).
*/
Jul 6, 2001
Jul 6, 2001
51
int (*write)(FileHandle *handle, void *buffer,
Jul 6, 2001
Jul 6, 2001
52
53
54
55
56
unsigned int objSize, unsigned int objCount);
/*
* Returns non-zero if at end of file.
*/
Jul 6, 2001
Jul 6, 2001
57
int (*eof)(FileHandle *handle);
Jul 6, 2001
Jul 6, 2001
58
59
60
61
/*
* Returns byte offset from start of file.
*/
Jul 6, 2001
Jul 6, 2001
62
int (*tell)(FileHandle *handle);
Jul 6, 2001
Jul 6, 2001
63
64
65
66
67
/*
* Move read/write pointer to byte offset from start of file.
* Returns non-zero on success, zero on error.
*/
Jul 6, 2001
Jul 6, 2001
68
int (*seek)(FileHandle *handle, int offset);
Jul 6, 2001
Jul 6, 2001
69
70
/*
Jul 6, 2001
Jul 6, 2001
71
* Close the file, and free the FileHandle structure (including "opaque").
Jul 6, 2001
Jul 6, 2001
72
*/
Jul 6, 2001
Jul 6, 2001
73
74
int (*close)(FileHandle *handle);
} FileFunctions;
Jul 6, 2001
Jul 6, 2001
75
76
77
78
79
80
81
82
83
typedef struct __PHYSFS_DIRREADER__
{
/*
* This is reserved for the driver to store information.
*/
void *opaque;
Jul 6, 2001
Jul 6, 2001
84
85
86
87
88
89
90
/*
* Pointer to the directory i/o functions for this reader.
*/
const struct __PHYSFS_DIRFUNCTIONS__ *funcs;
} DirHandle;
Jul 6, 2001
Jul 6, 2001
91
92
93
94
95
96
typedef struct __PHYSFS_LINKEDSTRINGLIST__
{
char *str;
struct __PHYSFS_LINKEDSTRINGLIST__ *next;
} LinkedStringList;
Jul 6, 2001
Jul 6, 2001
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
* Symlinks should always be followed; PhysicsFS will use
* DirFunctions->isSymLink() and make a judgement on whether to
* continue to call other methods based on that.
*/
typedef struct __PHYSFS_DIRFUNCTIONS__
{
/*
* Returns non-zero if (filename) is a valid archive that this
* driver can handle. This filename is in platform-dependent
* notation.
*/
int (*isArchive)(const char *filename);
/*
* Return a DirHandle for dir/archive (name).
* This filename is in platform-dependent notation.
* return (NULL) on error.
*/
DirHandle *(*openArchive)(const char *name);
Jul 6, 2001
Jul 6, 2001
118
/*
Jul 6, 2001
Jul 6, 2001
119
120
121
122
123
* Returns a list of all files in dirname. Each element of this list
* (and its "str" field) will be deallocated with the system's free()
* function by the caller, so be sure to explicitly malloc() each
* chunk.
* If you have a memory failure, return as much as you can.
Jul 6, 2001
Jul 6, 2001
124
* This dirname is in platform-independent notation.
Jul 6, 2001
Jul 6, 2001
125
*/
Jul 6, 2001
Jul 6, 2001
126
LinkedStringList **(*enumerateFiles)(DirHandle *r, const char *dirname);
Jul 6, 2001
Jul 6, 2001
127
128
129
/*
* Returns non-zero if filename is really a directory.
Jul 6, 2001
Jul 6, 2001
130
* This filename is in platform-independent notation.
Jul 6, 2001
Jul 6, 2001
131
*/
Jul 6, 2001
Jul 6, 2001
132
int (*isDirectory)(DirHandle *r, const char *name);
Jul 6, 2001
Jul 6, 2001
133
134
135
/*
* Returns non-zero if filename is really a symlink.
Jul 6, 2001
Jul 6, 2001
136
* This filename is in platform-independent notation.
Jul 6, 2001
Jul 6, 2001
137
*/
Jul 6, 2001
Jul 6, 2001
138
int (*isSymLink)(DirHandle *r, const char *name);
Jul 6, 2001
Jul 6, 2001
139
140
141
/*
* Returns non-zero if filename can be opened for reading.
Jul 6, 2001
Jul 6, 2001
142
* This filename is in platform-independent notation.
Jul 6, 2001
Jul 6, 2001
143
*/
Jul 6, 2001
Jul 6, 2001
144
int (*isOpenable)(DirHandle *r, const char *name);
Jul 6, 2001
Jul 6, 2001
145
146
147
/*
* Open file for reading, and return a FileHandle.
Jul 6, 2001
Jul 6, 2001
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
* This filename is in platform-independent notation.
*/
FileHandle *(*openRead)(DirHandle *r, const char *filename);
/*
* Open file for writing, and return a FileHandle.
* This filename is in platform-independent notation.
* This method may be NULL.
*/
FileHandle *(*openWrite)(DirHandle *r, const char *filename);
/*
* Open file for appending, and return a FileHandle.
* This filename is in platform-independent notation.
* This method may be NULL.
Jul 6, 2001
Jul 6, 2001
163
*/
Jul 6, 2001
Jul 6, 2001
164
FileHandle *(*openAppend)(DirHandle *r, const char *filename);
Jul 6, 2001
Jul 6, 2001
165
166
/*
Jul 6, 2001
Jul 6, 2001
167
* Close directories/archives, and free the handle, including
Jul 6, 2001
Jul 6, 2001
168
* the "opaque" entry. This should assume that it won't be called if
Jul 6, 2001
Jul 6, 2001
169
* there are still files open from this DirHandle.
Jul 6, 2001
Jul 6, 2001
170
*/
Jul 6, 2001
Jul 6, 2001
171
172
void (*close)(DirHandle *r);
} DirFunctions;
Jul 6, 2001
Jul 6, 2001
173
174
175
176
177
178
/* error messages... */
#define ERR_IS_INITIALIZED "Already initialized"
#define ERR_NOT_INITIALIZED "Not initialized"
#define ERR_INVALID_ARGUMENT "Invalid argument"
Jul 6, 2001
Jul 6, 2001
179
#define ERR_FILES_OPEN_READ "Files still open for reading"
Jul 6, 2001
Jul 6, 2001
180
181
182
183
184
#define ERR_FILES_OPEN_WRITE "Files still open for writing"
#define ERR_NO_DIR_CREATE "Failed to create directories"
#define ERR_OUT_OF_MEMORY "Out of memory"
#define ERR_NOT_IN_SEARCH_PATH "No such entry in search path"
#define ERR_NOT_SUPPORTED "Operation not supported"
Jul 6, 2001
Jul 6, 2001
185
#define ERR_UNSUPPORTED_ARCHIVE "Archive type unsupported"
Jul 6, 2001
Jul 6, 2001
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
/*
* Call this to set the message returned by PHYSFS_getLastError().
* Please only use the ERR_* constants above, or add new constants to the
* above group, but I want these all in one place.
*/
void __PHYSFS_setError(const char *err);
/* This gets used all over for lessening code clutter. */
#define BAIL_IF_MACRO(c, e, r) if (c) { __PHYSFS_setError(e); return(r); }
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
/*------------ ----------------*/
/*------------ You MUST implement the following functions ----------------*/
/*------------ if porting to a new platform. ----------------*/
/*------------ (see unix.c for an example) ----------------*/
/*------------ ----------------*/
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
/*
* The dir separator; "/" on unix, "\\" on win32, ":" on MacOS, etc...
* Obviously, this isn't a function, but it IS a null-terminated string.
*/
extern const char *__PHYSFS_PlatformDirSeparator;
/*
* Platform implementation of PHYSFS_getCdRomDirs()...
* See physfs.h. The retval should be freeable via PHYSFS_freeList().
*/
char **__PHYSFS_platformDetectAvailableCDs(void);
/*
* Calculate the base dir, if your platform needs special consideration.
* Just return NULL if the standard routines will suffice. (see
* calculateBaseDir() in physfs.c ...)
* Caller will free() the retval if it's not NULL.
*/
char *__PHYSFS_platformCalcBaseDir(char *argv0);
/*
* Get the platform-specific user name.
* Caller will free() the retval if it's not NULL. If it's NULL, the username
* will default to "default".
*/
char *__PHYSFS_platformGetUserName(void);
/*
* Get the platform-specific user dir.
* Caller will free() the retval if it's not NULL. If it's NULL, the userdir
* will default to basedir/username.
*/
char *__PHYSFS_platformGetUserDir(void);
/*
* Return a number that uniquely identifies the current thread.
* On a platform without threading, (1) will suffice. These numbers are
* arbitrary; the only requirement is that no two threads have the same
* number.
*/
int __PHYSFS_platformGetThreadID(void);
/*
* This is a pass-through to whatever stricmp() is called on your platform.
*/
int __PHYSFS_platformStricmp(const char *str1, const char *str2);
Jul 6, 2001
Jul 6, 2001
260
261
262
263
264
/*
* Return non-zero if filename (in platform-dependent notation) is a symlink.
*/
int __PHYSFS_platformIsSymlink(const char *fname);
Jul 6, 2001
Jul 6, 2001
265
266
267
268
269
270
271
272
#ifdef __cplusplus
extern "C" {
#endif
#endif
/* end of physfs_internal.h ... */