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