9
|
1 |
/*
|
|
2 |
* Internal function/structure declaration. Do NOT include in your
|
|
3 |
* application.
|
|
4 |
*
|
|
5 |
* Please see the file LICENSE in the source's root directory.
|
|
6 |
*
|
|
7 |
* This file written by Ryan C. Gordon.
|
|
8 |
*/
|
|
9 |
|
|
10 |
#ifndef _INCLUDE_PHYSFS_INTERNAL_H_
|
|
11 |
#define _INCLUDE_PHYSFS_INTERNAL_H_
|
|
12 |
|
|
13 |
#ifndef __PHYSICSFS_INTERNAL__
|
|
14 |
#error Do not include this header from your applications.
|
|
15 |
#endif
|
|
16 |
|
|
17 |
struct __PHYSFS_DIRREADER__;
|
|
18 |
|
|
19 |
typedef struct __PHYSFS_FILEHANDLE__
|
|
20 |
{
|
|
21 |
/*
|
|
22 |
* This is reserved for the driver to store information.
|
|
23 |
*/
|
|
24 |
void *opaque;
|
|
25 |
|
|
26 |
/*
|
|
27 |
* This should be the DirReader that created this FileHandle.
|
|
28 |
*/
|
|
29 |
struct __PHYSFS_DIRREADER__ *dirReader;
|
|
30 |
|
|
31 |
/*
|
|
32 |
* Read more from the file.
|
|
33 |
*/
|
|
34 |
int (*read)(struct __PHYSFS_FILEHANDLE__ *handle, void *buffer,
|
|
35 |
unsigned int objSize, unsigned int objCount);
|
|
36 |
|
|
37 |
/*
|
|
38 |
* Write more to the file. Archives don't have to implement this.
|
|
39 |
* (Set it to NULL if not implemented).
|
|
40 |
*/
|
|
41 |
int (*write)(struct __PHYSFS_FILEHANDLE__ *handle, void *buffer,
|
|
42 |
unsigned int objSize, unsigned int objCount);
|
|
43 |
|
|
44 |
/*
|
|
45 |
* Returns non-zero if at end of file.
|
|
46 |
*/
|
|
47 |
int (*eof)(struct __PHYSFS_FILEHANDLE__ *handle);
|
|
48 |
|
|
49 |
/*
|
|
50 |
* Returns byte offset from start of file.
|
|
51 |
*/
|
|
52 |
int (*tell)(struct __PHYSFS_FILEHANDLE__ *handle);
|
|
53 |
|
|
54 |
/*
|
|
55 |
* Move read/write pointer to byte offset from start of file.
|
|
56 |
* Returns non-zero on success, zero on error.
|
|
57 |
*/
|
|
58 |
int (*seek)(struct __PHYSFS_FILEHANDLE__ *handle, int offset);
|
|
59 |
|
|
60 |
/*
|
|
61 |
* Close the file, and free this structure (including "opaque").
|
|
62 |
*/
|
|
63 |
int (*close)(void);
|
|
64 |
} FileHandle;
|
|
65 |
|
|
66 |
|
|
67 |
typedef struct __PHYSFS_DIRREADER__
|
|
68 |
{
|
|
69 |
/*
|
|
70 |
* This is reserved for the driver to store information.
|
|
71 |
*/
|
|
72 |
void *opaque;
|
|
73 |
|
|
74 |
/*
|
|
75 |
* Returns a list (freeable via PHYSFS_freeList()) of
|
|
76 |
* all files in dirname.
|
|
77 |
* Symlinks should be followed.
|
|
78 |
*/
|
|
79 |
char **(*enumerateFiles)(struct __PHYSFS_DIRREADER__ *r, const char *dirname);
|
|
80 |
|
|
81 |
/*
|
|
82 |
* Returns non-zero if filename is really a directory.
|
|
83 |
* Symlinks should be followed.
|
|
84 |
*/
|
|
85 |
int (*isDirectory)(struct __PHYSFS_DIRREADER__ *r, const char *name);
|
|
86 |
|
|
87 |
/*
|
|
88 |
* Returns non-zero if filename is really a symlink.
|
|
89 |
*/
|
|
90 |
int (*isSymLink)(struct __PHYSFS_DIRREADER__ *r, const char *name);
|
|
91 |
|
|
92 |
/*
|
|
93 |
* Returns non-zero if filename can be opened for reading.
|
|
94 |
* Symlinks should be followed.
|
|
95 |
*/
|
|
96 |
int (*isOpenable)(struct __PHYSFS_DIRREADER__ *r, const char *name);
|
|
97 |
|
|
98 |
/*
|
|
99 |
* Open file for reading, and return a FileHandle.
|
|
100 |
* Symlinks should be followed.
|
|
101 |
*/
|
|
102 |
FileHandle *(*openRead)(struct __PHYSFS_DIRREADER__ *r, const char *filename);
|
|
103 |
|
|
104 |
/*
|
|
105 |
* Close directories/archives, and free this structure, including
|
|
106 |
* the "opaque" entry. This should assume that it won't be called if
|
|
107 |
* there are still files open from this DirReader.
|
|
108 |
*/
|
|
109 |
void (*close)(struct __PHYSFS_DIRREADER__ *r);
|
|
110 |
} DirReader;
|
|
111 |
|
|
112 |
|
|
113 |
/* error messages... */
|
|
114 |
#define ERR_IS_INITIALIZED "Already initialized"
|
|
115 |
#define ERR_NOT_INITIALIZED "Not initialized"
|
|
116 |
#define ERR_INVALID_ARGUMENT "Invalid argument"
|
|
117 |
#define ERR_FILES_OPEN_WRITE "Files still open for writing"
|
|
118 |
#define ERR_NO_DIR_CREATE "Failed to create directories"
|
|
119 |
#define ERR_OUT_OF_MEMORY "Out of memory"
|
|
120 |
#define ERR_NOT_IN_SEARCH_PATH "No such entry in search path"
|
|
121 |
#define ERR_NOT_SUPPORTED "Operation not supported"
|
|
122 |
|
|
123 |
|
|
124 |
/*
|
|
125 |
* Call this to set the message returned by PHYSFS_getLastError().
|
|
126 |
* Please only use the ERR_* constants above, or add new constants to the
|
|
127 |
* above group, but I want these all in one place.
|
|
128 |
*/
|
|
129 |
void __PHYSFS_setError(const char *err);
|
|
130 |
|
|
131 |
|
|
132 |
/* This gets used all over for lessening code clutter. */
|
|
133 |
#define BAIL_IF_MACRO(c, e, r) if (c) { __PHYSFS_setError(e); return(r); }
|
|
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
|
138 |
/*--------------------------------------------------------------------------*/
|
|
139 |
/*--------------------------------------------------------------------------*/
|
|
140 |
/*------------ ----------------*/
|
|
141 |
/*------------ You MUST implement the following functions ----------------*/
|
|
142 |
/*------------ if porting to a new platform. ----------------*/
|
|
143 |
/*------------ (see unix.c for an example) ----------------*/
|
|
144 |
/*------------ ----------------*/
|
|
145 |
/*--------------------------------------------------------------------------*/
|
|
146 |
/*--------------------------------------------------------------------------*/
|
|
147 |
|
|
148 |
|
|
149 |
/*
|
|
150 |
* The dir separator; "/" on unix, "\\" on win32, ":" on MacOS, etc...
|
|
151 |
* Obviously, this isn't a function, but it IS a null-terminated string.
|
|
152 |
*/
|
|
153 |
extern const char *__PHYSFS_PlatformDirSeparator;
|
|
154 |
|
|
155 |
/*
|
|
156 |
* Platform implementation of PHYSFS_getCdRomDirs()...
|
|
157 |
* See physfs.h. The retval should be freeable via PHYSFS_freeList().
|
|
158 |
*/
|
|
159 |
char **__PHYSFS_platformDetectAvailableCDs(void);
|
|
160 |
|
|
161 |
/*
|
|
162 |
* Calculate the base dir, if your platform needs special consideration.
|
|
163 |
* Just return NULL if the standard routines will suffice. (see
|
|
164 |
* calculateBaseDir() in physfs.c ...)
|
|
165 |
* Caller will free() the retval if it's not NULL.
|
|
166 |
*/
|
|
167 |
char *__PHYSFS_platformCalcBaseDir(char *argv0);
|
|
168 |
|
|
169 |
/*
|
|
170 |
* Get the platform-specific user name.
|
|
171 |
* Caller will free() the retval if it's not NULL. If it's NULL, the username
|
|
172 |
* will default to "default".
|
|
173 |
*/
|
|
174 |
char *__PHYSFS_platformGetUserName(void);
|
|
175 |
|
|
176 |
/*
|
|
177 |
* Get the platform-specific user dir.
|
|
178 |
* Caller will free() the retval if it's not NULL. If it's NULL, the userdir
|
|
179 |
* will default to basedir/username.
|
|
180 |
*/
|
|
181 |
char *__PHYSFS_platformGetUserDir(void);
|
|
182 |
|
|
183 |
/*
|
|
184 |
* Return a number that uniquely identifies the current thread.
|
|
185 |
* On a platform without threading, (1) will suffice. These numbers are
|
|
186 |
* arbitrary; the only requirement is that no two threads have the same
|
|
187 |
* number.
|
|
188 |
*/
|
|
189 |
int __PHYSFS_platformGetThreadID(void);
|
|
190 |
|
|
191 |
/*
|
|
192 |
* This is a pass-through to whatever stricmp() is called on your platform.
|
|
193 |
*/
|
|
194 |
int __PHYSFS_platformStricmp(const char *str1, const char *str2);
|
|
195 |
|
|
196 |
|
|
197 |
#ifdef __cplusplus
|
|
198 |
extern "C" {
|
|
199 |
#endif
|
|
200 |
|
|
201 |
#endif
|
|
202 |
|
|
203 |
/* end of physfs_internal.h ... */
|
|
204 |
|