author | Ryan C. Gordon <icculus@icculus.org> |
Fri, 23 Mar 2012 00:52:32 -0400 | |
changeset 1258 | 074d08049aa7 |
parent 1255 | f15ec4962d08 |
child 1259 | b01150541cfd |
permissions | -rw-r--r-- |
9 | 1 |
/* |
2 |
* Internal function/structure declaration. Do NOT include in your |
|
3 |
* application. |
|
4 |
* |
|
809
116b8fe30371
Renamed LICENSE to LICENSE.txt
Ryan C. Gordon <icculus@icculus.org>
parents:
775
diff
changeset
|
5 |
* Please see the file LICENSE.txt in the source's root directory. |
9 | 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 |
||
132
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
17 |
#include "physfs.h" |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
18 |
|
1129
d81afe4b0a97
Cleaned up some #includes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1128
diff
changeset
|
19 |
/* The holy trinity. */ |
d81afe4b0a97
Cleaned up some #includes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1128
diff
changeset
|
20 |
#include <stdio.h> |
d81afe4b0a97
Cleaned up some #includes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1128
diff
changeset
|
21 |
#include <stdlib.h> |
d81afe4b0a97
Cleaned up some #includes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1128
diff
changeset
|
22 |
#include <string.h> |
828
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
23 |
|
1229
a6b73703c4f9
Use physfs_platforms.h in physfs_internal.h, to avoid repeated macro tests.
Ryan C. Gordon <icculus@icculus.org>
parents:
1228
diff
changeset
|
24 |
#include "physfs_platforms.h" |
a6b73703c4f9
Use physfs_platforms.h in physfs_internal.h, to avoid repeated macro tests.
Ryan C. Gordon <icculus@icculus.org>
parents:
1228
diff
changeset
|
25 |
|
504
3420d82f9b01
Some cleanups for PocketPC port.
Ryan C. Gordon <icculus@icculus.org>
parents:
467
diff
changeset
|
26 |
#include <assert.h> |
3420d82f9b01
Some cleanups for PocketPC port.
Ryan C. Gordon <icculus@icculus.org>
parents:
467
diff
changeset
|
27 |
|
836
6514fba91816
Patched to compile with latest Platform SDK.
Ryan C. Gordon <icculus@icculus.org>
parents:
828
diff
changeset
|
28 |
/* !!! FIXME: remove this when revamping stack allocation code... */ |
905
8006327f5797
Whoops, it's malloc.h, not alloca.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
903
diff
changeset
|
29 |
#if defined(_MSC_VER) || defined(__MINGW32__) |
836
6514fba91816
Patched to compile with latest Platform SDK.
Ryan C. Gordon <icculus@icculus.org>
parents:
828
diff
changeset
|
30 |
#include <malloc.h> |
6514fba91816
Patched to compile with latest Platform SDK.
Ryan C. Gordon <icculus@icculus.org>
parents:
828
diff
changeset
|
31 |
#endif |
6514fba91816
Patched to compile with latest Platform SDK.
Ryan C. Gordon <icculus@icculus.org>
parents:
828
diff
changeset
|
32 |
|
1234
86e94cbbffca
Use our platform test macro for Solaris.
Ryan C. Gordon <icculus@icculus.org>
parents:
1232
diff
changeset
|
33 |
#if PHYSFS_PLATFORM_SOLARIS |
1089
5491e6c69162
Patched to compile on Solaris.
Ryan C. Gordon <icculus@icculus.org>
parents:
1054
diff
changeset
|
34 |
#include <alloca.h> |
5491e6c69162
Patched to compile on Solaris.
Ryan C. Gordon <icculus@icculus.org>
parents:
1054
diff
changeset
|
35 |
#endif |
5491e6c69162
Patched to compile on Solaris.
Ryan C. Gordon <icculus@icculus.org>
parents:
1054
diff
changeset
|
36 |
|
132
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
37 |
#ifdef __cplusplus |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
38 |
extern "C" { |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
39 |
#endif |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
40 |
|
936
3b4b6c107a59
Fixed aliasing bug in Windows platform layer (thanks, Dennis!).
Ryan C. Gordon <icculus@icculus.org>
parents:
933
diff
changeset
|
41 |
#ifdef __GNUC__ |
938
ecbae90ae88d
Yet another attempt to patch to compile.
Ryan C. Gordon <icculus@icculus.org>
parents:
936
diff
changeset
|
42 |
#define PHYSFS_MINIMUM_GCC_VERSION(major, minor) \ |
936
3b4b6c107a59
Fixed aliasing bug in Windows platform layer (thanks, Dennis!).
Ryan C. Gordon <icculus@icculus.org>
parents:
933
diff
changeset
|
43 |
( ((__GNUC__ << 16) + __GNUC_MINOR__) >= (((major) << 16) + (minor)) ) |
3b4b6c107a59
Fixed aliasing bug in Windows platform layer (thanks, Dennis!).
Ryan C. Gordon <icculus@icculus.org>
parents:
933
diff
changeset
|
44 |
#else |
938
ecbae90ae88d
Yet another attempt to patch to compile.
Ryan C. Gordon <icculus@icculus.org>
parents:
936
diff
changeset
|
45 |
#define PHYSFS_MINIMUM_GCC_VERSION(major, minor) (0) |
936
3b4b6c107a59
Fixed aliasing bug in Windows platform layer (thanks, Dennis!).
Ryan C. Gordon <icculus@icculus.org>
parents:
933
diff
changeset
|
46 |
#endif |
3b4b6c107a59
Fixed aliasing bug in Windows platform layer (thanks, Dennis!).
Ryan C. Gordon <icculus@icculus.org>
parents:
933
diff
changeset
|
47 |
|
1100
f90724e3b4c6
Get rid of __inline__, just make sure "inline" is defined sanely instead.
Ryan C. Gordon <icculus@icculus.org>
parents:
1098
diff
changeset
|
48 |
#ifdef __cplusplus |
f90724e3b4c6
Get rid of __inline__, just make sure "inline" is defined sanely instead.
Ryan C. Gordon <icculus@icculus.org>
parents:
1098
diff
changeset
|
49 |
/* C++ always has a real inline keyword. */ |
f90724e3b4c6
Get rid of __inline__, just make sure "inline" is defined sanely instead.
Ryan C. Gordon <icculus@icculus.org>
parents:
1098
diff
changeset
|
50 |
#elif (defined macintosh) && !(defined __MWERKS__) |
f90724e3b4c6
Get rid of __inline__, just make sure "inline" is defined sanely instead.
Ryan C. Gordon <icculus@icculus.org>
parents:
1098
diff
changeset
|
51 |
# define inline |
f90724e3b4c6
Get rid of __inline__, just make sure "inline" is defined sanely instead.
Ryan C. Gordon <icculus@icculus.org>
parents:
1098
diff
changeset
|
52 |
#elif (defined _MSC_VER) |
f90724e3b4c6
Get rid of __inline__, just make sure "inline" is defined sanely instead.
Ryan C. Gordon <icculus@icculus.org>
parents:
1098
diff
changeset
|
53 |
# define inline __inline |
f90724e3b4c6
Get rid of __inline__, just make sure "inline" is defined sanely instead.
Ryan C. Gordon <icculus@icculus.org>
parents:
1098
diff
changeset
|
54 |
#endif |
f90724e3b4c6
Get rid of __inline__, just make sure "inline" is defined sanely instead.
Ryan C. Gordon <icculus@icculus.org>
parents:
1098
diff
changeset
|
55 |
|
1229
a6b73703c4f9
Use physfs_platforms.h in physfs_internal.h, to avoid repeated macro tests.
Ryan C. Gordon <icculus@icculus.org>
parents:
1228
diff
changeset
|
56 |
#if PHYSFS_PLATFORM_LINUX && !defined(_FILE_OFFSET_BITS) |
1228 | 57 |
#define _FILE_OFFSET_BITS 64 |
58 |
#endif |
|
59 |
||
852
9467e96abdf1
Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents:
851
diff
changeset
|
60 |
/* |
9467e96abdf1
Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents:
851
diff
changeset
|
61 |
* Interface for small allocations. If you need a little scratch space for |
9467e96abdf1
Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents:
851
diff
changeset
|
62 |
* a throwaway buffer or string, use this. It will make small allocations |
9467e96abdf1
Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents:
851
diff
changeset
|
63 |
* on the stack if possible, and use allocator.Malloc() if they are too |
9467e96abdf1
Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents:
851
diff
changeset
|
64 |
* large. This helps reduce malloc pressure. |
9467e96abdf1
Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents:
851
diff
changeset
|
65 |
* There are some rules, though: |
9467e96abdf1
Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents:
851
diff
changeset
|
66 |
* NEVER return a pointer from this, as stack-allocated buffers go away |
9467e96abdf1
Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents:
851
diff
changeset
|
67 |
* when your function returns. |
9467e96abdf1
Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents:
851
diff
changeset
|
68 |
* NEVER allocate in a loop, as stack-allocated pointers will pile up. Call |
9467e96abdf1
Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents:
851
diff
changeset
|
69 |
* a function that uses smallAlloc from your loop, so the allocation can |
9467e96abdf1
Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents:
851
diff
changeset
|
70 |
* free each time. |
9467e96abdf1
Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents:
851
diff
changeset
|
71 |
* NEVER call smallAlloc with any complex expression (it's a macro that WILL |
9467e96abdf1
Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents:
851
diff
changeset
|
72 |
* have side effects...it references the argument multiple times). Use a |
9467e96abdf1
Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents:
851
diff
changeset
|
73 |
* variable or a literal. |
9467e96abdf1
Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents:
851
diff
changeset
|
74 |
* NEVER free a pointer from this with anything but smallFree. It will not |
9467e96abdf1
Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents:
851
diff
changeset
|
75 |
* be a valid pointer to the allocator, regardless of where the memory came |
9467e96abdf1
Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents:
851
diff
changeset
|
76 |
* from. |
9467e96abdf1
Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents:
851
diff
changeset
|
77 |
* NEVER realloc a pointer from this. |
9467e96abdf1
Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents:
851
diff
changeset
|
78 |
* NEVER forget to use smallFree: it may not be a pointer from the stack. |
9467e96abdf1
Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents:
851
diff
changeset
|
79 |
* NEVER forget to check for NULL...allocation can fail here, of course! |
9467e96abdf1
Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents:
851
diff
changeset
|
80 |
*/ |
1205
af22fe211dde
Bump the smallAlloc threshold up to 256 bytes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1203
diff
changeset
|
81 |
#define __PHYSFS_SMALLALLOCTHRESHOLD 256 |
852
9467e96abdf1
Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents:
851
diff
changeset
|
82 |
void *__PHYSFS_initSmallAlloc(void *ptr, PHYSFS_uint64 len); |
9467e96abdf1
Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents:
851
diff
changeset
|
83 |
|
9467e96abdf1
Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents:
851
diff
changeset
|
84 |
#define __PHYSFS_smallAlloc(bytes) ( \ |
1215
0a8369723de7
Fixed stack smashing in newly-aligned __PHYSFS_smallAlloc().
Ryan C. Gordon <icculus@icculus.org>
parents:
1214
diff
changeset
|
85 |
__PHYSFS_initSmallAlloc( \ |
0a8369723de7
Fixed stack smashing in newly-aligned __PHYSFS_smallAlloc().
Ryan C. Gordon <icculus@icculus.org>
parents:
1214
diff
changeset
|
86 |
(((bytes) < __PHYSFS_SMALLALLOCTHRESHOLD) ? \ |
0a8369723de7
Fixed stack smashing in newly-aligned __PHYSFS_smallAlloc().
Ryan C. Gordon <icculus@icculus.org>
parents:
1214
diff
changeset
|
87 |
alloca((size_t)((bytes)+sizeof(void*))) : NULL), (bytes)) \ |
852
9467e96abdf1
Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents:
851
diff
changeset
|
88 |
) |
9467e96abdf1
Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents:
851
diff
changeset
|
89 |
|
9467e96abdf1
Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents:
851
diff
changeset
|
90 |
void __PHYSFS_smallFree(void *ptr); |
9467e96abdf1
Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents:
851
diff
changeset
|
91 |
|
9467e96abdf1
Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents:
851
diff
changeset
|
92 |
|
691
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
676
diff
changeset
|
93 |
/* Use the allocation hooks. */ |
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
676
diff
changeset
|
94 |
#define malloc(x) Do not use malloc() directly. |
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
676
diff
changeset
|
95 |
#define realloc(x, y) Do not use realloc() directly. |
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
676
diff
changeset
|
96 |
#define free(x) Do not use free() directly. |
836
6514fba91816
Patched to compile with latest Platform SDK.
Ryan C. Gordon <icculus@icculus.org>
parents:
828
diff
changeset
|
97 |
/* !!! FIXME: add alloca check here. */ |
427
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
422
diff
changeset
|
98 |
|
1258
074d08049aa7
Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents:
1255
diff
changeset
|
99 |
#ifndef PHYSFS_SUPPORTS_ZIP |
074d08049aa7
Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents:
1255
diff
changeset
|
100 |
#define PHYSFS_SUPPORTS_ZIP 1 |
074d08049aa7
Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents:
1255
diff
changeset
|
101 |
#endif |
074d08049aa7
Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents:
1255
diff
changeset
|
102 |
#ifndef PHYSFS_SUPPORTS_7Z |
074d08049aa7
Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents:
1255
diff
changeset
|
103 |
#define PHYSFS_SUPPORTS_7Z 0 |
074d08049aa7
Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents:
1255
diff
changeset
|
104 |
#endif |
074d08049aa7
Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents:
1255
diff
changeset
|
105 |
#ifndef PHYSFS_SUPPORTS_GRP |
074d08049aa7
Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents:
1255
diff
changeset
|
106 |
#define PHYSFS_SUPPORTS_GRP 0 |
074d08049aa7
Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents:
1255
diff
changeset
|
107 |
#endif |
074d08049aa7
Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents:
1255
diff
changeset
|
108 |
#ifndef PHYSFS_SUPPORTS_HOG |
074d08049aa7
Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents:
1255
diff
changeset
|
109 |
#define PHYSFS_SUPPORTS_HOG 0 |
074d08049aa7
Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents:
1255
diff
changeset
|
110 |
#endif |
074d08049aa7
Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents:
1255
diff
changeset
|
111 |
#ifndef PHYSFS_SUPPORTS_MVL |
074d08049aa7
Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents:
1255
diff
changeset
|
112 |
#define PHYSFS_SUPPORTS_MVL 0 |
074d08049aa7
Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents:
1255
diff
changeset
|
113 |
#endif |
074d08049aa7
Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents:
1255
diff
changeset
|
114 |
#ifndef PHYSFS_SUPPORTS_WAD |
074d08049aa7
Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents:
1255
diff
changeset
|
115 |
#define PHYSFS_SUPPORTS_WAD 0 |
074d08049aa7
Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents:
1255
diff
changeset
|
116 |
#endif |
074d08049aa7
Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents:
1255
diff
changeset
|
117 |
#ifndef PHYSFS_SUPPORTS_ISO9660 |
074d08049aa7
Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents:
1255
diff
changeset
|
118 |
#define PHYSFS_SUPPORTS_ISO9660 0 |
074d08049aa7
Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents:
1255
diff
changeset
|
119 |
#endif |
074d08049aa7
Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents:
1255
diff
changeset
|
120 |
|
1240
22d4d1bd4e21
Reworked the error reporting API. Now we use error codes instead of strings.
Ryan C. Gordon <icculus@icculus.org>
parents:
1234
diff
changeset
|
121 |
#define DIR_ARCHIVE_DESCRIPTION "Non-archive, direct filesystem I/O" |
22d4d1bd4e21
Reworked the error reporting API. Now we use error codes instead of strings.
Ryan C. Gordon <icculus@icculus.org>
parents:
1234
diff
changeset
|
122 |
#define GRP_ARCHIVE_DESCRIPTION "Build engine Groupfile format" |
22d4d1bd4e21
Reworked the error reporting API. Now we use error codes instead of strings.
Ryan C. Gordon <icculus@icculus.org>
parents:
1234
diff
changeset
|
123 |
#define HOG_ARCHIVE_DESCRIPTION "Descent I/II HOG file format" |
22d4d1bd4e21
Reworked the error reporting API. Now we use error codes instead of strings.
Ryan C. Gordon <icculus@icculus.org>
parents:
1234
diff
changeset
|
124 |
#define MVL_ARCHIVE_DESCRIPTION "Descent II Movielib format" |
22d4d1bd4e21
Reworked the error reporting API. Now we use error codes instead of strings.
Ryan C. Gordon <icculus@icculus.org>
parents:
1234
diff
changeset
|
125 |
#define QPAK_ARCHIVE_DESCRIPTION "Quake I/II format" |
22d4d1bd4e21
Reworked the error reporting API. Now we use error codes instead of strings.
Ryan C. Gordon <icculus@icculus.org>
parents:
1234
diff
changeset
|
126 |
#define ZIP_ARCHIVE_DESCRIPTION "PkZip/WinZip/Info-Zip compatible" |
22d4d1bd4e21
Reworked the error reporting API. Now we use error codes instead of strings.
Ryan C. Gordon <icculus@icculus.org>
parents:
1234
diff
changeset
|
127 |
#define WAD_ARCHIVE_DESCRIPTION "DOOM engine format" |
22d4d1bd4e21
Reworked the error reporting API. Now we use error codes instead of strings.
Ryan C. Gordon <icculus@icculus.org>
parents:
1234
diff
changeset
|
128 |
#define LZMA_ARCHIVE_DESCRIPTION "LZMA (7zip) format" |
427
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
422
diff
changeset
|
129 |
|
20
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
130 |
|
650
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
131 |
/* !!! FIXME: find something better than "dvoid" and "fvoid" ... */ |
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
132 |
/* Opaque data for file and dir handlers... */ |
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
133 |
typedef void dvoid; |
9 | 134 |
|
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
135 |
|
650
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
136 |
typedef struct |
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
137 |
{ |
9 | 138 |
/* |
650
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
139 |
* Basic info about this archiver... |
9 | 140 |
*/ |
650
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
141 |
const PHYSFS_ArchiveInfo *info; |
9 | 142 |
|
143 |
||
650
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
144 |
/* |
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
145 |
* DIRECTORY ROUTINES: |
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
146 |
* These functions are for dir handles. Generate a handle with the |
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
147 |
* openArchive() method, then pass it as the "opaque" dvoid to the |
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
148 |
* others. |
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
149 |
* |
1125
bcff76dbd9fd
Removed isDirectory, isSymLink and exists methods from internal code.
Ryan C. Gordon <icculus@icculus.org>
parents:
1120
diff
changeset
|
150 |
* Symlinks should always be followed (except in stat()); PhysicsFS will |
bcff76dbd9fd
Removed isDirectory, isSymLink and exists methods from internal code.
Ryan C. Gordon <icculus@icculus.org>
parents:
1120
diff
changeset
|
151 |
* use the stat() method to check for symlinks and make a judgement on |
bcff76dbd9fd
Removed isDirectory, isSymLink and exists methods from internal code.
Ryan C. Gordon <icculus@icculus.org>
parents:
1120
diff
changeset
|
152 |
* whether to continue to call other methods based on that. |
650
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
153 |
*/ |
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
154 |
|
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
155 |
/* |
1118
2e09fc635fdd
Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents:
1115
diff
changeset
|
156 |
* Open a dirhandle for dir/archive data provided by (io). |
2e09fc635fdd
Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents:
1115
diff
changeset
|
157 |
* (name) is a filename associated with (io), but doesn't necessarily |
2e09fc635fdd
Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents:
1115
diff
changeset
|
158 |
* map to anything, let alone a real filename. This possibly- |
2e09fc635fdd
Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents:
1115
diff
changeset
|
159 |
* meaningless name is in platform-dependent notation. |
2e09fc635fdd
Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents:
1115
diff
changeset
|
160 |
* (forWriting) is non-zero if this is to be used for |
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
161 |
* 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
|
162 |
* element of the search path. |
1240
22d4d1bd4e21
Reworked the error reporting API. Now we use error codes instead of strings.
Ryan C. Gordon <icculus@icculus.org>
parents:
1234
diff
changeset
|
163 |
* Returns NULL on failure. We ignore any error code you set here. |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
644
diff
changeset
|
164 |
* Returns non-NULL on success. The pointer returned will be |
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
644
diff
changeset
|
165 |
* passed as the "opaque" parameter for later calls. |
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
166 |
*/ |
1118
2e09fc635fdd
Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents:
1115
diff
changeset
|
167 |
dvoid *(*openArchive)(PHYSFS_Io *io, const char *name, int forWriting); |
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
168 |
|
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
169 |
/* |
657
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
170 |
* List all files in (dirname). Each file is passed to (callback), |
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
171 |
* where a copy is made if appropriate, so you should dispose of |
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
172 |
* it properly upon return from the callback. |
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
173 |
* You should omit symlinks if (omitSymLinks) is non-zero. |
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
174 |
* If you have a failure, report as much as you can. |
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
175 |
* (dirname) is in platform-independent notation. |
9 | 176 |
*/ |
657
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
177 |
void (*enumerateFiles)(dvoid *opaque, |
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
178 |
const char *dirname, |
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
179 |
int omitSymLinks, |
754
e7cd7411eadf
API BREAKAGE: Changed PHYSFS_enumerateFilesCallback() to pass the originally
Ryan C. Gordon <icculus@icculus.org>
parents:
747
diff
changeset
|
180 |
PHYSFS_EnumFilesCallback callback, |
e7cd7411eadf
API BREAKAGE: Changed PHYSFS_enumerateFilesCallback() to pass the originally
Ryan C. Gordon <icculus@icculus.org>
parents:
747
diff
changeset
|
181 |
const char *origdir, |
657
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
182 |
void *callbackdata); |
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
183 |
|
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
184 |
/* |
650
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
185 |
* Open file for reading. |
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
186 |
* 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
|
187 |
* 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
|
188 |
* 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
|
189 |
* 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
|
190 |
* Returns NULL on failure, and calls __PHYSFS_setError(). |
650
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
191 |
* Returns non-NULL on success. The pointer returned will be |
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
192 |
* passed as the "opaque" parameter for later file calls. |
467
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
193 |
* |
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
194 |
* Regardless of success or failure, please set *fileExists to |
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
195 |
* non-zero if the file existed (even if it's a broken symlink!), |
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
196 |
* zero if it did not. |
9 | 197 |
*/ |
1118
2e09fc635fdd
Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents:
1115
diff
changeset
|
198 |
PHYSFS_Io *(*openRead)(dvoid *opaque, const char *fname, int *fileExists); |
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
199 |
|
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
200 |
/* |
650
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
201 |
* Open file for writing. |
20
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
202 |
* 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
|
203 |
* 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
|
204 |
* 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
|
205 |
* 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
|
206 |
* 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
|
207 |
* 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
|
208 |
* Returns NULL on failure, and calls __PHYSFS_setError(). |
650
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
209 |
* Returns non-NULL on success. The pointer returned will be |
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
210 |
* passed as the "opaque" parameter for later file calls. |
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
211 |
*/ |
1118
2e09fc635fdd
Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents:
1115
diff
changeset
|
212 |
PHYSFS_Io *(*openWrite)(dvoid *opaque, const char *filename); |
9 | 213 |
|
214 |
/* |
|
650
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
215 |
* Open file for appending. |
20
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
216 |
* 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
|
217 |
* 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
|
218 |
* 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
|
219 |
* 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
|
220 |
* 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
|
221 |
* Returns NULL on failure, and calls __PHYSFS_setError(). |
650
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
222 |
* Returns non-NULL on success. The pointer returned will be |
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
223 |
* passed as the "opaque" parameter for later file calls. |
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
224 |
*/ |
1118
2e09fc635fdd
Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents:
1115
diff
changeset
|
225 |
PHYSFS_Io *(*openAppend)(dvoid *opaque, const char *filename); |
11
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
226 |
|
677e01f5109e
Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents:
9
diff
changeset
|
227 |
/* |
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
228 |
* 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
|
229 |
* 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
|
230 |
* 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
|
231 |
* This method may be NULL. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
232 |
* On failure, call __PHYSFS_setError(). |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
233 |
*/ |
650
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
234 |
int (*remove)(dvoid *opaque, const char *filename); |
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
235 |
|
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
236 |
/* |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
237 |
* 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
|
238 |
* 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
|
239 |
* 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
|
240 |
* your driver. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
241 |
* 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
|
242 |
* 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
|
243 |
* This method may be NULL. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
244 |
* On failure, call __PHYSFS_setError(). |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
245 |
*/ |
650
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
246 |
int (*mkdir)(dvoid *opaque, const char *filename); |
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
247 |
|
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
248 |
/* |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
644
diff
changeset
|
249 |
* Close directories/archives, and free any associated memory, |
1118
2e09fc635fdd
Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents:
1115
diff
changeset
|
250 |
* including the original PHYSFS_Io and (opaque) itself, if |
2e09fc635fdd
Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents:
1115
diff
changeset
|
251 |
* applicable. Implementation can assume that it won't be called if |
2e09fc635fdd
Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents:
1115
diff
changeset
|
252 |
* there are still files open from this archive. |
9 | 253 |
*/ |
650
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
254 |
void (*dirClose)(dvoid *opaque); |
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
255 |
|
1108
b63e39d5be04
Fixed details of PHYSFS_Archiver's stat method.
Ryan C. Gordon <icculus@icculus.org>
parents:
1100
diff
changeset
|
256 |
/* |
b63e39d5be04
Fixed details of PHYSFS_Archiver's stat method.
Ryan C. Gordon <icculus@icculus.org>
parents:
1100
diff
changeset
|
257 |
* Obtain basic file metadata. |
b63e39d5be04
Fixed details of PHYSFS_Archiver's stat method.
Ryan C. Gordon <icculus@icculus.org>
parents:
1100
diff
changeset
|
258 |
* Returns non-zero on success, zero on failure. |
b63e39d5be04
Fixed details of PHYSFS_Archiver's stat method.
Ryan C. Gordon <icculus@icculus.org>
parents:
1100
diff
changeset
|
259 |
* On failure, call __PHYSFS_setError(). |
b63e39d5be04
Fixed details of PHYSFS_Archiver's stat method.
Ryan C. Gordon <icculus@icculus.org>
parents:
1100
diff
changeset
|
260 |
*/ |
b63e39d5be04
Fixed details of PHYSFS_Archiver's stat method.
Ryan C. Gordon <icculus@icculus.org>
parents:
1100
diff
changeset
|
261 |
int (*stat)(dvoid *opaque, const char *fn, int *exists, PHYSFS_Stat *stat); |
650
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
262 |
} PHYSFS_Archiver; |
9 | 263 |
|
264 |
||
265 |
/* |
|
266 |
* Call this to set the message returned by PHYSFS_getLastError(). |
|
267 |
* Please only use the ERR_* constants above, or add new constants to the |
|
268 |
* 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
|
269 |
* |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
12
diff
changeset
|
270 |
* Calling this with a NULL argument is a safe no-op. |
9 | 271 |
*/ |
1240
22d4d1bd4e21
Reworked the error reporting API. Now we use error codes instead of strings.
Ryan C. Gordon <icculus@icculus.org>
parents:
1234
diff
changeset
|
272 |
void __PHYSFS_setError(const PHYSFS_ErrorCode err); |
9 | 273 |
|
274 |
||
629
b01a59827192
Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents:
627
diff
changeset
|
275 |
/* This byteorder stuff was lifted from SDL. http://www.libsdl.org/ */ |
b01a59827192
Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents:
627
diff
changeset
|
276 |
#define PHYSFS_LIL_ENDIAN 1234 |
b01a59827192
Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents:
627
diff
changeset
|
277 |
#define PHYSFS_BIG_ENDIAN 4321 |
b01a59827192
Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents:
627
diff
changeset
|
278 |
|
1185
43aea6bc12d7
Check _M_X64 (Visual Studio, Windows/x86-64) in littleendian test.
Ryan C. Gordon <icculus@icculus.org>
parents:
1180
diff
changeset
|
279 |
#if defined(__i386__) || defined(__ia64__) || \ |
1188 | 280 |
defined(_M_IX86) || defined(_M_IA64) || defined(_M_X64) || \ |
629
b01a59827192
Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents:
627
diff
changeset
|
281 |
(defined(__alpha__) || defined(__alpha)) || \ |
b01a59827192
Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents:
627
diff
changeset
|
282 |
defined(__arm__) || defined(ARM) || \ |
b01a59827192
Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents:
627
diff
changeset
|
283 |
(defined(__mips__) && defined(__MIPSEL__)) || \ |
b01a59827192
Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents:
627
diff
changeset
|
284 |
defined(__SYMBIAN32__) || \ |
b01a59827192
Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents:
627
diff
changeset
|
285 |
defined(__x86_64__) || \ |
b01a59827192
Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents:
627
diff
changeset
|
286 |
defined(__LITTLE_ENDIAN__) |
b01a59827192
Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents:
627
diff
changeset
|
287 |
#define PHYSFS_BYTEORDER PHYSFS_LIL_ENDIAN |
b01a59827192
Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents:
627
diff
changeset
|
288 |
#else |
b01a59827192
Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents:
627
diff
changeset
|
289 |
#define PHYSFS_BYTEORDER PHYSFS_BIG_ENDIAN |
b01a59827192
Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents:
627
diff
changeset
|
290 |
#endif |
b01a59827192
Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents:
627
diff
changeset
|
291 |
|
b01a59827192
Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents:
627
diff
changeset
|
292 |
|
464
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
444
diff
changeset
|
293 |
/* |
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
444
diff
changeset
|
294 |
* When sorting the entries in an archive, we use a modified QuickSort. |
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
444
diff
changeset
|
295 |
* When there are less then PHYSFS_QUICKSORT_THRESHOLD entries left to sort, |
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
444
diff
changeset
|
296 |
* we switch over to a BubbleSort for the remainder. Tweak to taste. |
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
444
diff
changeset
|
297 |
* |
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
444
diff
changeset
|
298 |
* You can override this setting by defining PHYSFS_QUICKSORT_THRESHOLD |
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
444
diff
changeset
|
299 |
* before #including "physfs_internal.h". |
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
444
diff
changeset
|
300 |
*/ |
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
444
diff
changeset
|
301 |
#ifndef PHYSFS_QUICKSORT_THRESHOLD |
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
444
diff
changeset
|
302 |
#define PHYSFS_QUICKSORT_THRESHOLD 4 |
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
444
diff
changeset
|
303 |
#endif |
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
444
diff
changeset
|
304 |
|
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
444
diff
changeset
|
305 |
/* |
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
444
diff
changeset
|
306 |
* Sort an array (or whatever) of (max) elements. This uses a mixture of |
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
444
diff
changeset
|
307 |
* a QuickSort and BubbleSort internally. |
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
444
diff
changeset
|
308 |
* (cmpfn) is used to determine ordering, and (swapfn) does the actual |
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
444
diff
changeset
|
309 |
* swapping of elements in the list. |
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
444
diff
changeset
|
310 |
* |
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
444
diff
changeset
|
311 |
* See zip.c for an example. |
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
444
diff
changeset
|
312 |
*/ |
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
444
diff
changeset
|
313 |
void __PHYSFS_sort(void *entries, PHYSFS_uint32 max, |
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
444
diff
changeset
|
314 |
int (*cmpfn)(void *, PHYSFS_uint32, PHYSFS_uint32), |
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
444
diff
changeset
|
315 |
void (*swapfn)(void *, PHYSFS_uint32, PHYSFS_uint32)); |
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
444
diff
changeset
|
316 |
|
1240
22d4d1bd4e21
Reworked the error reporting API. Now we use error codes instead of strings.
Ryan C. Gordon <icculus@icculus.org>
parents:
1234
diff
changeset
|
317 |
/* |
22d4d1bd4e21
Reworked the error reporting API. Now we use error codes instead of strings.
Ryan C. Gordon <icculus@icculus.org>
parents:
1234
diff
changeset
|
318 |
* This isn't a formal error code, it's just for BAIL_MACRO. |
22d4d1bd4e21
Reworked the error reporting API. Now we use error codes instead of strings.
Ryan C. Gordon <icculus@icculus.org>
parents:
1234
diff
changeset
|
319 |
* It means: there was an error, but someone else already set it for us. |
22d4d1bd4e21
Reworked the error reporting API. Now we use error codes instead of strings.
Ryan C. Gordon <icculus@icculus.org>
parents:
1234
diff
changeset
|
320 |
*/ |
22d4d1bd4e21
Reworked the error reporting API. Now we use error codes instead of strings.
Ryan C. Gordon <icculus@icculus.org>
parents:
1234
diff
changeset
|
321 |
#define ERRPASS PHYSFS_ERR_OK |
363
79f155a51527
Added __PHYSFS_addToLinkedStringList().
Ryan C. Gordon <icculus@icculus.org>
parents:
344
diff
changeset
|
322 |
|
69
546a95cc5591
Updates, corrections and enhancements to get this ported to win32.
Ryan C. Gordon <icculus@icculus.org>
parents:
49
diff
changeset
|
323 |
/* These get used all over for lessening code clutter. */ |
1240
22d4d1bd4e21
Reworked the error reporting API. Now we use error codes instead of strings.
Ryan C. Gordon <icculus@icculus.org>
parents:
1234
diff
changeset
|
324 |
#define BAIL_MACRO(e, r) do { if (e) __PHYSFS_setError(e); return r; } while (0) |
22d4d1bd4e21
Reworked the error reporting API. Now we use error codes instead of strings.
Ryan C. Gordon <icculus@icculus.org>
parents:
1234
diff
changeset
|
325 |
#define BAIL_IF_MACRO(c, e, r) do { if (c) { if (e) __PHYSFS_setError(e); return r; } } while (0) |
22d4d1bd4e21
Reworked the error reporting API. Now we use error codes instead of strings.
Ryan C. Gordon <icculus@icculus.org>
parents:
1234
diff
changeset
|
326 |
#define BAIL_MACRO_MUTEX(e, m, r) do { if (e) __PHYSFS_setError(e); __PHYSFS_platformReleaseMutex(m); return r; } while (0) |
22d4d1bd4e21
Reworked the error reporting API. Now we use error codes instead of strings.
Ryan C. Gordon <icculus@icculus.org>
parents:
1234
diff
changeset
|
327 |
#define BAIL_IF_MACRO_MUTEX(c, e, m, r) do { if (c) { if (e) __PHYSFS_setError(e); __PHYSFS_platformReleaseMutex(m); return r; } } while (0) |
22d4d1bd4e21
Reworked the error reporting API. Now we use error codes instead of strings.
Ryan C. Gordon <icculus@icculus.org>
parents:
1234
diff
changeset
|
328 |
#define GOTO_MACRO(e, g) do { if (e) __PHYSFS_setError(e); goto g; } while (0) |
22d4d1bd4e21
Reworked the error reporting API. Now we use error codes instead of strings.
Ryan C. Gordon <icculus@icculus.org>
parents:
1234
diff
changeset
|
329 |
#define GOTO_IF_MACRO(c, e, g) do { if (c) { if (e) __PHYSFS_setError(e); goto g; } } while (0) |
22d4d1bd4e21
Reworked the error reporting API. Now we use error codes instead of strings.
Ryan C. Gordon <icculus@icculus.org>
parents:
1234
diff
changeset
|
330 |
#define GOTO_MACRO_MUTEX(e, m, g) do { if (e) __PHYSFS_setError(e); __PHYSFS_platformReleaseMutex(m); goto g; } while (0) |
22d4d1bd4e21
Reworked the error reporting API. Now we use error codes instead of strings.
Ryan C. Gordon <icculus@icculus.org>
parents:
1234
diff
changeset
|
331 |
#define GOTO_IF_MACRO_MUTEX(c, e, m, g) do { if (c) { if (e) __PHYSFS_setError(e); __PHYSFS_platformReleaseMutex(m); goto g; } } while (0) |
9 | 332 |
|
828
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
333 |
#define __PHYSFS_ARRAYLEN(x) ( (sizeof (x)) / (sizeof (x[0])) ) |
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
334 |
|
1098
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1097
diff
changeset
|
335 |
#ifdef PHYSFS_NO_64BIT_SUPPORT |
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1097
diff
changeset
|
336 |
#define __PHYSFS_SI64(x) ((PHYSFS_sint64) (x)) |
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1097
diff
changeset
|
337 |
#define __PHYSFS_UI64(x) ((PHYSFS_uint64) (x)) |
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1097
diff
changeset
|
338 |
#elif (defined __GNUC__) |
850
2bc230284fed
Replaced LONGLONGLITERAL with __PHYSFS_UI64/__PHYSFS_SI64.
Ryan C. Gordon <icculus@icculus.org>
parents:
845
diff
changeset
|
339 |
#define __PHYSFS_SI64(x) x##LL |
2bc230284fed
Replaced LONGLONGLITERAL with __PHYSFS_UI64/__PHYSFS_SI64.
Ryan C. Gordon <icculus@icculus.org>
parents:
845
diff
changeset
|
340 |
#define __PHYSFS_UI64(x) x##ULL |
851
dcfbb779ff40
Apparently this is how you do 64-bit literals in MSVC...untested.
Ryan C. Gordon <icculus@icculus.org>
parents:
850
diff
changeset
|
341 |
#elif (defined _MSC_VER) |
dcfbb779ff40
Apparently this is how you do 64-bit literals in MSVC...untested.
Ryan C. Gordon <icculus@icculus.org>
parents:
850
diff
changeset
|
342 |
#define __PHYSFS_SI64(x) x##i64 |
dcfbb779ff40
Apparently this is how you do 64-bit literals in MSVC...untested.
Ryan C. Gordon <icculus@icculus.org>
parents:
850
diff
changeset
|
343 |
#define __PHYSFS_UI64(x) x##ui64 |
763
efadd9cdb6a4
Cleaned up overflow checks in platform memory allocators (thanks to Nicolas
Ryan C. Gordon <icculus@icculus.org>
parents:
754
diff
changeset
|
344 |
#else |
1098
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1097
diff
changeset
|
345 |
#define __PHYSFS_SI64(x) ((PHYSFS_sint64) (x)) |
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1097
diff
changeset
|
346 |
#define __PHYSFS_UI64(x) ((PHYSFS_uint64) (x)) |
763
efadd9cdb6a4
Cleaned up overflow checks in platform memory allocators (thanks to Nicolas
Ryan C. Gordon <icculus@icculus.org>
parents:
754
diff
changeset
|
347 |
#endif |
efadd9cdb6a4
Cleaned up overflow checks in platform memory allocators (thanks to Nicolas
Ryan C. Gordon <icculus@icculus.org>
parents:
754
diff
changeset
|
348 |
|
936
3b4b6c107a59
Fixed aliasing bug in Windows platform layer (thanks, Dennis!).
Ryan C. Gordon <icculus@icculus.org>
parents:
933
diff
changeset
|
349 |
|
763
efadd9cdb6a4
Cleaned up overflow checks in platform memory allocators (thanks to Nicolas
Ryan C. Gordon <icculus@icculus.org>
parents:
754
diff
changeset
|
350 |
/* |
efadd9cdb6a4
Cleaned up overflow checks in platform memory allocators (thanks to Nicolas
Ryan C. Gordon <icculus@icculus.org>
parents:
754
diff
changeset
|
351 |
* Check if a ui64 will fit in the platform's address space. |
efadd9cdb6a4
Cleaned up overflow checks in platform memory allocators (thanks to Nicolas
Ryan C. Gordon <icculus@icculus.org>
parents:
754
diff
changeset
|
352 |
* The initial sizeof check will optimize this macro out entirely on |
efadd9cdb6a4
Cleaned up overflow checks in platform memory allocators (thanks to Nicolas
Ryan C. Gordon <icculus@icculus.org>
parents:
754
diff
changeset
|
353 |
* 64-bit (and larger?!) platforms, and the other condition will |
efadd9cdb6a4
Cleaned up overflow checks in platform memory allocators (thanks to Nicolas
Ryan C. Gordon <icculus@icculus.org>
parents:
754
diff
changeset
|
354 |
* return zero or non-zero if the variable will fit in the platform's |
efadd9cdb6a4
Cleaned up overflow checks in platform memory allocators (thanks to Nicolas
Ryan C. Gordon <icculus@icculus.org>
parents:
754
diff
changeset
|
355 |
* size_t, suitable to pass to malloc. This is kinda messy, but effective. |
efadd9cdb6a4
Cleaned up overflow checks in platform memory allocators (thanks to Nicolas
Ryan C. Gordon <icculus@icculus.org>
parents:
754
diff
changeset
|
356 |
*/ |
efadd9cdb6a4
Cleaned up overflow checks in platform memory allocators (thanks to Nicolas
Ryan C. Gordon <icculus@icculus.org>
parents:
754
diff
changeset
|
357 |
#define __PHYSFS_ui64FitsAddressSpace(s) ( \ |
1112
12e187aa051c
Made __PHYSFS_ui64FitsAddressSpace's behaviour match its name.
Ryan C. Gordon <icculus@icculus.org>
parents:
1111
diff
changeset
|
358 |
(sizeof (PHYSFS_uint64) <= sizeof (size_t)) || \ |
12e187aa051c
Made __PHYSFS_ui64FitsAddressSpace's behaviour match its name.
Ryan C. Gordon <icculus@icculus.org>
parents:
1111
diff
changeset
|
359 |
((s) < (__PHYSFS_UI64(0xFFFFFFFFFFFFFFFF) >> (64-(sizeof(size_t)*8)))) \ |
763
efadd9cdb6a4
Cleaned up overflow checks in platform memory allocators (thanks to Nicolas
Ryan C. Gordon <icculus@icculus.org>
parents:
754
diff
changeset
|
360 |
) |
9 | 361 |
|
936
3b4b6c107a59
Fixed aliasing bug in Windows platform layer (thanks, Dennis!).
Ryan C. Gordon <icculus@icculus.org>
parents:
933
diff
changeset
|
362 |
|
644
1cb5533d369c
Initial structure for replacable allocator work.
Ryan C. Gordon <icculus@icculus.org>
parents:
641
diff
changeset
|
363 |
/* |
828
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
364 |
* This is a strcasecmp() or stricmp() replacement that expects both strings |
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
365 |
* to be in UTF-8 encoding. It will do "case folding" to decide if the |
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
366 |
* Unicode codepoints in the strings match. |
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
367 |
* |
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
368 |
* It will report which string is "greater than" the other, but be aware that |
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
369 |
* this doesn't necessarily mean anything: 'a' may be "less than" 'b', but |
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
370 |
* a random Kanji codepoint has no meaningful alphabetically relationship to |
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
371 |
* a Greek Lambda, but being able to assign a reliable "value" makes sorting |
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
372 |
* algorithms possible, if not entirely sane. Most cases should treat the |
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
373 |
* return value as "equal" or "not equal". |
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
374 |
*/ |
1255
f15ec4962d08
Renamed __PHYSFS_utf8strcasecmp() to __PHYSFS_utf8stricmp().
Ryan C. Gordon <icculus@icculus.org>
parents:
1249
diff
changeset
|
375 |
int __PHYSFS_utf8stricmp(const char *s1, const char *s2); |
828
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
376 |
|
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
377 |
/* |
1255
f15ec4962d08
Renamed __PHYSFS_utf8strcasecmp() to __PHYSFS_utf8stricmp().
Ryan C. Gordon <icculus@icculus.org>
parents:
1249
diff
changeset
|
378 |
* This works like __PHYSFS_utf8stricmp(), but takes a character (NOT BYTE |
828
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
379 |
* COUNT) argument, like strcasencmp(). |
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
380 |
*/ |
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
381 |
int __PHYSFS_utf8strnicmp(const char *s1, const char *s2, PHYSFS_uint32 l); |
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
382 |
|
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
383 |
/* |
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
384 |
* stricmp() that guarantees to only work with low ASCII. The C runtime |
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
385 |
* stricmp() might try to apply a locale/codepage/etc, which we don't want. |
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
386 |
*/ |
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
387 |
int __PHYSFS_stricmpASCII(const char *s1, const char *s2); |
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
388 |
|
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
389 |
/* |
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
390 |
* strnicmp() that guarantees to only work with low ASCII. The C runtime |
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
391 |
* strnicmp() might try to apply a locale/codepage/etc, which we don't want. |
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
392 |
*/ |
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
393 |
int __PHYSFS_strnicmpASCII(const char *s1, const char *s2, PHYSFS_uint32 l); |
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
394 |
|
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
395 |
|
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
396 |
/* |
691
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
676
diff
changeset
|
397 |
* The current allocator. Not valid before PHYSFS_init is called! |
644
1cb5533d369c
Initial structure for replacable allocator work.
Ryan C. Gordon <icculus@icculus.org>
parents:
641
diff
changeset
|
398 |
*/ |
691
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
676
diff
changeset
|
399 |
extern PHYSFS_Allocator __PHYSFS_AllocatorHooks; |
9 | 400 |
|
691
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
676
diff
changeset
|
401 |
/* convenience macro to make this less cumbersome internally... */ |
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
676
diff
changeset
|
402 |
#define allocator __PHYSFS_AllocatorHooks |
9 | 403 |
|
1118
2e09fc635fdd
Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents:
1115
diff
changeset
|
404 |
/* |
2e09fc635fdd
Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents:
1115
diff
changeset
|
405 |
* Create a PHYSFS_Io for a file in the physical filesystem. |
2e09fc635fdd
Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents:
1115
diff
changeset
|
406 |
* This path is in platform-dependent notation. (mode) must be 'r', 'w', or |
2e09fc635fdd
Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents:
1115
diff
changeset
|
407 |
* 'a' for Read, Write, or Append. |
2e09fc635fdd
Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents:
1115
diff
changeset
|
408 |
*/ |
2e09fc635fdd
Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents:
1115
diff
changeset
|
409 |
PHYSFS_Io *__PHYSFS_createNativeIo(const char *path, const int mode); |
2e09fc635fdd
Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents:
1115
diff
changeset
|
410 |
|
1120
67e5e23425a0
Added PHYSFS_mountMemory().
Ryan C. Gordon <icculus@icculus.org>
parents:
1118
diff
changeset
|
411 |
/* |
67e5e23425a0
Added PHYSFS_mountMemory().
Ryan C. Gordon <icculus@icculus.org>
parents:
1118
diff
changeset
|
412 |
* Create a PHYSFS_Io for a buffer of memory (READ-ONLY). If you already |
67e5e23425a0
Added PHYSFS_mountMemory().
Ryan C. Gordon <icculus@icculus.org>
parents:
1118
diff
changeset
|
413 |
* have one of these, just use its duplicate() method, and it'll increment |
67e5e23425a0
Added PHYSFS_mountMemory().
Ryan C. Gordon <icculus@icculus.org>
parents:
1118
diff
changeset
|
414 |
* its refcount without allocating a copy of the buffer. |
67e5e23425a0
Added PHYSFS_mountMemory().
Ryan C. Gordon <icculus@icculus.org>
parents:
1118
diff
changeset
|
415 |
*/ |
67e5e23425a0
Added PHYSFS_mountMemory().
Ryan C. Gordon <icculus@icculus.org>
parents:
1118
diff
changeset
|
416 |
PHYSFS_Io *__PHYSFS_createMemoryIo(const void *buf, PHYSFS_uint64 len, |
67e5e23425a0
Added PHYSFS_mountMemory().
Ryan C. Gordon <icculus@icculus.org>
parents:
1118
diff
changeset
|
417 |
void (*destruct)(void *)); |
67e5e23425a0
Added PHYSFS_mountMemory().
Ryan C. Gordon <icculus@icculus.org>
parents:
1118
diff
changeset
|
418 |
|
1118
2e09fc635fdd
Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents:
1115
diff
changeset
|
419 |
|
1203
55f147714ce2
Cleaned up all the readAll() cut and paste.
Ryan C. Gordon <icculus@icculus.org>
parents:
1197
diff
changeset
|
420 |
/* |
55f147714ce2
Cleaned up all the readAll() cut and paste.
Ryan C. Gordon <icculus@icculus.org>
parents:
1197
diff
changeset
|
421 |
* Read (len) bytes from (io) into (buf). Returns non-zero on success, |
55f147714ce2
Cleaned up all the readAll() cut and paste.
Ryan C. Gordon <icculus@icculus.org>
parents:
1197
diff
changeset
|
422 |
* zero on i/o error. Literally: "return (io->read(io, buf, len) == len);" |
55f147714ce2
Cleaned up all the readAll() cut and paste.
Ryan C. Gordon <icculus@icculus.org>
parents:
1197
diff
changeset
|
423 |
*/ |
55f147714ce2
Cleaned up all the readAll() cut and paste.
Ryan C. Gordon <icculus@icculus.org>
parents:
1197
diff
changeset
|
424 |
int __PHYSFS_readAll(PHYSFS_Io *io, void *buf, const PHYSFS_uint64 len); |
1128
067d8e76261e
Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents:
1127
diff
changeset
|
425 |
|
067d8e76261e
Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents:
1127
diff
changeset
|
426 |
|
067d8e76261e
Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents:
1127
diff
changeset
|
427 |
/* These are shared between some archivers. */ |
067d8e76261e
Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents:
1127
diff
changeset
|
428 |
|
067d8e76261e
Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents:
1127
diff
changeset
|
429 |
typedef struct |
067d8e76261e
Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents:
1127
diff
changeset
|
430 |
{ |
067d8e76261e
Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents:
1127
diff
changeset
|
431 |
char name[32]; |
067d8e76261e
Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents:
1127
diff
changeset
|
432 |
PHYSFS_uint32 startPos; |
067d8e76261e
Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents:
1127
diff
changeset
|
433 |
PHYSFS_uint32 size; |
067d8e76261e
Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents:
1127
diff
changeset
|
434 |
} UNPKentry; |
067d8e76261e
Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents:
1127
diff
changeset
|
435 |
|
067d8e76261e
Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents:
1127
diff
changeset
|
436 |
void UNPK_dirClose(dvoid *opaque); |
067d8e76261e
Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents:
1127
diff
changeset
|
437 |
dvoid *UNPK_openArchive(PHYSFS_Io *io, UNPKentry *e, const PHYSFS_uint32 num); |
067d8e76261e
Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents:
1127
diff
changeset
|
438 |
void UNPK_enumerateFiles(dvoid *opaque, const char *dname, |
067d8e76261e
Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents:
1127
diff
changeset
|
439 |
int omitSymLinks, PHYSFS_EnumFilesCallback cb, |
067d8e76261e
Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents:
1127
diff
changeset
|
440 |
const char *origdir, void *callbackdata); |
067d8e76261e
Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents:
1127
diff
changeset
|
441 |
PHYSFS_Io *UNPK_openRead(dvoid *opaque, const char *fnm, int *fileExists); |
067d8e76261e
Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents:
1127
diff
changeset
|
442 |
PHYSFS_Io *UNPK_openWrite(dvoid *opaque, const char *name); |
067d8e76261e
Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents:
1127
diff
changeset
|
443 |
PHYSFS_Io *UNPK_openAppend(dvoid *opaque, const char *name); |
067d8e76261e
Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents:
1127
diff
changeset
|
444 |
int UNPK_remove(dvoid *opaque, const char *name); |
067d8e76261e
Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents:
1127
diff
changeset
|
445 |
int UNPK_mkdir(dvoid *opaque, const char *name); |
067d8e76261e
Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents:
1127
diff
changeset
|
446 |
int UNPK_stat(dvoid *opaque, const char *fn, int *exists, PHYSFS_Stat *stat); |
067d8e76261e
Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents:
1127
diff
changeset
|
447 |
|
067d8e76261e
Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents:
1127
diff
changeset
|
448 |
|
9 | 449 |
/*--------------------------------------------------------------------------*/ |
450 |
/*--------------------------------------------------------------------------*/ |
|
451 |
/*------------ ----------------*/ |
|
452 |
/*------------ You MUST implement the following functions ----------------*/ |
|
453 |
/*------------ 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
|
454 |
/*------------ (see platform/unix.c for an example) ----------------*/ |
9 | 455 |
/*------------ ----------------*/ |
456 |
/*--------------------------------------------------------------------------*/ |
|
457 |
/*--------------------------------------------------------------------------*/ |
|
458 |
||
459 |
||
460 |
/* |
|
1225
671d4ea47c13
Make __PHYSFS_platformDirSeparator into a single char.
Ryan C. Gordon <icculus@icculus.org>
parents:
1224
diff
changeset
|
461 |
* The dir separator; '/' on unix, '\\' on win32, ":" on MacOS, etc... |
671d4ea47c13
Make __PHYSFS_platformDirSeparator into a single char.
Ryan C. Gordon <icculus@icculus.org>
parents:
1224
diff
changeset
|
462 |
* Obviously, this isn't a function. If you need more than one char for this, |
671d4ea47c13
Make __PHYSFS_platformDirSeparator into a single char.
Ryan C. Gordon <icculus@icculus.org>
parents:
1224
diff
changeset
|
463 |
* you'll need to pull some old pieces of PhysicsFS out of revision control. |
9 | 464 |
*/ |
1229
a6b73703c4f9
Use physfs_platforms.h in physfs_internal.h, to avoid repeated macro tests.
Ryan C. Gordon <icculus@icculus.org>
parents:
1228
diff
changeset
|
465 |
#if PHYSFS_PLATFORM_WINDOWS |
1225
671d4ea47c13
Make __PHYSFS_platformDirSeparator into a single char.
Ryan C. Gordon <icculus@icculus.org>
parents:
1224
diff
changeset
|
466 |
#define __PHYSFS_platformDirSeparator '\\' |
671d4ea47c13
Make __PHYSFS_platformDirSeparator into a single char.
Ryan C. Gordon <icculus@icculus.org>
parents:
1224
diff
changeset
|
467 |
#else |
671d4ea47c13
Make __PHYSFS_platformDirSeparator into a single char.
Ryan C. Gordon <icculus@icculus.org>
parents:
1224
diff
changeset
|
468 |
#define __PHYSFS_platformDirSeparator '/' |
671d4ea47c13
Make __PHYSFS_platformDirSeparator into a single char.
Ryan C. Gordon <icculus@icculus.org>
parents:
1224
diff
changeset
|
469 |
#endif |
130
2deec3eb7430
Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents:
126
diff
changeset
|
470 |
|
2deec3eb7430
Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents:
126
diff
changeset
|
471 |
/* |
2deec3eb7430
Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents:
126
diff
changeset
|
472 |
* Initialize the platform. This is called when PHYSFS_init() is called from |
1227
b5c017759a1f
Fixed a comment. Cut and paste error, I guess?
Ryan C. Gordon <icculus@icculus.org>
parents:
1226
diff
changeset
|
473 |
* the application. |
130
2deec3eb7430
Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents:
126
diff
changeset
|
474 |
* |
2deec3eb7430
Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents:
126
diff
changeset
|
475 |
* Return zero if there was a catastrophic failure (which prevents you from |
2deec3eb7430
Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents:
126
diff
changeset
|
476 |
* functioning at all), and non-zero otherwise. |
2deec3eb7430
Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents:
126
diff
changeset
|
477 |
*/ |
2deec3eb7430
Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents:
126
diff
changeset
|
478 |
int __PHYSFS_platformInit(void); |
2deec3eb7430
Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents:
126
diff
changeset
|
479 |
|
240
052041af9001
Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents:
172
diff
changeset
|
480 |
|
130
2deec3eb7430
Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents:
126
diff
changeset
|
481 |
/* |
2deec3eb7430
Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents:
126
diff
changeset
|
482 |
* Deinitialize the platform. This is called when PHYSFS_deinit() is called |
2deec3eb7430
Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents:
126
diff
changeset
|
483 |
* from the application. You can use this to clean up anything you've |
2deec3eb7430
Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents:
126
diff
changeset
|
484 |
* allocated in your platform driver. |
2deec3eb7430
Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents:
126
diff
changeset
|
485 |
* |
2deec3eb7430
Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents:
126
diff
changeset
|
486 |
* Return zero if there was a catastrophic failure (which prevents you from |
2deec3eb7430
Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents:
126
diff
changeset
|
487 |
* functioning at all), and non-zero otherwise. |
2deec3eb7430
Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents:
126
diff
changeset
|
488 |
*/ |
2deec3eb7430
Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents:
126
diff
changeset
|
489 |
int __PHYSFS_platformDeinit(void); |
2deec3eb7430
Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents:
126
diff
changeset
|
490 |
|
240
052041af9001
Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents:
172
diff
changeset
|
491 |
|
9 | 492 |
/* |
132
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
493 |
* Open a file for reading. (filename) is in platform-dependent notation. The |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
494 |
* file pointer should be positioned on the first byte of the file. |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
495 |
* |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
496 |
* The return value will be some platform-specific datatype that is opaque to |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
497 |
* the caller; it could be a (FILE *) under Unix, or a (HANDLE *) under win32. |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
498 |
* |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
499 |
* The same file can be opened for read multiple times, and each should have |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
500 |
* a unique file handle; this is frequently employed to prevent race |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
501 |
* conditions in the archivers. |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
502 |
* |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
503 |
* Call __PHYSFS_setError() and return (NULL) if the file can't be opened. |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
504 |
*/ |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
505 |
void *__PHYSFS_platformOpenRead(const char *filename); |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
506 |
|
240
052041af9001
Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents:
172
diff
changeset
|
507 |
|
132
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
508 |
/* |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
509 |
* Open a file for writing. (filename) is in platform-dependent notation. If |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
510 |
* the file exists, it should be truncated to zero bytes, and if it doesn't |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
511 |
* exist, it should be created as a zero-byte file. The file pointer should |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
512 |
* be positioned on the first byte of the file. |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
513 |
* |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
514 |
* The return value will be some platform-specific datatype that is opaque to |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
515 |
* the caller; it could be a (FILE *) under Unix, or a (HANDLE *) under win32, |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
516 |
* etc. |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
517 |
* |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
518 |
* Opening a file for write multiple times has undefined results. |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
519 |
* |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
520 |
* Call __PHYSFS_setError() and return (NULL) if the file can't be opened. |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
521 |
*/ |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
522 |
void *__PHYSFS_platformOpenWrite(const char *filename); |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
523 |
|
240
052041af9001
Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents:
172
diff
changeset
|
524 |
|
132
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
525 |
/* |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
526 |
* Open a file for appending. (filename) is in platform-dependent notation. If |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
527 |
* the file exists, the file pointer should be place just past the end of the |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
528 |
* file, so that the first write will be one byte after the current end of |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
529 |
* the file. If the file doesn't exist, it should be created as a zero-byte |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
530 |
* file. The file pointer should be positioned on the first byte of the file. |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
531 |
* |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
532 |
* The return value will be some platform-specific datatype that is opaque to |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
533 |
* the caller; it could be a (FILE *) under Unix, or a (HANDLE *) under win32, |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
534 |
* etc. |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
535 |
* |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
536 |
* Opening a file for append multiple times has undefined results. |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
537 |
* |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
538 |
* Call __PHYSFS_setError() and return (NULL) if the file can't be opened. |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
539 |
*/ |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
540 |
void *__PHYSFS_platformOpenAppend(const char *filename); |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
541 |
|
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
542 |
/* |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
543 |
* Read more data from a platform-specific file handle. (opaque) should be |
1098
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1097
diff
changeset
|
544 |
* cast to whatever data type your platform uses. Read a maximum of (len) |
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1097
diff
changeset
|
545 |
* 8-bit bytes to the area pointed to by (buf). If there isn't enough data |
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1097
diff
changeset
|
546 |
* available, return the number of bytes read, and position the file pointer |
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1097
diff
changeset
|
547 |
* immediately after those bytes. |
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1097
diff
changeset
|
548 |
* On success, return (len) and position the file pointer immediately past |
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1097
diff
changeset
|
549 |
* the end of the last read byte. Return (-1) if there is a catastrophic |
132
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
550 |
* error, and call __PHYSFS_setError() to describe the problem; the file |
1098
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1097
diff
changeset
|
551 |
* pointer should not move in such a case. A partial read is success; only |
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1097
diff
changeset
|
552 |
* return (-1) on total failure; presumably, the next read call after a |
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1097
diff
changeset
|
553 |
* partial read will fail as such. |
132
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
554 |
*/ |
1098
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1097
diff
changeset
|
555 |
PHYSFS_sint64 __PHYSFS_platformRead(void *opaque, void *buf, PHYSFS_uint64 len); |
132
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
556 |
|
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
557 |
/* |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
558 |
* Write more data to a platform-specific file handle. (opaque) should be |
1098
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1097
diff
changeset
|
559 |
* cast to whatever data type your platform uses. Write a maximum of (len) |
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1097
diff
changeset
|
560 |
* 8-bit bytes from the area pointed to by (buffer). If there is a problem, |
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1097
diff
changeset
|
561 |
* return the number of bytes written, and position the file pointer |
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1097
diff
changeset
|
562 |
* immediately after those bytes. Return (-1) if there is a catastrophic |
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1097
diff
changeset
|
563 |
* error, and call __PHYSFS_setError() to describe the problem; the file |
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1097
diff
changeset
|
564 |
* pointer should not move in such a case. A partial write is success; only |
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1097
diff
changeset
|
565 |
* return (-1) on total failure; presumably, the next write call after a |
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1097
diff
changeset
|
566 |
* partial write will fail as such. |
132
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
567 |
*/ |
134 | 568 |
PHYSFS_sint64 __PHYSFS_platformWrite(void *opaque, const void *buffer, |
1098
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1097
diff
changeset
|
569 |
PHYSFS_uint64 len); |
132
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
570 |
|
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
571 |
/* |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
572 |
* Set the file pointer to a new position. (opaque) should be cast to |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
573 |
* whatever data type your platform uses. (pos) specifies the number |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
574 |
* of 8-bit bytes to seek to from the start of the file. Seeking past the |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
575 |
* end of the file is an error condition, and you should check for it. |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
576 |
* |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
577 |
* Not all file types can seek; this is to be expected by the caller. |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
578 |
* |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
579 |
* On error, call __PHYSFS_setError() and return zero. On success, return |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
580 |
* a non-zero value. |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
581 |
*/ |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
582 |
int __PHYSFS_platformSeek(void *opaque, PHYSFS_uint64 pos); |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
583 |
|
240
052041af9001
Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents:
172
diff
changeset
|
584 |
|
132
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
585 |
/* |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
586 |
* Get the file pointer's position, in an 8-bit byte offset from the start of |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
587 |
* the file. (opaque) should be cast to whatever data type your platform |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
588 |
* uses. |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
589 |
* |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
590 |
* Not all file types can "tell"; this is to be expected by the caller. |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
591 |
* |
1180
b463fbb66af9
Corrected __PHYSFS_platformTell()'s return value to be correct.
Ryan C. Gordon <icculus@icculus.org>
parents:
1176
diff
changeset
|
592 |
* On error, call __PHYSFS_setError() and return -1. On success, return >= 0. |
132
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
593 |
*/ |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
594 |
PHYSFS_sint64 __PHYSFS_platformTell(void *opaque); |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
595 |
|
240
052041af9001
Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents:
172
diff
changeset
|
596 |
|
132
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
597 |
/* |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
598 |
* Determine the current size of a file, in 8-bit bytes, from an open file. |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
599 |
* |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
600 |
* The caller expects that this information may not be available for all |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
601 |
* file types on all platforms. |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
602 |
* |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
603 |
* Return -1 if you can't do it, and call __PHYSFS_setError(). Otherwise, |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
604 |
* return the file length in 8-bit bytes. |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
605 |
*/ |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
606 |
PHYSFS_sint64 __PHYSFS_platformFileLength(void *handle); |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
607 |
|
1054
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
608 |
|
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
609 |
/* |
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
610 |
* !!! FIXME: comment me. |
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
611 |
*/ |
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
612 |
int __PHYSFS_platformStat(const char *fn, int *exists, PHYSFS_Stat *stat); |
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
613 |
|
132
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
614 |
/* |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
615 |
* Flush any pending writes to disk. (opaque) should be cast to whatever data |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
616 |
* type your platform uses. Be sure to check for errors; the caller expects |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
617 |
* that this function can fail if there was a flushing error, etc. |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
618 |
* |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
619 |
* Return zero on failure, non-zero on success. |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
620 |
*/ |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
621 |
int __PHYSFS_platformFlush(void *opaque); |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
622 |
|
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
623 |
/* |
1118
2e09fc635fdd
Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents:
1115
diff
changeset
|
624 |
* Close file and deallocate resources. (opaque) should be cast to whatever |
2e09fc635fdd
Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents:
1115
diff
changeset
|
625 |
* data type your platform uses. This should close the file in any scenario: |
2e09fc635fdd
Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents:
1115
diff
changeset
|
626 |
* flushing is a separate function call, and this function should never fail. |
132
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
627 |
* |
1118
2e09fc635fdd
Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents:
1115
diff
changeset
|
628 |
* You should clean up all resources associated with (opaque); the pointer |
2e09fc635fdd
Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents:
1115
diff
changeset
|
629 |
* will be considered invalid after this call. |
132
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
630 |
*/ |
1118
2e09fc635fdd
Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents:
1115
diff
changeset
|
631 |
void __PHYSFS_platformClose(void *opaque); |
132
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
632 |
|
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
633 |
/* |
657
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
634 |
* Platform implementation of PHYSFS_getCdRomDirsCallback()... |
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
635 |
* CD directories are discovered and reported to the callback one at a time. |
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
636 |
* Pointers passed to the callback are assumed to be invalid to the |
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
637 |
* application after the callback returns, so you can free them or whatever. |
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
638 |
* Callback does not assume results will be sorted in any meaningful way. |
9 | 639 |
*/ |
657
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
640 |
void __PHYSFS_platformDetectAvailableCDs(PHYSFS_StringCallback cb, void *data); |
9 | 641 |
|
642 |
/* |
|
643 |
* Calculate the base dir, if your platform needs special consideration. |
|
644 |
* Just return NULL if the standard routines will suffice. (see |
|
645 |
* calculateBaseDir() in physfs.c ...) |
|
1214 | 646 |
* Caller will allocator.Free() the retval if it's not NULL. |
9 | 647 |
*/ |
23
bd6ba9c8717c
Initial debugging: dropped PhysicsFS routines into the Build engine,
Ryan C. Gordon <icculus@icculus.org>
parents:
22
diff
changeset
|
648 |
char *__PHYSFS_platformCalcBaseDir(const char *argv0); |
9 | 649 |
|
650 |
/* |
|
651 |
* Get the platform-specific user dir. |
|
1214 | 652 |
* Caller will allocator.Free() the retval if it's not NULL. If it's NULL, |
653 |
* the userdir will default to basedir/username. |
|
9 | 654 |
*/ |
1248
632895970ed6
Cleaned up some FIXMEs.
Ryan C. Gordon <icculus@icculus.org>
parents:
1246
diff
changeset
|
655 |
char *__PHYSFS_platformCalcUserDir(void); |
9 | 656 |
|
1242
1e6db80d2393
Added PHYSFS_getPrefDir().
Ryan C. Gordon <icculus@icculus.org>
parents:
1240
diff
changeset
|
657 |
|
1e6db80d2393
Added PHYSFS_getPrefDir().
Ryan C. Gordon <icculus@icculus.org>
parents:
1240
diff
changeset
|
658 |
/* This is the cached version from PHYSFS_init(). This is a fast call. */ |
1e6db80d2393
Added PHYSFS_getPrefDir().
Ryan C. Gordon <icculus@icculus.org>
parents:
1240
diff
changeset
|
659 |
const char *__PHYSFS_getUserDir(void); /* not deprecated internal version. */ |
1e6db80d2393
Added PHYSFS_getPrefDir().
Ryan C. Gordon <icculus@icculus.org>
parents:
1240
diff
changeset
|
660 |
|
1e6db80d2393
Added PHYSFS_getPrefDir().
Ryan C. Gordon <icculus@icculus.org>
parents:
1240
diff
changeset
|
661 |
/* |
1246
4fa9fe3e0b52
Make sure the prefdir has a final dirsep on it.
Ryan C. Gordon <icculus@icculus.org>
parents:
1242
diff
changeset
|
662 |
* Get the platform-specific pref dir. You must make sure the string ends |
4fa9fe3e0b52
Make sure the prefdir has a final dirsep on it.
Ryan C. Gordon <icculus@icculus.org>
parents:
1242
diff
changeset
|
663 |
* with a dir separator. |
4fa9fe3e0b52
Make sure the prefdir has a final dirsep on it.
Ryan C. Gordon <icculus@icculus.org>
parents:
1242
diff
changeset
|
664 |
* Caller will allocator.Free() the retval if it's not NULL. If it's NULL, |
1242
1e6db80d2393
Added PHYSFS_getPrefDir().
Ryan C. Gordon <icculus@icculus.org>
parents:
1240
diff
changeset
|
665 |
* it's a total failure. Caller will make missing directories if necessary; |
1e6db80d2393
Added PHYSFS_getPrefDir().
Ryan C. Gordon <icculus@icculus.org>
parents:
1240
diff
changeset
|
666 |
* this just reports the final path. |
1e6db80d2393
Added PHYSFS_getPrefDir().
Ryan C. Gordon <icculus@icculus.org>
parents:
1240
diff
changeset
|
667 |
*/ |
1e6db80d2393
Added PHYSFS_getPrefDir().
Ryan C. Gordon <icculus@icculus.org>
parents:
1240
diff
changeset
|
668 |
char *__PHYSFS_platformCalcPrefDir(const char *org, const char *app); |
1e6db80d2393
Added PHYSFS_getPrefDir().
Ryan C. Gordon <icculus@icculus.org>
parents:
1240
diff
changeset
|
669 |
|
1e6db80d2393
Added PHYSFS_getPrefDir().
Ryan C. Gordon <icculus@icculus.org>
parents:
1240
diff
changeset
|
670 |
|
9 | 671 |
/* |
1012
f254870dd7dd
Attempt to clean up the thread ID mess in platform_unix ...
Ryan C. Gordon <icculus@icculus.org>
parents:
984
diff
changeset
|
672 |
* Return a pointer that uniquely identifies the current thread. |
f254870dd7dd
Attempt to clean up the thread ID mess in platform_unix ...
Ryan C. Gordon <icculus@icculus.org>
parents:
984
diff
changeset
|
673 |
* On a platform without threading, (0x1) will suffice. These numbers are |
9 | 674 |
* arbitrary; the only requirement is that no two threads have the same |
1012
f254870dd7dd
Attempt to clean up the thread ID mess in platform_unix ...
Ryan C. Gordon <icculus@icculus.org>
parents:
984
diff
changeset
|
675 |
* pointer. |
9 | 676 |
*/ |
1012
f254870dd7dd
Attempt to clean up the thread ID mess in platform_unix ...
Ryan C. Gordon <icculus@icculus.org>
parents:
984
diff
changeset
|
677 |
void *__PHYSFS_platformGetThreadID(void); |
9 | 678 |
|
240
052041af9001
Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents:
172
diff
changeset
|
679 |
|
20
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
680 |
/* |
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
681 |
* Enumerate a directory of files. This follows the rules for the |
650
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
682 |
* PHYSFS_Archiver->enumerateFiles() method (see above), except that the |
20
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
683 |
* (dirName) that is passed to this function is converted to |
650
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
684 |
* platform-DEPENDENT notation by the caller. The PHYSFS_Archiver version |
41
ff60d39d0862
Architecture adjustment for enumerating files with regards to whether
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
685 |
* 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
|
686 |
* 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
|
687 |
*/ |
657
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
688 |
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:
650
diff
changeset
|
689 |
int omitSymLinks, |
754
e7cd7411eadf
API BREAKAGE: Changed PHYSFS_enumerateFilesCallback() to pass the originally
Ryan C. Gordon <icculus@icculus.org>
parents:
747
diff
changeset
|
690 |
PHYSFS_EnumFilesCallback callback, |
e7cd7411eadf
API BREAKAGE: Changed PHYSFS_enumerateFilesCallback() to pass the originally
Ryan C. Gordon <icculus@icculus.org>
parents:
747
diff
changeset
|
691 |
const char *origdir, |
657
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
692 |
void *callbackdata); |
20
efdde0d21521
Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents:
19
diff
changeset
|
693 |
|
39
bc29e1ee7ef6
Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents:
30
diff
changeset
|
694 |
/* |
69
546a95cc5591
Updates, corrections and enhancements to get this ported to win32.
Ryan C. Gordon <icculus@icculus.org>
parents:
49
diff
changeset
|
695 |
* 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
|
696 |
* 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
|
697 |
* 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
|
698 |
*/ |
546a95cc5591
Updates, corrections and enhancements to get this ported to win32.
Ryan C. Gordon <icculus@icculus.org>
parents:
49
diff
changeset
|
699 |
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
|
700 |
|
240
052041af9001
Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents:
172
diff
changeset
|
701 |
|
137
66bddb94b6e0
Abstracted file deletion, so we don't rely on C library for it anymore.
Ryan C. Gordon <icculus@icculus.org>
parents:
134
diff
changeset
|
702 |
/* |
66bddb94b6e0
Abstracted file deletion, so we don't rely on C library for it anymore.
Ryan C. Gordon <icculus@icculus.org>
parents:
134
diff
changeset
|
703 |
* Remove a file or directory entry in the actual filesystem. (path) is |
66bddb94b6e0
Abstracted file deletion, so we don't rely on C library for it anymore.
Ryan C. Gordon <icculus@icculus.org>
parents:
134
diff
changeset
|
704 |
* specified in platform-dependent notation. Note that this deletes files |
66bddb94b6e0
Abstracted file deletion, so we don't rely on C library for it anymore.
Ryan C. Gordon <icculus@icculus.org>
parents:
134
diff
changeset
|
705 |
* _and_ directories, so you might need to do some determination. |
66bddb94b6e0
Abstracted file deletion, so we don't rely on C library for it anymore.
Ryan C. Gordon <icculus@icculus.org>
parents:
134
diff
changeset
|
706 |
* Non-empty directories should report an error and not delete themselves |
66bddb94b6e0
Abstracted file deletion, so we don't rely on C library for it anymore.
Ryan C. Gordon <icculus@icculus.org>
parents:
134
diff
changeset
|
707 |
* or their contents. |
66bddb94b6e0
Abstracted file deletion, so we don't rely on C library for it anymore.
Ryan C. Gordon <icculus@icculus.org>
parents:
134
diff
changeset
|
708 |
* |
66bddb94b6e0
Abstracted file deletion, so we don't rely on C library for it anymore.
Ryan C. Gordon <icculus@icculus.org>
parents:
134
diff
changeset
|
709 |
* Deleting a symlink should remove the link, not what it points to. |
66bddb94b6e0
Abstracted file deletion, so we don't rely on C library for it anymore.
Ryan C. Gordon <icculus@icculus.org>
parents:
134
diff
changeset
|
710 |
* |
66bddb94b6e0
Abstracted file deletion, so we don't rely on C library for it anymore.
Ryan C. Gordon <icculus@icculus.org>
parents:
134
diff
changeset
|
711 |
* On error, return zero and set the error message. Return non-zero on success. |
66bddb94b6e0
Abstracted file deletion, so we don't rely on C library for it anymore.
Ryan C. Gordon <icculus@icculus.org>
parents:
134
diff
changeset
|
712 |
*/ |
66bddb94b6e0
Abstracted file deletion, so we don't rely on C library for it anymore.
Ryan C. Gordon <icculus@icculus.org>
parents:
134
diff
changeset
|
713 |
int __PHYSFS_platformDelete(const char *path); |
66bddb94b6e0
Abstracted file deletion, so we don't rely on C library for it anymore.
Ryan C. Gordon <icculus@icculus.org>
parents:
134
diff
changeset
|
714 |
|
66bddb94b6e0
Abstracted file deletion, so we don't rely on C library for it anymore.
Ryan C. Gordon <icculus@icculus.org>
parents:
134
diff
changeset
|
715 |
|
145
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
716 |
/* |
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
717 |
* Create a platform-specific mutex. This can be whatever datatype your |
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
718 |
* platform uses for mutexes, but it is cast to a (void *) for abstractness. |
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
719 |
* |
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
720 |
* Return (NULL) if you couldn't create one. Systems without threads can |
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
721 |
* return any arbitrary non-NULL value. |
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
722 |
*/ |
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
723 |
void *__PHYSFS_platformCreateMutex(void); |
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
724 |
|
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
725 |
/* |
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
726 |
* Destroy a platform-specific mutex, and clean up any resources associated |
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
727 |
* with it. (mutex) is a value previously returned by |
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
728 |
* __PHYSFS_platformCreateMutex(). This can be a no-op on single-threaded |
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
729 |
* platforms. |
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
730 |
*/ |
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
731 |
void __PHYSFS_platformDestroyMutex(void *mutex); |
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
732 |
|
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
733 |
/* |
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
734 |
* Grab possession of a platform-specific mutex. Mutexes should be recursive; |
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
735 |
* that is, the same thread should be able to call this function multiple |
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
736 |
* times in a row without causing a deadlock. This function should block |
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
737 |
* until a thread can gain possession of the mutex. |
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
738 |
* |
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
739 |
* Return non-zero if the mutex was grabbed, zero if there was an |
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
740 |
* unrecoverable problem grabbing it (this should not be a matter of |
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
741 |
* timing out! We're talking major system errors; block until the mutex |
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
742 |
* is available otherwise.) |
156
f45e26b5f398
Added warning about potential infinite recursion between setError and grabMutex.
Ryan C. Gordon <icculus@icculus.org>
parents:
150
diff
changeset
|
743 |
* |
f45e26b5f398
Added warning about potential infinite recursion between setError and grabMutex.
Ryan C. Gordon <icculus@icculus.org>
parents:
150
diff
changeset
|
744 |
* _DO NOT_ call __PHYSFS_setError() in here! Since setError calls this |
f45e26b5f398
Added warning about potential infinite recursion between setError and grabMutex.
Ryan C. Gordon <icculus@icculus.org>
parents:
150
diff
changeset
|
745 |
* function, you'll cause an infinite recursion. This means you can't |
f45e26b5f398
Added warning about potential infinite recursion between setError and grabMutex.
Ryan C. Gordon <icculus@icculus.org>
parents:
150
diff
changeset
|
746 |
* use the BAIL_*MACRO* macros, either. |
145
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
747 |
*/ |
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
748 |
int __PHYSFS_platformGrabMutex(void *mutex); |
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
749 |
|
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
750 |
/* |
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
751 |
* Relinquish possession of the mutex when this method has been called |
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
752 |
* once for each time that platformGrabMutex was called. Once possession has |
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
753 |
* been released, the next thread in line to grab the mutex (if any) may |
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
754 |
* proceed. |
156
f45e26b5f398
Added warning about potential infinite recursion between setError and grabMutex.
Ryan C. Gordon <icculus@icculus.org>
parents:
150
diff
changeset
|
755 |
* |
f45e26b5f398
Added warning about potential infinite recursion between setError and grabMutex.
Ryan C. Gordon <icculus@icculus.org>
parents:
150
diff
changeset
|
756 |
* _DO NOT_ call __PHYSFS_setError() in here! Since setError calls this |
f45e26b5f398
Added warning about potential infinite recursion between setError and grabMutex.
Ryan C. Gordon <icculus@icculus.org>
parents:
150
diff
changeset
|
757 |
* function, you'll cause an infinite recursion. This means you can't |
f45e26b5f398
Added warning about potential infinite recursion between setError and grabMutex.
Ryan C. Gordon <icculus@icculus.org>
parents:
150
diff
changeset
|
758 |
* use the BAIL_*MACRO* macros, either. |
145
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
759 |
*/ |
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
760 |
void __PHYSFS_platformReleaseMutex(void *mutex); |
d6385584f6c4
First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
761 |
|
644
1cb5533d369c
Initial structure for replacable allocator work.
Ryan C. Gordon <icculus@icculus.org>
parents:
641
diff
changeset
|
762 |
/* |
845
3f150ffcf50c
Since all the platform layers were using the same cut-and-paste of the
Ryan C. Gordon <icculus@icculus.org>
parents:
844
diff
changeset
|
763 |
* Called at the start of PHYSFS_init() to prepare the allocator, if the user |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
644
diff
changeset
|
764 |
* hasn't selected their own allocator via PHYSFS_setAllocator(). |
845
3f150ffcf50c
Since all the platform layers were using the same cut-and-paste of the
Ryan C. Gordon <icculus@icculus.org>
parents:
844
diff
changeset
|
765 |
* If the platform has a custom allocator, it should fill in the fields of |
3f150ffcf50c
Since all the platform layers were using the same cut-and-paste of the
Ryan C. Gordon <icculus@icculus.org>
parents:
844
diff
changeset
|
766 |
* (a) with the proper function pointers and return non-zero. |
3f150ffcf50c
Since all the platform layers were using the same cut-and-paste of the
Ryan C. Gordon <icculus@icculus.org>
parents:
844
diff
changeset
|
767 |
* If the platform just wants to use malloc()/free()/etc, return zero |
3f150ffcf50c
Since all the platform layers were using the same cut-and-paste of the
Ryan C. Gordon <icculus@icculus.org>
parents:
844
diff
changeset
|
768 |
* immediately and the higher level will handle it. The Init and Deinit |
3f150ffcf50c
Since all the platform layers were using the same cut-and-paste of the
Ryan C. Gordon <icculus@icculus.org>
parents:
844
diff
changeset
|
769 |
* fields of (a) are optional...set them to NULL if you don't need them. |
3f150ffcf50c
Since all the platform layers were using the same cut-and-paste of the
Ryan C. Gordon <icculus@icculus.org>
parents:
844
diff
changeset
|
770 |
* Everything else must be implemented. All rules follow those for |
3f150ffcf50c
Since all the platform layers were using the same cut-and-paste of the
Ryan C. Gordon <icculus@icculus.org>
parents:
844
diff
changeset
|
771 |
* PHYSFS_setAllocator(). If Init isn't NULL, it will be called shortly |
3f150ffcf50c
Since all the platform layers were using the same cut-and-paste of the
Ryan C. Gordon <icculus@icculus.org>
parents:
844
diff
changeset
|
772 |
* after this function returns non-zero. |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
644
diff
changeset
|
773 |
*/ |
845
3f150ffcf50c
Since all the platform layers were using the same cut-and-paste of the
Ryan C. Gordon <icculus@icculus.org>
parents:
844
diff
changeset
|
774 |
int __PHYSFS_platformSetDefaultAllocator(PHYSFS_Allocator *a); |
644
1cb5533d369c
Initial structure for replacable allocator work.
Ryan C. Gordon <icculus@icculus.org>
parents:
641
diff
changeset
|
775 |
|
9 | 776 |
#ifdef __cplusplus |
132
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
130
diff
changeset
|
777 |
} |
9 | 778 |
#endif |
779 |
||
780 |
#endif |
|
781 |
||
782 |
/* end of physfs_internal.h ... */ |
|
783 |