author | Ryan C. Gordon <icculus@icculus.org> |
Sun, 18 Sep 2005 21:44:42 +0000 | |
changeset 754 | e7cd7411eadf |
parent 747 | 3da194b12f43 |
child 763 | efadd9cdb6a4 |
permissions | -rw-r--r-- |
152 | 1 |
/* |
2 |
* Skeleton platform-dependent support routines for PhysicsFS. |
|
3 |
* |
|
4 |
* Please see the file LICENSE in the source's root directory. |
|
5 |
* |
|
6 |
* This file written by Ryan C. Gordon. |
|
7 |
*/ |
|
8 |
||
214
19846c18071b
Initial autoconf support.
Ryan C. Gordon <icculus@icculus.org>
parents:
156
diff
changeset
|
9 |
#if HAVE_CONFIG_H |
19846c18071b
Initial autoconf support.
Ryan C. Gordon <icculus@icculus.org>
parents:
156
diff
changeset
|
10 |
# include <config.h> |
19846c18071b
Initial autoconf support.
Ryan C. Gordon <icculus@icculus.org>
parents:
156
diff
changeset
|
11 |
#endif |
19846c18071b
Initial autoconf support.
Ryan C. Gordon <icculus@icculus.org>
parents:
156
diff
changeset
|
12 |
|
152 | 13 |
#define __PHYSICSFS_INTERNAL__ |
14 |
#include "physfs_internal.h" |
|
15 |
||
16 |
||
17 |
#error DO NOT COMPILE THIS. IT IS JUST A SKELETON EXAMPLE FILE. |
|
18 |
||
19 |
||
20 |
const char *__PHYSFS_platformDirSeparator = ":"; |
|
21 |
||
22 |
||
23 |
int __PHYSFS_platformInit(void) |
|
24 |
{ |
|
25 |
return(1); /* always succeed. */ |
|
26 |
} /* __PHYSFS_platformInit */ |
|
27 |
||
28 |
||
29 |
int __PHYSFS_platformDeinit(void) |
|
30 |
{ |
|
31 |
return(1); /* always succeed. */ |
|
32 |
} /* __PHYSFS_platformDeinit */ |
|
33 |
||
34 |
||
657
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
596
diff
changeset
|
35 |
void __PHYSFS_platformDetectAvailableCDs(PHYSFS_StringCallback cb, void *data) |
152 | 36 |
{ |
37 |
} /* __PHYSFS_platformDetectAvailableCDs */ |
|
38 |
||
39 |
||
40 |
char *__PHYSFS_platformCalcBaseDir(const char *argv0) |
|
41 |
{ |
|
42 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, NULL); |
|
43 |
} /* __PHYSFS_platformCalcBaseDir */ |
|
44 |
||
45 |
||
46 |
char *__PHYSFS_platformGetUserName(void) |
|
47 |
{ |
|
48 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, NULL); |
|
49 |
} /* __PHYSFS_platformGetUserName */ |
|
50 |
||
51 |
||
52 |
char *__PHYSFS_platformGetUserDir(void) |
|
53 |
{ |
|
54 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, NULL); |
|
55 |
} /* __PHYSFS_platformGetUserDir */ |
|
56 |
||
57 |
||
58 |
PHYSFS_uint64 __PHYSFS_platformGetThreadID(void) |
|
59 |
{ |
|
60 |
return(1); /* single threaded. */ |
|
61 |
} /* __PHYSFS_platformGetThreadID */ |
|
62 |
||
63 |
||
64 |
int __PHYSFS_platformStricmp(const char *x, const char *y) |
|
65 |
{ |
|
66 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, 0); |
|
67 |
} /* __PHYSFS_platformStricmp */ |
|
68 |
||
69 |
||
596
381b6ca0dd85
Added internal function __PHYSFS_platformStrnicmp().
Ryan C. Gordon <icculus@icculus.org>
parents:
240
diff
changeset
|
70 |
int __PHYSFS_platformStrnicmp(const char *x, const char *y, PHYSFS_uint32 l) |
381b6ca0dd85
Added internal function __PHYSFS_platformStrnicmp().
Ryan C. Gordon <icculus@icculus.org>
parents:
240
diff
changeset
|
71 |
{ |
381b6ca0dd85
Added internal function __PHYSFS_platformStrnicmp().
Ryan C. Gordon <icculus@icculus.org>
parents:
240
diff
changeset
|
72 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, 0); |
381b6ca0dd85
Added internal function __PHYSFS_platformStrnicmp().
Ryan C. Gordon <icculus@icculus.org>
parents:
240
diff
changeset
|
73 |
} /* __PHYSFS_platformStrnicmp */ |
381b6ca0dd85
Added internal function __PHYSFS_platformStrnicmp().
Ryan C. Gordon <icculus@icculus.org>
parents:
240
diff
changeset
|
74 |
|
381b6ca0dd85
Added internal function __PHYSFS_platformStrnicmp().
Ryan C. Gordon <icculus@icculus.org>
parents:
240
diff
changeset
|
75 |
|
152 | 76 |
int __PHYSFS_platformExists(const char *fname) |
77 |
{ |
|
78 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, 0); |
|
79 |
} /* __PHYSFS_platformExists */ |
|
80 |
||
81 |
||
82 |
int __PHYSFS_platformIsSymLink(const char *fname) |
|
83 |
{ |
|
84 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, 0); |
|
85 |
} /* __PHYSFS_platformIsSymlink */ |
|
86 |
||
87 |
||
88 |
int __PHYSFS_platformIsDirectory(const char *fname) |
|
89 |
{ |
|
90 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, 0); |
|
91 |
} /* __PHYSFS_platformIsDirectory */ |
|
92 |
||
93 |
||
94 |
char *__PHYSFS_platformCvtToDependent(const char *prepend, |
|
95 |
const char *dirName, |
|
96 |
const char *append) |
|
97 |
{ |
|
98 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, NULL); |
|
99 |
} /* __PHYSFS_platformCvtToDependent */ |
|
100 |
||
101 |
||
102 |
void __PHYSFS_platformTimeslice(void) |
|
103 |
{ |
|
104 |
} /* __PHYSFS_platformTimeslice */ |
|
105 |
||
106 |
||
657
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
596
diff
changeset
|
107 |
void __PHYSFS_platformEnumerateFiles(const char *dirname, |
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
596
diff
changeset
|
108 |
int omitSymLinks, |
754
e7cd7411eadf
API BREAKAGE: Changed PHYSFS_enumerateFilesCallback() to pass the originally
Ryan C. Gordon <icculus@icculus.org>
parents:
747
diff
changeset
|
109 |
PHYSFS_EnumFilesCallback callback, |
e7cd7411eadf
API BREAKAGE: Changed PHYSFS_enumerateFilesCallback() to pass the originally
Ryan C. Gordon <icculus@icculus.org>
parents:
747
diff
changeset
|
110 |
const char *origdir, |
657
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
596
diff
changeset
|
111 |
void *callbackdata) |
152 | 112 |
{ |
113 |
} /* __PHYSFS_platformEnumerateFiles */ |
|
114 |
||
115 |
||
116 |
char *__PHYSFS_platformCurrentDir(void) |
|
117 |
{ |
|
118 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, NULL); |
|
119 |
} /* __PHYSFS_platformCurrentDir */ |
|
120 |
||
121 |
||
122 |
char *__PHYSFS_platformRealPath(const char *path) |
|
123 |
{ |
|
124 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, NULL); |
|
125 |
} /* __PHYSFS_platformRealPath */ |
|
126 |
||
127 |
||
128 |
int __PHYSFS_platformMkDir(const char *path) |
|
129 |
{ |
|
130 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, 0); |
|
131 |
} /* __PHYSFS_platformMkDir */ |
|
132 |
||
133 |
||
134 |
void *__PHYSFS_platformOpenRead(const char *filename) |
|
135 |
{ |
|
136 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, NULL); |
|
137 |
} /* __PHYSFS_platformOpenRead */ |
|
138 |
||
139 |
||
140 |
void *__PHYSFS_platformOpenWrite(const char *filename) |
|
141 |
{ |
|
142 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, NULL); |
|
143 |
} /* __PHYSFS_platformOpenWrite */ |
|
144 |
||
145 |
||
146 |
void *__PHYSFS_platformOpenAppend(const char *filename) |
|
147 |
{ |
|
148 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, NULL); |
|
149 |
} /* __PHYSFS_platformOpenAppend */ |
|
150 |
||
151 |
||
152 |
PHYSFS_sint64 __PHYSFS_platformRead(void *opaque, void *buffer, |
|
153 |
PHYSFS_uint32 size, PHYSFS_uint32 count) |
|
154 |
{ |
|
155 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, -1); |
|
156 |
} /* __PHYSFS_platformRead */ |
|
157 |
||
158 |
||
159 |
PHYSFS_sint64 __PHYSFS_platformWrite(void *opaque, const void *buffer, |
|
160 |
PHYSFS_uint32 size, PHYSFS_uint32 count) |
|
161 |
{ |
|
162 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, -1); |
|
163 |
} /* __PHYSFS_platformWrite */ |
|
164 |
||
165 |
||
166 |
int __PHYSFS_platformSeek(void *opaque, PHYSFS_uint64 pos) |
|
167 |
{ |
|
168 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, -1); |
|
169 |
} /* __PHYSFS_platformSeek */ |
|
170 |
||
171 |
||
172 |
PHYSFS_sint64 __PHYSFS_platformTell(void *opaque) |
|
173 |
{ |
|
174 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, -1); |
|
175 |
} /* __PHYSFS_platformTell */ |
|
176 |
||
177 |
||
178 |
PHYSFS_sint64 __PHYSFS_platformFileLength(void *opaque) |
|
179 |
{ |
|
180 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, -1); |
|
181 |
} /* __PHYSFS_platformFileLength */ |
|
182 |
||
183 |
||
184 |
int __PHYSFS_platformEOF(void *opaque) |
|
185 |
{ |
|
186 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, -1); |
|
187 |
} /* __PHYSFS_platformEOF */ |
|
188 |
||
189 |
||
190 |
int __PHYSFS_platformFlush(void *opaque) |
|
191 |
{ |
|
192 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, 0); |
|
193 |
} /* __PHYSFS_platformFlush */ |
|
194 |
||
195 |
||
196 |
int __PHYSFS_platformClose(void *opaque) |
|
197 |
{ |
|
198 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, 0); |
|
199 |
} /* __PHYSFS_platformClose */ |
|
200 |
||
201 |
||
202 |
int __PHYSFS_platformDelete(const char *path) |
|
203 |
{ |
|
204 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, 0); |
|
205 |
} /* __PHYSFS_platformDelete */ |
|
206 |
||
207 |
||
208 |
void *__PHYSFS_platformCreateMutex(void) |
|
209 |
{ |
|
210 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, NULL); |
|
211 |
} /* __PHYSFS_platformCreateMutex */ |
|
212 |
||
213 |
||
214 |
void __PHYSFS_platformDestroyMutex(void *mutex) |
|
215 |
{ |
|
216 |
} /* __PHYSFS_platformDestroyMutex */ |
|
217 |
||
218 |
||
219 |
int __PHYSFS_platformGrabMutex(void *mutex) |
|
220 |
{ |
|
156
f45e26b5f398
Added warning about potential infinite recursion between setError and grabMutex.
Ryan C. Gordon <icculus@icculus.org>
parents:
152
diff
changeset
|
221 |
/* not implemented, but can't call __PHYSFS_setError! */ |
f45e26b5f398
Added warning about potential infinite recursion between setError and grabMutex.
Ryan C. Gordon <icculus@icculus.org>
parents:
152
diff
changeset
|
222 |
return(0); |
152 | 223 |
} /* __PHYSFS_platformGrabMutex */ |
224 |
||
225 |
||
226 |
void __PHYSFS_platformReleaseMutex(void *mutex) |
|
227 |
{ |
|
156
f45e26b5f398
Added warning about potential infinite recursion between setError and grabMutex.
Ryan C. Gordon <icculus@icculus.org>
parents:
152
diff
changeset
|
228 |
/* not implemented, but can't call __PHYSFS_setError! */ |
152 | 229 |
} /* __PHYSFS_platformReleaseMutex */ |
230 |
||
240
052041af9001
Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
231 |
|
052041af9001
Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
232 |
PHYSFS_sint64 __PHYSFS_platformGetLastModTime(const char *fname) |
052041af9001
Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
233 |
{ |
052041af9001
Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
234 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, -1); |
052041af9001
Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
235 |
} /* __PHYSFS_platformGetLastModTime */ |
052041af9001
Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
236 |
|
691
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
237 |
|
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
238 |
int __PHYSFS_platformAllocatorInit(void) |
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
239 |
{ |
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
240 |
return(1); /* always succeeds. */ |
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
241 |
} /* __PHYSFS_platformAllocatorInit */ |
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
242 |
|
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
243 |
|
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
244 |
void __PHYSFS_platformAllocatorDeinit(void) |
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
245 |
{ |
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
246 |
/* no-op */ |
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
247 |
} /* __PHYSFS_platformAllocatorInit */ |
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
248 |
|
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
249 |
|
747
3da194b12f43
Don't use size_t in physfs.h, since it relies on C runtime headers.
Ryan C. Gordon <icculus@icculus.org>
parents:
691
diff
changeset
|
250 |
void *__PHYSFS_platformAllocatorMalloc(PHYSFS_uint64 s) |
691
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
251 |
{ |
747
3da194b12f43
Don't use size_t in physfs.h, since it relies on C runtime headers.
Ryan C. Gordon <icculus@icculus.org>
parents:
691
diff
changeset
|
252 |
/* make sure s isn't larger than the address space of the platform... */ |
3da194b12f43
Don't use size_t in physfs.h, since it relies on C runtime headers.
Ryan C. Gordon <icculus@icculus.org>
parents:
691
diff
changeset
|
253 |
if ( s > (0xFFFFFFFFFFFFFFFF >> (64-(sizeof (size_t) * 8))) ) |
3da194b12f43
Don't use size_t in physfs.h, since it relies on C runtime headers.
Ryan C. Gordon <icculus@icculus.org>
parents:
691
diff
changeset
|
254 |
BAIL_MACRO(ERR_OUT_OF_MEMORY, NULL); |
691
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
255 |
#undef malloc |
747
3da194b12f43
Don't use size_t in physfs.h, since it relies on C runtime headers.
Ryan C. Gordon <icculus@icculus.org>
parents:
691
diff
changeset
|
256 |
return(malloc((size_t) s)); |
691
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
257 |
} /* __PHYSFS_platformMalloc */ |
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
258 |
|
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
259 |
|
747
3da194b12f43
Don't use size_t in physfs.h, since it relies on C runtime headers.
Ryan C. Gordon <icculus@icculus.org>
parents:
691
diff
changeset
|
260 |
void *__PHYSFS_platformAllocatorRealloc(void *ptr, PHYSFS_uint64 s) |
691
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
261 |
{ |
747
3da194b12f43
Don't use size_t in physfs.h, since it relies on C runtime headers.
Ryan C. Gordon <icculus@icculus.org>
parents:
691
diff
changeset
|
262 |
/* make sure s isn't larger than the address space of the platform... */ |
3da194b12f43
Don't use size_t in physfs.h, since it relies on C runtime headers.
Ryan C. Gordon <icculus@icculus.org>
parents:
691
diff
changeset
|
263 |
if ( s > (0xFFFFFFFFFFFFFFFF >> (64-(sizeof (size_t) * 8))) ) |
3da194b12f43
Don't use size_t in physfs.h, since it relies on C runtime headers.
Ryan C. Gordon <icculus@icculus.org>
parents:
691
diff
changeset
|
264 |
BAIL_MACRO(ERR_OUT_OF_MEMORY, NULL); |
691
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
265 |
#undef realloc |
747
3da194b12f43
Don't use size_t in physfs.h, since it relies on C runtime headers.
Ryan C. Gordon <icculus@icculus.org>
parents:
691
diff
changeset
|
266 |
return(realloc(ptr, (size_t) s)); |
691
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
267 |
} /* __PHYSFS_platformRealloc */ |
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
268 |
|
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
269 |
|
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
270 |
void __PHYSFS_platformAllocatorFree(void *ptr) |
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
271 |
{ |
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
272 |
#undef free |
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
273 |
free(ptr); |
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
274 |
} /* __PHYSFS_platformAllocatorFree */ |
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
275 |
|
152 | 276 |
/* end of skeleton.c ... */ |
277 |