author | Ryan C. Gordon <icculus@icculus.org> |
Thu, 15 Mar 2007 08:16:23 +0000 | |
changeset 828 | ee871d51510d |
parent 818 | e36f23f49042 |
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_platformExists(const char *fname) |
|
63 |
{ |
|
64 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, 0); |
|
65 |
} /* __PHYSFS_platformExists */ |
|
66 |
||
67 |
||
68 |
int __PHYSFS_platformIsSymLink(const char *fname) |
|
69 |
{ |
|
70 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, 0); |
|
71 |
} /* __PHYSFS_platformIsSymlink */ |
|
72 |
||
73 |
||
74 |
int __PHYSFS_platformIsDirectory(const char *fname) |
|
75 |
{ |
|
76 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, 0); |
|
77 |
} /* __PHYSFS_platformIsDirectory */ |
|
78 |
||
79 |
||
80 |
char *__PHYSFS_platformCvtToDependent(const char *prepend, |
|
81 |
const char *dirName, |
|
82 |
const char *append) |
|
83 |
{ |
|
84 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, NULL); |
|
85 |
} /* __PHYSFS_platformCvtToDependent */ |
|
86 |
||
87 |
||
88 |
void __PHYSFS_platformTimeslice(void) |
|
89 |
{ |
|
90 |
} /* __PHYSFS_platformTimeslice */ |
|
91 |
||
92 |
||
657
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
596
diff
changeset
|
93 |
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
|
94 |
int omitSymLinks, |
754
e7cd7411eadf
API BREAKAGE: Changed PHYSFS_enumerateFilesCallback() to pass the originally
Ryan C. Gordon <icculus@icculus.org>
parents:
747
diff
changeset
|
95 |
PHYSFS_EnumFilesCallback callback, |
e7cd7411eadf
API BREAKAGE: Changed PHYSFS_enumerateFilesCallback() to pass the originally
Ryan C. Gordon <icculus@icculus.org>
parents:
747
diff
changeset
|
96 |
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
|
97 |
void *callbackdata) |
152 | 98 |
{ |
99 |
} /* __PHYSFS_platformEnumerateFiles */ |
|
100 |
||
101 |
||
102 |
char *__PHYSFS_platformCurrentDir(void) |
|
103 |
{ |
|
104 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, NULL); |
|
105 |
} /* __PHYSFS_platformCurrentDir */ |
|
106 |
||
107 |
||
108 |
char *__PHYSFS_platformRealPath(const char *path) |
|
109 |
{ |
|
110 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, NULL); |
|
111 |
} /* __PHYSFS_platformRealPath */ |
|
112 |
||
113 |
||
114 |
int __PHYSFS_platformMkDir(const char *path) |
|
115 |
{ |
|
116 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, 0); |
|
117 |
} /* __PHYSFS_platformMkDir */ |
|
118 |
||
119 |
||
120 |
void *__PHYSFS_platformOpenRead(const char *filename) |
|
121 |
{ |
|
122 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, NULL); |
|
123 |
} /* __PHYSFS_platformOpenRead */ |
|
124 |
||
125 |
||
126 |
void *__PHYSFS_platformOpenWrite(const char *filename) |
|
127 |
{ |
|
128 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, NULL); |
|
129 |
} /* __PHYSFS_platformOpenWrite */ |
|
130 |
||
131 |
||
132 |
void *__PHYSFS_platformOpenAppend(const char *filename) |
|
133 |
{ |
|
134 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, NULL); |
|
135 |
} /* __PHYSFS_platformOpenAppend */ |
|
136 |
||
137 |
||
138 |
PHYSFS_sint64 __PHYSFS_platformRead(void *opaque, void *buffer, |
|
139 |
PHYSFS_uint32 size, PHYSFS_uint32 count) |
|
140 |
{ |
|
141 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, -1); |
|
142 |
} /* __PHYSFS_platformRead */ |
|
143 |
||
144 |
||
145 |
PHYSFS_sint64 __PHYSFS_platformWrite(void *opaque, const void *buffer, |
|
146 |
PHYSFS_uint32 size, PHYSFS_uint32 count) |
|
147 |
{ |
|
148 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, -1); |
|
149 |
} /* __PHYSFS_platformWrite */ |
|
150 |
||
151 |
||
152 |
int __PHYSFS_platformSeek(void *opaque, PHYSFS_uint64 pos) |
|
153 |
{ |
|
154 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, -1); |
|
155 |
} /* __PHYSFS_platformSeek */ |
|
156 |
||
157 |
||
158 |
PHYSFS_sint64 __PHYSFS_platformTell(void *opaque) |
|
159 |
{ |
|
160 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, -1); |
|
161 |
} /* __PHYSFS_platformTell */ |
|
162 |
||
163 |
||
164 |
PHYSFS_sint64 __PHYSFS_platformFileLength(void *opaque) |
|
165 |
{ |
|
166 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, -1); |
|
167 |
} /* __PHYSFS_platformFileLength */ |
|
168 |
||
169 |
||
170 |
int __PHYSFS_platformEOF(void *opaque) |
|
171 |
{ |
|
172 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, -1); |
|
173 |
} /* __PHYSFS_platformEOF */ |
|
174 |
||
175 |
||
176 |
int __PHYSFS_platformFlush(void *opaque) |
|
177 |
{ |
|
178 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, 0); |
|
179 |
} /* __PHYSFS_platformFlush */ |
|
180 |
||
181 |
||
182 |
int __PHYSFS_platformClose(void *opaque) |
|
183 |
{ |
|
184 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, 0); |
|
185 |
} /* __PHYSFS_platformClose */ |
|
186 |
||
187 |
||
188 |
int __PHYSFS_platformDelete(const char *path) |
|
189 |
{ |
|
190 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, 0); |
|
191 |
} /* __PHYSFS_platformDelete */ |
|
192 |
||
193 |
||
194 |
void *__PHYSFS_platformCreateMutex(void) |
|
195 |
{ |
|
196 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, NULL); |
|
197 |
} /* __PHYSFS_platformCreateMutex */ |
|
198 |
||
199 |
||
200 |
void __PHYSFS_platformDestroyMutex(void *mutex) |
|
201 |
{ |
|
202 |
} /* __PHYSFS_platformDestroyMutex */ |
|
203 |
||
204 |
||
205 |
int __PHYSFS_platformGrabMutex(void *mutex) |
|
206 |
{ |
|
156
f45e26b5f398
Added warning about potential infinite recursion between setError and grabMutex.
Ryan C. Gordon <icculus@icculus.org>
parents:
152
diff
changeset
|
207 |
/* 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
|
208 |
return(0); |
152 | 209 |
} /* __PHYSFS_platformGrabMutex */ |
210 |
||
211 |
||
212 |
void __PHYSFS_platformReleaseMutex(void *mutex) |
|
213 |
{ |
|
156
f45e26b5f398
Added warning about potential infinite recursion between setError and grabMutex.
Ryan C. Gordon <icculus@icculus.org>
parents:
152
diff
changeset
|
214 |
/* not implemented, but can't call __PHYSFS_setError! */ |
152 | 215 |
} /* __PHYSFS_platformReleaseMutex */ |
216 |
||
240
052041af9001
Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
217 |
|
052041af9001
Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
218 |
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
|
219 |
{ |
052041af9001
Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
220 |
BAIL_MACRO(ERR_NOT_IMPLEMENTED, -1); |
052041af9001
Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
221 |
} /* __PHYSFS_platformGetLastModTime */ |
052041af9001
Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
222 |
|
691
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
223 |
|
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
224 |
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
|
225 |
{ |
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
226 |
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
|
227 |
} /* __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
|
228 |
|
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
229 |
|
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
230 |
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
|
231 |
{ |
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
232 |
/* 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
|
233 |
} /* __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
|
234 |
|
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
235 |
|
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
|
236 |
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
|
237 |
{ |
763
efadd9cdb6a4
Cleaned up overflow checks in platform memory allocators (thanks to Nicolas
Ryan C. Gordon <icculus@icculus.org>
parents:
754
diff
changeset
|
238 |
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
|
239 |
#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
|
240 |
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
|
241 |
} /* __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
|
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 |
|
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
|
244 |
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
|
245 |
{ |
763
efadd9cdb6a4
Cleaned up overflow checks in platform memory allocators (thanks to Nicolas
Ryan C. Gordon <icculus@icculus.org>
parents:
754
diff
changeset
|
246 |
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
|
247 |
#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
|
248 |
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
|
249 |
} /* __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
|
250 |
|
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
251 |
|
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
252 |
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
|
253 |
{ |
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
254 |
#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
|
255 |
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
|
256 |
} /* __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
|
257 |
|
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
|
258 |
#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
|
259 |
|
e36f23f49042
Now compiles everything whether we need it or not, removing whole files with
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
260 |
|
152 | 261 |
/* end of skeleton.c ... */ |
262 |