author | Ryan C. Gordon <icculus@icculus.org> |
Thu, 23 Aug 2001 15:23:21 +0000 | |
changeset 69 | 546a95cc5591 |
parent 49 | 5e6d33615d30 |
child 126 | f5135b499c0c |
permissions | -rw-r--r-- |
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 |
||
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
17 |
struct __PHYSFS_DIRHANDLE__; |
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
18 |
struct __PHYSFS_FILEFUNCTIONS__; |
9 | 19 |
|
20
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
20 |
|
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
21 |
typedef struct __PHYSFS_LINKEDSTRINGLIST__ |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
22 |
{ |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
23 |
char *str; |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
24 |
struct __PHYSFS_LINKEDSTRINGLIST__ *next; |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
25 |
} LinkedStringList; |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
26 |
|
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
27 |
|
9 | 28 |
typedef struct __PHYSFS_FILEHANDLE__ |
29 |
{ |
|
30 |
/* |
|
31 |
* This is reserved for the driver to store information. |
|
32 |
*/ |
|
33 |
void *opaque; |
|
34 |
||
35 |
/* |
|
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
36 |
* This should be the DirHandle that created this FileHandle. |
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
37 |
*/ |
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
38 |
const struct __PHYSFS_DIRHANDLE__ *dirHandle; |
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
39 |
|
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
40 |
/* |
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
41 |
* Pointer to the file i/o functions for this filehandle. |
9 | 42 |
*/ |
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
43 |
const struct __PHYSFS_FILEFUNCTIONS__ *funcs; |
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
44 |
} FileHandle; |
9 | 45 |
|
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
46 |
|
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
47 |
typedef struct __PHYSFS_FILEFUNCTIONS__ |
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
48 |
{ |
9 | 49 |
/* |
50 |
* Read more from the file. |
|
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
51 |
* Returns number of objects of (objSize) bytes read from file, -1 |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
52 |
* if complete failure. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
53 |
* On failure, call __PHYSFS_setError(). |
9 | 54 |
*/ |
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
55 |
int (*read)(FileHandle *handle, void *buffer, |
9 | 56 |
unsigned int objSize, unsigned int objCount); |
57 |
||
58 |
/* |
|
59 |
* Write more to the file. Archives don't have to implement this. |
|
60 |
* (Set it to NULL if not implemented). |
|
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
61 |
* Returns number of objects of (objSize) bytes written to file, -1 |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
62 |
* if complete failure. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
63 |
* On failure, call __PHYSFS_setError(). |
9 | 64 |
*/ |
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
65 |
int (*write)(FileHandle *handle, void *buffer, |
9 | 66 |
unsigned int objSize, unsigned int objCount); |
67 |
||
68 |
/* |
|
69 |
* Returns non-zero if at end of file. |
|
70 |
*/ |
|
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
71 |
int (*eof)(FileHandle *handle); |
9 | 72 |
|
73 |
/* |
|
74 |
* Returns byte offset from start of file. |
|
75 |
*/ |
|
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
76 |
int (*tell)(FileHandle *handle); |
9 | 77 |
|
78 |
/* |
|
79 |
* Move read/write pointer to byte offset from start of file. |
|
80 |
* Returns non-zero on success, zero on error. |
|
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
81 |
* On failure, call __PHYSFS_setError(). |
9 | 82 |
*/ |
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
83 |
int (*seek)(FileHandle *handle, int offset); |
9 | 84 |
|
85 |
/* |
|
28
529214f57d1b
Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents:
23
diff
changeset
|
86 |
* Return number of bytes available in the file, or -1 if you |
529214f57d1b
Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents:
23
diff
changeset
|
87 |
* aren't able to determine. |
529214f57d1b
Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents:
23
diff
changeset
|
88 |
* On failure, call __PHYSFS_setError(). |
529214f57d1b
Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents:
23
diff
changeset
|
89 |
*/ |
529214f57d1b
Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents:
23
diff
changeset
|
90 |
int (*fileLength)(FileHandle *handle); |
529214f57d1b
Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents:
23
diff
changeset
|
91 |
|
529214f57d1b
Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents:
23
diff
changeset
|
92 |
/* |
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
93 |
* Close the file, and free the FileHandle structure (including "opaque"). |
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
94 |
* returns non-zero on success, zero if can't close file. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
95 |
* On failure, call __PHYSFS_setError(). |
9 | 96 |
*/ |
20
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
97 |
int (*fileClose)(FileHandle *handle); |
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
98 |
} FileFunctions; |
9 | 99 |
|
100 |
||
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
101 |
typedef struct __PHYSFS_DIRHANDLE__ |
9 | 102 |
{ |
103 |
/* |
|
104 |
* This is reserved for the driver to store information. |
|
105 |
*/ |
|
106 |
void *opaque; |
|
107 |
||
108 |
/* |
|
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
109 |
* Pointer to the directory i/o functions for this handle. |
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
110 |
*/ |
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
111 |
const struct __PHYSFS_DIRFUNCTIONS__ *funcs; |
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
112 |
} DirHandle; |
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
113 |
|
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
114 |
|
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
115 |
/* |
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
116 |
* Symlinks should always be followed; PhysicsFS will use |
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
117 |
* DirFunctions->isSymLink() and make a judgement on whether to |
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
118 |
* continue to call other methods based on that. |
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
119 |
*/ |
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
120 |
typedef struct __PHYSFS_DIRFUNCTIONS__ |
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
121 |
{ |
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
122 |
/* |
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
123 |
* Returns non-zero if (filename) is a valid archive that this |
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
124 |
* driver can handle. This filename is in platform-dependent |
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
125 |
* notation. forWriting is non-zero if this is to be used for |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
126 |
* the write directory, and zero if this is to be used for an |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
127 |
* element of the search path. |
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
128 |
*/ |
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
129 |
int (*isArchive)(const char *filename, int forWriting); |
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
130 |
|
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
131 |
/* |
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
132 |
* Return a DirHandle for dir/archive (name). |
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
133 |
* This filename is in platform-dependent notation. |
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
134 |
* forWriting is non-zero if this is to be used for |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
135 |
* the write directory, and zero if this is to be used for an |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
136 |
* element of the search path. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
137 |
* Returns NULL on failure, and calls __PHYSFS_setError(). |
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
138 |
*/ |
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
139 |
DirHandle *(*openArchive)(const char *name, int forWriting); |
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
140 |
|
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
141 |
/* |
12
a4041c91d715
Redesign of enumerateFiles code. More efficient and clean, less memory
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
142 |
* Returns a list of all files in dirname. Each element of this list |
a4041c91d715
Redesign of enumerateFiles code. More efficient and clean, less memory
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
143 |
* (and its "str" field) will be deallocated with the system's free() |
a4041c91d715
Redesign of enumerateFiles code. More efficient and clean, less memory
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
144 |
* function by the caller, so be sure to explicitly malloc() each |
41
ff60d39d0862
Architecture adjustment for enumerating files with regards to whether
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
145 |
* chunk. Omit symlinks if (omitSymLinks) is non-zero. |
12
a4041c91d715
Redesign of enumerateFiles code. More efficient and clean, less memory
Ryan C. Gordon <icculus@icculus.org>
parents:
11
diff
changeset
|
146 |
* If you have a memory failure, return as much as you can. |
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
147 |
* This dirname is in platform-independent notation. |
9 | 148 |
*/ |
41
ff60d39d0862
Architecture adjustment for enumerating files with regards to whether
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
149 |
LinkedStringList *(*enumerateFiles)(DirHandle *r, |
ff60d39d0862
Architecture adjustment for enumerating files with regards to whether
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
150 |
const char *dirname, |
ff60d39d0862
Architecture adjustment for enumerating files with regards to whether
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
151 |
int omitSymLinks); |
ff60d39d0862
Architecture adjustment for enumerating files with regards to whether
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
152 |
|
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
153 |
|
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
154 |
/* |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
155 |
* Returns non-zero if filename can be opened for reading. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
156 |
* This filename is in platform-independent notation. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
157 |
*/ |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
158 |
int (*exists)(DirHandle *r, const char *name); |
9 | 159 |
|
160 |
/* |
|
161 |
* Returns non-zero if filename is really a directory. |
|
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
162 |
* This filename is in platform-independent notation. |
9 | 163 |
*/ |
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
164 |
int (*isDirectory)(DirHandle *r, const char *name); |
9 | 165 |
|
166 |
/* |
|
167 |
* Returns non-zero if filename is really a symlink. |
|
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
168 |
* This filename is in platform-independent notation. |
9 | 169 |
*/ |
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
170 |
int (*isSymLink)(DirHandle *r, const char *name); |
9 | 171 |
|
172 |
/* |
|
173 |
* Open file for reading, and return a FileHandle. |
|
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
174 |
* This filename is in platform-independent notation. |
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
175 |
* If you can't handle multiple opens of the same file, |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
176 |
* you can opt to fail for the second call. |
20
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
177 |
* Fail if the file does not exist. |
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
178 |
* Returns NULL on failure, and calls __PHYSFS_setError(). |
9 | 179 |
*/ |
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
180 |
FileHandle *(*openRead)(DirHandle *r, const char *filename); |
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
181 |
|
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
182 |
/* |
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
183 |
* Open file for writing, and return a FileHandle. |
20
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
184 |
* If the file does not exist, it should be created. If it exists, |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
185 |
* it should be truncated to zero bytes. The writing |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
186 |
* offset should be the start of the file. |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
187 |
* This filename is in platform-independent notation. |
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
188 |
* This method may be NULL. |
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
189 |
* If you can't handle multiple opens of the same file, |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
190 |
* you can opt to fail for the second call. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
191 |
* Returns NULL on failure, and calls __PHYSFS_setError(). |
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
192 |
*/ |
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
193 |
FileHandle *(*openWrite)(DirHandle *r, const char *filename); |
9 | 194 |
|
195 |
/* |
|
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
196 |
* Open file for appending, and return a FileHandle. |
20
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
197 |
* If the file does not exist, it should be created. The writing |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
198 |
* offset should be the end of the file. |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
199 |
* This filename is in platform-independent notation. |
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
200 |
* This method may be NULL. |
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
201 |
* If you can't handle multiple opens of the same file, |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
202 |
* you can opt to fail for the second call. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
203 |
* Returns NULL on failure, and calls __PHYSFS_setError(). |
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
204 |
*/ |
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
205 |
FileHandle *(*openAppend)(DirHandle *r, const char *filename); |
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
206 |
|
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
207 |
/* |
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
208 |
* Delete a file in the archive/directory. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
209 |
* Return non-zero on success, zero on failure. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
210 |
* This filename is in platform-independent notation. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
211 |
* This method may be NULL. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
212 |
* On failure, call __PHYSFS_setError(). |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
213 |
*/ |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
214 |
int (*remove)(DirHandle *r, const char *filename); |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
215 |
|
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
216 |
/* |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
217 |
* Create a directory in the archive/directory. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
218 |
* If the application is trying to make multiple dirs, PhysicsFS |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
219 |
* will split them up into multiple calls before passing them to |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
220 |
* your driver. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
221 |
* Return non-zero on success, zero on failure. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
222 |
* This filename is in platform-independent notation. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
223 |
* This method may be NULL. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
224 |
* On failure, call __PHYSFS_setError(). |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
225 |
*/ |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
226 |
int (*mkdir)(DirHandle *r, const char *filename); |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
227 |
|
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
228 |
/* |
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
229 |
* Close directories/archives, and free the handle, including |
9 | 230 |
* the "opaque" entry. This should assume that it won't be called if |
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
231 |
* there are still files open from this DirHandle. |
9 | 232 |
*/ |
20
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
233 |
void (*dirClose)(DirHandle *r); |
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
234 |
} DirFunctions; |
9 | 235 |
|
236 |
||
237 |
/* error messages... */ |
|
238 |
#define ERR_IS_INITIALIZED "Already initialized" |
|
239 |
#define ERR_NOT_INITIALIZED "Not initialized" |
|
240 |
#define ERR_INVALID_ARGUMENT "Invalid argument" |
|
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
241 |
#define ERR_FILES_STILL_OPEN "Files still open" |
9 | 242 |
#define ERR_NO_DIR_CREATE "Failed to create directories" |
243 |
#define ERR_OUT_OF_MEMORY "Out of memory" |
|
244 |
#define ERR_NOT_IN_SEARCH_PATH "No such entry in search path" |
|
245 |
#define ERR_NOT_SUPPORTED "Operation not supported" |
|
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
246 |
#define ERR_UNSUPPORTED_ARCHIVE "Archive type unsupported" |
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
247 |
#define ERR_NOT_A_HANDLE "Not a file handle" |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
248 |
#define ERR_INSECURE_FNAME "Insecure filename" |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
249 |
#define ERR_SYMLINK_DISALLOWED "Symbolic links are disabled" |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
250 |
#define ERR_NO_WRITE_DIR "Write directory is not set" |
19
a0279b57398c
Base implementation is now complete. Now to fill in archive/platform drivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
15
diff
changeset
|
251 |
#define ERR_NO_SUCH_FILE "No such file" |
21
b1ea58d70a56
Archive implementation (Build Groupfiles), other tweaks.
Ryan C. Gordon <icculus@icculus.org>
parents:
20
diff
changeset
|
252 |
#define ERR_PAST_EOF "Past end of file" |
22
49f6101707b4
More tweaks; GRP completely implemented. Everything builds clean.
Ryan C. Gordon <icculus@icculus.org>
parents:
21
diff
changeset
|
253 |
#define ERR_ARC_IS_READ_ONLY "Archive is read-only" |
30
c9cc9b79112e
"I/O error" error string, and updated comment.
Ryan C. Gordon <icculus@icculus.org>
parents:
28
diff
changeset
|
254 |
#define ERR_IO_ERROR "I/O error" |
45 | 255 |
#define ERR_CANT_SET_WRITE_DIR "Can't set write directory" |
256 |
#define ERR_TOO_MANY_SYMLINKS "Too many symbolic links" |
|
49 | 257 |
#define ERR_COMPRESSION "(De)compression error" |
9 | 258 |
|
259 |
/* |
|
260 |
* Call this to set the message returned by PHYSFS_getLastError(). |
|
261 |
* Please only use the ERR_* constants above, or add new constants to the |
|
262 |
* above group, but I want these all in one place. |
|
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
263 |
* |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
264 |
* Calling this with a NULL argument is a safe no-op. |
9 | 265 |
*/ |
266 |
void __PHYSFS_setError(const char *err); |
|
267 |
||
268 |
||
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
269 |
/* |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
270 |
* Convert (dirName) to platform-dependent notation, then prepend (prepend) |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
271 |
* and append (append) to the converted string. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
272 |
* |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
273 |
* So, on Win32, calling: |
20
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
274 |
* __PHYSFS_convertToDependent("C:\", "my/files", NULL); |
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
275 |
* ...will return the string "C:\my\files". |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
276 |
* |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
277 |
* This is a convenience function; you might want to hack something out that |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
278 |
* is less generic (and therefore more efficient). |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
279 |
* |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
280 |
* Be sure to free() the return value when done with it. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
281 |
*/ |
20
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
282 |
char *__PHYSFS_convertToDependent(const char *prepend, |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
283 |
const char *dirName, |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
284 |
const char *append); |
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
285 |
|
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
286 |
/* |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
287 |
* Verify that (fname) (in platform-independent notation), in relation |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
288 |
* to (h) is secure. That means that each element of fname is checked |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
289 |
* for symlinks (if they aren't permitted). Also, elements such as |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
290 |
* ".", "..", or ":" are flagged. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
291 |
* |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
292 |
* Returns non-zero if string is safe, zero if there's a security issue. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
293 |
* PHYSFS_getLastError() will specify what was wrong. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
294 |
*/ |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
295 |
int __PHYSFS_verifySecurity(DirHandle *h, const char *fname); |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
296 |
|
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
297 |
|
69
546a95cc5591
Updates, corrections and enhancements to get this ported to win32.
Ryan C. Gordon <icculus@icculus.org>
parents:
49
diff
changeset
|
298 |
/* These get used all over for lessening code clutter. */ |
546a95cc5591
Updates, corrections and enhancements to get this ported to win32.
Ryan C. Gordon <icculus@icculus.org>
parents:
49
diff
changeset
|
299 |
#define BAIL_MACRO(e, r) { __PHYSFS_setError(e); return r; } |
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
300 |
#define BAIL_IF_MACRO(c, e, r) if (c) { __PHYSFS_setError(e); return r; } |
9 | 301 |
|
302 |
||
303 |
||
304 |
||
305 |
/*--------------------------------------------------------------------------*/ |
|
306 |
/*--------------------------------------------------------------------------*/ |
|
307 |
/*------------ ----------------*/ |
|
308 |
/*------------ You MUST implement the following functions ----------------*/ |
|
309 |
/*------------ if porting to a new platform. ----------------*/ |
|
30
c9cc9b79112e
"I/O error" error string, and updated comment.
Ryan C. Gordon <icculus@icculus.org>
parents:
28
diff
changeset
|
310 |
/*------------ (see platform/unix.c for an example) ----------------*/ |
9 | 311 |
/*------------ ----------------*/ |
312 |
/*--------------------------------------------------------------------------*/ |
|
313 |
/*--------------------------------------------------------------------------*/ |
|
314 |
||
315 |
||
316 |
/* |
|
317 |
* The dir separator; "/" on unix, "\\" on win32, ":" on MacOS, etc... |
|
318 |
* Obviously, this isn't a function, but it IS a null-terminated string. |
|
319 |
*/ |
|
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
320 |
extern const char *__PHYSFS_platformDirSeparator; |
9 | 321 |
|
322 |
/* |
|
323 |
* Platform implementation of PHYSFS_getCdRomDirs()... |
|
324 |
* See physfs.h. The retval should be freeable via PHYSFS_freeList(). |
|
325 |
*/ |
|
326 |
char **__PHYSFS_platformDetectAvailableCDs(void); |
|
327 |
||
328 |
/* |
|
329 |
* Calculate the base dir, if your platform needs special consideration. |
|
330 |
* Just return NULL if the standard routines will suffice. (see |
|
331 |
* calculateBaseDir() in physfs.c ...) |
|
332 |
* Caller will free() the retval if it's not NULL. |
|
333 |
*/ |
|
23
bd6ba9c8717c
Initial debugging: dropped PhysicsFS routines into the Build engine,
Ryan C. Gordon <icculus@icculus.org>
parents:
22
diff
changeset
|
334 |
char *__PHYSFS_platformCalcBaseDir(const char *argv0); |
9 | 335 |
|
336 |
/* |
|
337 |
* Get the platform-specific user name. |
|
338 |
* Caller will free() the retval if it's not NULL. If it's NULL, the username |
|
339 |
* will default to "default". |
|
340 |
*/ |
|
341 |
char *__PHYSFS_platformGetUserName(void); |
|
342 |
||
343 |
/* |
|
344 |
* Get the platform-specific user dir. |
|
345 |
* Caller will free() the retval if it's not NULL. If it's NULL, the userdir |
|
346 |
* will default to basedir/username. |
|
347 |
*/ |
|
348 |
char *__PHYSFS_platformGetUserDir(void); |
|
349 |
||
350 |
/* |
|
351 |
* Return a number that uniquely identifies the current thread. |
|
352 |
* On a platform without threading, (1) will suffice. These numbers are |
|
353 |
* arbitrary; the only requirement is that no two threads have the same |
|
354 |
* number. |
|
355 |
*/ |
|
356 |
int __PHYSFS_platformGetThreadID(void); |
|
357 |
||
358 |
/* |
|
359 |
* This is a pass-through to whatever stricmp() is called on your platform. |
|
360 |
*/ |
|
361 |
int __PHYSFS_platformStricmp(const char *str1, const char *str2); |
|
362 |
||
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
363 |
/* |
20
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
364 |
* Return non-zero if filename (in platform-dependent notation) exists. |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
365 |
* Symlinks should be followed; if what the symlink points to is missing, |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
366 |
* then the retval is false. |
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
367 |
*/ |
20
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
368 |
int __PHYSFS_platformExists(const char *fname); |
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
369 |
|
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
370 |
/* |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
371 |
* Return non-zero if filename (in platform-dependent notation) is a symlink. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
372 |
*/ |
20
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
373 |
int __PHYSFS_platformIsSymLink(const char *fname); |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
374 |
|
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
375 |
/* |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
376 |
* Return non-zero if filename (in platform-dependent notation) is a symlink. |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
377 |
* Symlinks should be followed; if what the symlink points to is missing, |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
378 |
* or isn't a directory, then the retval is false. |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
379 |
*/ |
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
380 |
int __PHYSFS_platformIsDirectory(const char *fname); |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
381 |
|
20
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
382 |
/* |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
383 |
* Convert (dirName) to platform-dependent notation, then prepend (prepend) |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
384 |
* and append (append) to the converted string. |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
385 |
* |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
386 |
* So, on Win32, calling: |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
387 |
* __PHYSFS_platformCvtToDependent("C:\", "my/files", NULL); |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
388 |
* ...will return the string "C:\my\files". |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
389 |
* |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
390 |
* This can be implemented in a platform-specific manner, so you can get |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
391 |
* get a speed boost that the default implementation can't, since |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
392 |
* you can make assumptions about the size of strings, etc.. |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
393 |
* |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
394 |
* Platforms that choose not to implement this may just call |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
395 |
* __PHYSFS_convertToDependent() as a passthrough. |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
396 |
* |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
397 |
* Be sure to free() the return value when done with it. |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
398 |
*/ |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
399 |
char *__PHYSFS_platformCvtToDependent(const char *prepend, |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
400 |
const char *dirName, |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
401 |
const char *append); |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
402 |
|
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
403 |
/* |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
404 |
* Make the current thread give up a timeslice. This is called in a loop |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
405 |
* while waiting for various external forces to get back to us. |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
406 |
*/ |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
407 |
void __PHYSFS_platformTimeslice(void); |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
408 |
|
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
409 |
|
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
410 |
/* |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
411 |
* Enumerate a directory of files. This follows the rules for the |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
412 |
* DirFunctions->enumerateFiles() method (see above), except that the |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
413 |
* (dirName) that is passed to this function is converted to |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
414 |
* platform-DEPENDENT notation by the caller. The DirFunctions version |
41
ff60d39d0862
Architecture adjustment for enumerating files with regards to whether
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
415 |
* uses platform-independent notation. Note that ".", "..", and other |
ff60d39d0862
Architecture adjustment for enumerating files with regards to whether
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
416 |
* metaentries should always be ignored. |
20
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
417 |
*/ |
41
ff60d39d0862
Architecture adjustment for enumerating files with regards to whether
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
418 |
LinkedStringList *__PHYSFS_platformEnumerateFiles(const char *dirname, |
ff60d39d0862
Architecture adjustment for enumerating files with regards to whether
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
419 |
int omitSymLinks); |
20
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
420 |
|
9 | 421 |
|
28
529214f57d1b
Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents:
23
diff
changeset
|
422 |
/* |
529214f57d1b
Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents:
23
diff
changeset
|
423 |
* Determine the current size of a file, in bytes, from a stdio FILE *. |
529214f57d1b
Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents:
23
diff
changeset
|
424 |
* Return -1 if you can't do it, and call __PHYSFS_setError(). |
529214f57d1b
Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents:
23
diff
changeset
|
425 |
*/ |
529214f57d1b
Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents:
23
diff
changeset
|
426 |
int __PHYSFS_platformFileLength(FILE *handle); |
529214f57d1b
Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents:
23
diff
changeset
|
427 |
|
529214f57d1b
Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents:
23
diff
changeset
|
428 |
|
39
bc29e1ee7ef6
Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
429 |
/* |
bc29e1ee7ef6
Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
430 |
* Get the current working directory. The return value should be an |
bc29e1ee7ef6
Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
431 |
* absolute path in platform-dependent notation. The caller will deallocate |
bc29e1ee7ef6
Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
432 |
* the return value with the standard C runtime free() function when it |
bc29e1ee7ef6
Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
433 |
* is done with it. |
bc29e1ee7ef6
Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
434 |
* On error, return NULL and set the error message. |
bc29e1ee7ef6
Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
435 |
*/ |
bc29e1ee7ef6
Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
436 |
char *__PHYSFS_platformCurrentDir(void); |
bc29e1ee7ef6
Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
437 |
|
bc29e1ee7ef6
Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
438 |
|
bc29e1ee7ef6
Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
439 |
/* |
bc29e1ee7ef6
Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
440 |
* Get the real physical path to a file. (path) is specified in |
bc29e1ee7ef6
Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
441 |
* platform-dependent notation, as should your return value be. |
bc29e1ee7ef6
Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
442 |
* All relative paths should be removed, leaving you with an absolute |
bc29e1ee7ef6
Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
443 |
* path. Symlinks should be resolved, too, so that the returned value is |
bc29e1ee7ef6
Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
444 |
* the most direct path to a file. |
bc29e1ee7ef6
Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
445 |
* The return value will be deallocated with the standard C runtime free() |
bc29e1ee7ef6
Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
446 |
* function when the caller is done with it. |
bc29e1ee7ef6
Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
447 |
* On error, return NULL and set the error message. |
bc29e1ee7ef6
Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
448 |
*/ |
bc29e1ee7ef6
Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
449 |
char *__PHYSFS_platformRealPath(const char *path); |
bc29e1ee7ef6
Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
450 |
|
bc29e1ee7ef6
Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
451 |
|
69
546a95cc5591
Updates, corrections and enhancements to get this ported to win32.
Ryan C. Gordon <icculus@icculus.org>
parents:
49
diff
changeset
|
452 |
/* |
546a95cc5591
Updates, corrections and enhancements to get this ported to win32.
Ryan C. Gordon <icculus@icculus.org>
parents:
49
diff
changeset
|
453 |
* Make a directory in the actual filesystem. (path) is specified in |
546a95cc5591
Updates, corrections and enhancements to get this ported to win32.
Ryan C. Gordon <icculus@icculus.org>
parents:
49
diff
changeset
|
454 |
* platform-dependent notation. On error, return zero and set the error |
546a95cc5591
Updates, corrections and enhancements to get this ported to win32.
Ryan C. Gordon <icculus@icculus.org>
parents:
49
diff
changeset
|
455 |
* message. Return non-zero on success. |
546a95cc5591
Updates, corrections and enhancements to get this ported to win32.
Ryan C. Gordon <icculus@icculus.org>
parents:
49
diff
changeset
|
456 |
*/ |
546a95cc5591
Updates, corrections and enhancements to get this ported to win32.
Ryan C. Gordon <icculus@icculus.org>
parents:
49
diff
changeset
|
457 |
int __PHYSFS_platformMkDir(const char *path); |
546a95cc5591
Updates, corrections and enhancements to get this ported to win32.
Ryan C. Gordon <icculus@icculus.org>
parents:
49
diff
changeset
|
458 |
|
546a95cc5591
Updates, corrections and enhancements to get this ported to win32.
Ryan C. Gordon <icculus@icculus.org>
parents:
49
diff
changeset
|
459 |
|
9 | 460 |
#ifdef __cplusplus |
461 |
extern "C" { |
|
462 |
#endif |
|
463 |
||
464 |
#endif |
|
465 |
||
466 |
/* end of physfs_internal.h ... */ |
|
467 |