author | Ryan C. Gordon <icculus@icculus.org> |
Fri, 12 Apr 2002 05:53:12 +0000 | |
changeset 194 | 09c353d30cd4 |
parent 178 | e71b33bc440f |
child 203 | 7e0acf501377 |
permissions | -rw-r--r-- |
1 | 1 |
/** |
2 |
* PhysicsFS; a portable, flexible file i/o abstraction. |
|
3 |
* |
|
4 |
* This API gives you access to a system file system in ways superior to the |
|
5 |
* stdio or system i/o calls. The brief benefits: |
|
6 |
* |
|
7 |
* - It's portable. |
|
2
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
8 |
* - It's safe. No file access is permitted outside the specified dirs. |
1 | 9 |
* - It's flexible. Archives (.ZIP files) can be used transparently as |
10 |
* directory structures. |
|
11 |
* |
|
12 |
* This system is largely inspired by Quake 3's PK3 files and the related |
|
2
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
13 |
* fs_* cvars. If you've ever tinkered with these, then this API will be |
1 | 14 |
* familiar to you. |
15 |
* |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
16 |
* With PhysicsFS, you have a single writing directory and multiple |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
17 |
* directories (the "search path") for reading. You can think of this as a |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
18 |
* filesystem within a filesystem. If (on Windows) you were to set the |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
19 |
* writing directory to "C:\MyGame\MyWritingDirectory", then no PHYSFS calls |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
20 |
* could touch anything above this directory, including the "C:\MyGame" and |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
21 |
* "C:\" directories. This prevents an application's internal scripting |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
22 |
* language from piddling over c:\config.sys, for example. If you'd rather |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
23 |
* give PHYSFS full access to the system's REAL file system, set the writing |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
24 |
* dir to "C:\", but that's generally A Bad Thing for several reasons. |
1 | 25 |
* |
26 |
* Drive letters are hidden in PhysicsFS once you set up your initial paths. |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
27 |
* The search path creates a single, hierarchical directory structure. |
1 | 28 |
* Not only does this lend itself well to general abstraction with archives, |
29 |
* it also gives better support to operating systems like MacOS and Unix. |
|
30 |
* Generally speaking, you shouldn't ever hardcode a drive letter; not only |
|
31 |
* does this hurt portability to non-Microsoft OSes, but it limits your win32 |
|
32 |
* users to a single drive, too. Use the PhysicsFS abstraction functions and |
|
33 |
* allow user-defined configuration options, too. When opening a file, you |
|
34 |
* specify it like it was on a Unix filesystem: if you want to write to |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
35 |
* "C:\MyGame\MyConfigFiles\game.cfg", then you might set the write dir to |
1 | 36 |
* "C:\MyGame" and then open "MyConfigFiles/game.cfg". This gives an |
2
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
37 |
* abstraction across all platforms. Specifying a file in this way is termed |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
38 |
* "platform-independent notation" in this documentation. Specifying a |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
39 |
* a filename in a form such as "C:\mydir\myfile" or |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
40 |
* "MacOS hard drive:My Directory:My File" is termed "platform-dependent |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
41 |
* notation". The only time you use platform-dependent notation is when |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
42 |
* setting up your write directory and search path; after that, all file |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
43 |
* access into those directories are done with platform-independent notation. |
1 | 44 |
* |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
45 |
* All files opened for writing are opened in relation to the write directory, |
1 | 46 |
* which is the root of the writable filesystem. When opening a file for |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
47 |
* reading, PhysicsFS goes through the search path. This is NOT the |
1 | 48 |
* same thing as the PATH environment variable. An application using |
49 |
* PhysicsFS specifies directories to be searched which may be actual |
|
50 |
* directories, or archive files that contain files and subdirectories of |
|
51 |
* their own. See the end of these docs for currently supported archive |
|
52 |
* formats. |
|
53 |
* |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
54 |
* Once the search path is defined, you may open files for reading. If you've |
1 | 55 |
* got the following search path defined (to use a win32 example again): |
56 |
* |
|
57 |
* C:\mygame |
|
58 |
* C:\mygame\myuserfiles |
|
59 |
* D:\mygamescdromdatafiles |
|
60 |
* C:\mygame\installeddatafiles.zip |
|
61 |
* |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
62 |
* Then a call to PHYSFS_openRead("textfiles/myfile.txt") (note the directory |
2
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
63 |
* separator, lack of drive letter, and lack of dir separator at the start of |
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
64 |
* the string; this is platform-independent notation) will check for |
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
65 |
* C:\mygame\textfiles\myfile.txt, then |
1 | 66 |
* C:\mygame\myuserfiles\textfiles\myfile.txt, then |
67 |
* D:\mygamescdromdatafiles\textfiles\myfile.txt, then, finally, for |
|
68 |
* textfiles\myfile.txt inside of C:\mygame\installeddatafiles.zip. Remember |
|
69 |
* that most archive types and platform filesystems store their filenames in |
|
2
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
70 |
* a case-sensitive manner, so you should be careful to specify it correctly. |
1 | 71 |
* |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
72 |
* Files opened through PhysicsFS may NOT contain "." or ".." or ":" as dir |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
73 |
* elements. Not only are these meaningless on MacOS and/or Unix, they are a |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
74 |
* security hole. Also, symbolic links (which can be found in some archive |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
75 |
* types and directly in the filesystem on Unix platforms) are NOT followed |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
76 |
* until you call PHYSFS_permitSymbolicLinks(). That's left to your own |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
77 |
* discretion, as following a symlink can allow for access outside the write |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
78 |
* dir and search paths. There is no mechanism for creating new symlinks in |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
79 |
* PhysicsFS. |
1 | 80 |
* |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
81 |
* The write dir is not included in the search path unless you specifically |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
82 |
* add it. While you CAN change the write dir as many times as you like, |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
83 |
* you should probably set it once and stick to it. Remember that your |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
84 |
* program will not have permission to write in every directory on Unix and |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
85 |
* NT systems. |
1 | 86 |
* |
87 |
* All files are opened in binary mode; there is no endline conversion for |
|
88 |
* textfiles. Other than that, PhysicsFS has some convenience functions for |
|
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
89 |
* platform-independence. There is a function to tell you the current |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
90 |
* platform's dir separator ("\\" on windows, "/" on Unix, ":" on MacOS), |
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
91 |
* which is needed only to set up your search/write paths. There is a |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
92 |
* function to tell you what CD-ROM drives contain accessible discs, and a |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
93 |
* function to recommend a good search path, etc. |
1 | 94 |
* |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
95 |
* A recommended order for the search path is the write dir, then the base dir, |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
96 |
* then the cdrom dir, then any archives discovered. Quake 3 does something |
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
97 |
* like this, but moves the archives to the start of the search path. Build |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
98 |
* Engine games, like Duke Nukem 3D and Blood, place the archives last, and |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
99 |
* use the base dir for both searching and writing. There is a helper |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
100 |
* function (PHYSFS_setSaneConfig()) that puts together a basic configuration |
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
101 |
* for you, based on a few parameters. Also see the comments on |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
102 |
* PHYSFS_getBaseDir(), and PHYSFS_getUserDir() for info on what those |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
103 |
* are and how they can help you determine an optimal search path. |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
104 |
* |
147
5e1eda65ceb3
Updated comment on thread safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
105 |
* PhysicsFS is mostly thread safe. The error messages returned by |
5e1eda65ceb3
Updated comment on thread safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
106 |
* PHYSFS_getLastError are unique by thread, and library-state-setting |
5e1eda65ceb3
Updated comment on thread safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
107 |
* functions are mutex'd. For efficiency, individual file accesses are |
5e1eda65ceb3
Updated comment on thread safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
108 |
* not locked, so you can not safely read/write/seek/close/etc the same |
5e1eda65ceb3
Updated comment on thread safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
109 |
* file from two threads at the same time. Other race conditions are bugs |
5e1eda65ceb3
Updated comment on thread safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
110 |
* that should be reported/patched. |
1 | 111 |
* |
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
112 |
* While you CAN use stdio/syscall file access in a program that has PHYSFS_* |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
113 |
* calls, doing so is not recommended, and you can not use system |
147
5e1eda65ceb3
Updated comment on thread safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
114 |
* filehandles with PhysicsFS and vice versa. |
1 | 115 |
* |
116 |
* Note that archives need not be named as such: if you have a ZIP file and |
|
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
117 |
* rename it with a .PKG extension, the file will still be recognized as a |
1 | 118 |
* ZIP archive by PhysicsFS; the file's contents are used to determine its |
119 |
* type. |
|
120 |
* |
|
121 |
* Currently supported archive types: |
|
122 |
* - .ZIP (pkZip/WinZip/Info-ZIP compatible) |
|
123 |
* |
|
124 |
* Please see the file LICENSE in the source's root directory. |
|
125 |
* |
|
126 |
* This file written by Ryan C. Gordon. |
|
127 |
*/ |
|
128 |
||
129 |
#ifndef _INCLUDE_PHYSFS_H_ |
|
130 |
#define _INCLUDE_PHYSFS_H_ |
|
131 |
||
132 |
#ifdef __cplusplus |
|
133 |
extern "C" { |
|
134 |
#endif |
|
135 |
||
74
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
136 |
#if (defined _MSC_VER) |
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
137 |
#define __EXPORT__ __declspec(dllexport) |
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
138 |
#else |
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
139 |
#define __EXPORT__ |
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
140 |
#endif |
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
141 |
|
132
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
142 |
typedef unsigned char PHYSFS_uint8; |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
143 |
typedef signed char PHYSFS_sint8; |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
144 |
typedef unsigned short PHYSFS_uint16; |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
145 |
typedef signed short PHYSFS_sint16; |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
146 |
typedef unsigned int PHYSFS_uint32; |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
147 |
typedef signed int PHYSFS_sint32; |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
148 |
|
194
09c353d30cd4
Patches for correctness and cleaner win32 support.
Ryan C. Gordon <icculus@icculus.org>
parents:
178
diff
changeset
|
149 |
#if (defined PHYSFS_NO_64BIT_SUPPORT) /* oh well. */ |
132
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
150 |
typedef PHYSFS_uint32 PHYSFS_uint64; |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
151 |
typedef PHYSFS_sint32 PHYSFS_sint64; |
194
09c353d30cd4
Patches for correctness and cleaner win32 support.
Ryan C. Gordon <icculus@icculus.org>
parents:
178
diff
changeset
|
152 |
#elif (defined _MSC_VER) |
09c353d30cd4
Patches for correctness and cleaner win32 support.
Ryan C. Gordon <icculus@icculus.org>
parents:
178
diff
changeset
|
153 |
typedef signed __int64 PHYSFS_sint64; |
09c353d30cd4
Patches for correctness and cleaner win32 support.
Ryan C. Gordon <icculus@icculus.org>
parents:
178
diff
changeset
|
154 |
typedef unsigned __int64 PHYSFS_uint64; |
132
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
155 |
#else |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
156 |
typedef unsigned long long PHYSFS_uint64; |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
157 |
typedef signed long long PHYSFS_sint64; |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
158 |
#endif |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
159 |
|
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
160 |
/* Make sure the types really have the right sizes */ |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
161 |
#define PHYSFS_COMPILE_TIME_ASSERT(name, x) \ |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
162 |
typedef int PHYSFS_dummy_ ## name[(x) * 2 - 1] |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
163 |
|
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
164 |
PHYSFS_COMPILE_TIME_ASSERT(uint8, sizeof(PHYSFS_uint8) == 1); |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
165 |
PHYSFS_COMPILE_TIME_ASSERT(sint8, sizeof(PHYSFS_sint8) == 1); |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
166 |
PHYSFS_COMPILE_TIME_ASSERT(uint16, sizeof(PHYSFS_uint16) == 2); |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
167 |
PHYSFS_COMPILE_TIME_ASSERT(sint16, sizeof(PHYSFS_sint16) == 2); |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
168 |
PHYSFS_COMPILE_TIME_ASSERT(uint32, sizeof(PHYSFS_uint32) == 4); |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
169 |
PHYSFS_COMPILE_TIME_ASSERT(sint32, sizeof(PHYSFS_sint32) == 4); |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
170 |
|
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
171 |
#ifndef PHYSFS_NO_64BIT_SUPPORT |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
172 |
PHYSFS_COMPILE_TIME_ASSERT(uint64, sizeof(PHYSFS_uint64) == 8); |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
173 |
PHYSFS_COMPILE_TIME_ASSERT(sint64, sizeof(PHYSFS_sint64) == 8); |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
174 |
#endif |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
175 |
|
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
176 |
#undef PHYSFS_COMPILE_TIME_ASSERT |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
177 |
|
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
178 |
|
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
179 |
|
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
180 |
typedef struct __PHYSFS_FILE__ |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
181 |
{ |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
182 |
void *opaque; |
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
183 |
} PHYSFS_file; |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
184 |
|
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
185 |
typedef struct __PHYSFS_ARCHIVEINFO__ |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
186 |
{ |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
187 |
const char *extension; |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
188 |
const char *description; |
29
91b45664ec85
Added more fields to the ArchiveInfo struct: author and url.
Ryan C. Gordon <icculus@icculus.org>
parents:
28
diff
changeset
|
189 |
const char *author; |
91b45664ec85
Added more fields to the ArchiveInfo struct: author and url.
Ryan C. Gordon <icculus@icculus.org>
parents:
28
diff
changeset
|
190 |
const char *url; |
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
191 |
} PHYSFS_ArchiveInfo; |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
192 |
|
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
193 |
|
1 | 194 |
/* functions... */ |
195 |
||
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
196 |
typedef struct __PHYSFS_VERSION__ |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
197 |
{ |
132
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
198 |
PHYSFS_uint8 major; |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
199 |
PHYSFS_uint8 minor; |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
200 |
PHYSFS_uint8 patch; |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
201 |
} PHYSFS_Version; |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
202 |
|
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
203 |
#define PHYSFS_VER_MAJOR 0 |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
204 |
#define PHYSFS_VER_MINOR 1 |
99
5a5a0d60cbf1
Updated version from 0.1.3 to 0.1.4.
Ryan C. Gordon <icculus@icculus.org>
parents:
80
diff
changeset
|
205 |
#define PHYSFS_VER_PATCH 4 |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
206 |
|
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
207 |
#define PHYSFS_VERSION(x) { \ |
33
313a6bc49a46
Fixed bug in PHYSFS_VERSION macro.
Ryan C. Gordon <icculus@icculus.org>
parents:
29
diff
changeset
|
208 |
(x)->major = PHYSFS_VER_MAJOR; \ |
313a6bc49a46
Fixed bug in PHYSFS_VERSION macro.
Ryan C. Gordon <icculus@icculus.org>
parents:
29
diff
changeset
|
209 |
(x)->minor = PHYSFS_VER_MINOR; \ |
313a6bc49a46
Fixed bug in PHYSFS_VERSION macro.
Ryan C. Gordon <icculus@icculus.org>
parents:
29
diff
changeset
|
210 |
(x)->patch = PHYSFS_VER_PATCH; \ |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
211 |
} |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
212 |
|
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
213 |
/** |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
214 |
* Get the version of PhysicsFS that is linked against your program. If you |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
215 |
* are using a shared library (DLL) version of PhysFS, then it is possible |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
216 |
* that it will be different than the version you compiled against. |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
217 |
* |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
218 |
* This is a real function; the macro PHYSFS_VERSION tells you what version |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
219 |
* of PhysFS you compiled against: |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
220 |
* |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
221 |
* PHYSFS_Version compiled; |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
222 |
* PHYSFS_Version linked; |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
223 |
* |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
224 |
* PHYSFS_VERSION(&compiled); |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
225 |
* PHYSFS_getLinkedVersion(&linked); |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
226 |
* printf("We compiled against PhysFS version %d.%d.%d ...\n", |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
227 |
* compiled.major, compiled.minor, compiled.patch); |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
228 |
* printf("But we linked against PhysFS version %d.%d.%d.\n", |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
229 |
* linked.major, linked.minor, linked.patch); |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
230 |
* |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
231 |
* This function may be called safely at any time, even before PHYSFS_init(). |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
232 |
*/ |
74
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
233 |
__EXPORT__ void PHYSFS_getLinkedVersion(PHYSFS_Version *ver); |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
234 |
|
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
235 |
|
2
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
236 |
/** |
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
237 |
* Initialize PhysicsFS. This must be called before any other PhysicsFS |
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
238 |
* function. |
2
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
239 |
* |
23
bd6ba9c8717c
Initial debugging: dropped PhysicsFS routines into the Build engine,
Ryan C. Gordon <icculus@icculus.org>
parents:
15
diff
changeset
|
240 |
* This should be called prior to any attempts to change your process's |
bd6ba9c8717c
Initial debugging: dropped PhysicsFS routines into the Build engine,
Ryan C. Gordon <icculus@icculus.org>
parents:
15
diff
changeset
|
241 |
* current working directory. |
bd6ba9c8717c
Initial debugging: dropped PhysicsFS routines into the Build engine,
Ryan C. Gordon <icculus@icculus.org>
parents:
15
diff
changeset
|
242 |
* |
2
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
243 |
* @param argv0 the argv[0] string passed to your program's mainline. |
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
244 |
* @return nonzero on success, zero on error. Specifics of the error can be |
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
245 |
* gleaned from PHYSFS_getLastError(). |
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
246 |
*/ |
74
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
247 |
__EXPORT__ int PHYSFS_init(const char *argv0); |
2
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
248 |
|
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
249 |
|
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
250 |
/** |
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
251 |
* Shutdown PhysicsFS. This closes any files opened via PhysicsFS, blanks the |
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
252 |
* search/write paths, frees memory, and invalidates all of your handles. |
2
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
253 |
* |
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
254 |
* Note that this call can FAIL if there's a file open for writing that |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
255 |
* refuses to close (for example, the underlying operating system was |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
256 |
* buffering writes to network filesystem, and the fileserver has crashed, |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
257 |
* or a hard drive has failed, etc). It is usually best to close all write |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
258 |
* handles yourself before calling this function, so that you can gracefully |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
259 |
* handle a specific failure. |
2
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
260 |
* |
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
261 |
* Once successfully deinitialized, PHYSFS_init() can be called again to |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
262 |
* restart the subsystem. All defaults API states are restored at this |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
263 |
* point. |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
264 |
* |
2
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
265 |
* @return nonzero on success, zero on error. Specifics of the error can be |
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
266 |
* gleaned from PHYSFS_getLastError(). If failure, state of PhysFS is |
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
267 |
* undefined, and probably badly screwed up. |
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
268 |
*/ |
74
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
269 |
__EXPORT__ int PHYSFS_deinit(void); |
2
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
270 |
|
1 | 271 |
|
272 |
/** |
|
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
273 |
* Get a list of archive types supported by this implementation of PhysicFS. |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
274 |
* These are the file formats usable for search path entries. This is for |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
275 |
* informational purposes only. Note that the extension listed is merely |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
276 |
* convention: if we list "ZIP", you can open a PkZip-compatible archive |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
277 |
* with an extension of "XYZ", if you like. |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
278 |
* |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
279 |
* The returned value is an array of pointers to PHYSFS_ArchiveInfo structures, |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
280 |
* with a NULL entry to signify the end of the list: |
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
281 |
* |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
282 |
* PHYSFS_ArchiveInfo **i; |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
283 |
* |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
284 |
* for (i = PHYSFS_supportedArchiveTypes(); *i != NULL; i++) |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
285 |
* { |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
286 |
* printf("Supported archive: [%s], which is [%s].\n", |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
287 |
* i->extension, i->description); |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
288 |
* } |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
289 |
* |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
290 |
* The return values are pointers to static internal memory, and should |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
291 |
* be considered READ ONLY, and never freed. |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
292 |
* |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
293 |
* @return READ ONLY Null-terminated array of READ ONLY structures. |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
294 |
*/ |
74
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
295 |
__EXPORT__ const PHYSFS_ArchiveInfo **PHYSFS_supportedArchiveTypes(void); |
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
296 |
|
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
297 |
|
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
298 |
/** |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
299 |
* Certain PhysicsFS functions return lists of information that are |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
300 |
* dynamically allocated. Use this function to free those resources. |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
301 |
* |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
302 |
* @param list List of information specified as freeable by this function. |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
303 |
*/ |
128
31f754165105
Patched to fix a namespace issue.
Ryan C. Gordon <icculus@icculus.org>
parents:
126
diff
changeset
|
304 |
__EXPORT__ void PHYSFS_freeList(void *listVar); |
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
305 |
|
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
306 |
|
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
307 |
/** |
1 | 308 |
* Get the last PhysicsFS error message as a null-terminated string. |
309 |
* This will be NULL if there's been no error since the last call to this |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
310 |
* function. The pointer returned by this call points to an internal buffer. |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
311 |
* Each thread has a unique error state associated with it, but each time |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
312 |
* a new error message is set, it will overwrite the previous one associated |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
313 |
* with that thread. It is safe to call this function at anytime, even |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
314 |
* before PHYSFS_init(). |
1 | 315 |
* |
316 |
* @return READ ONLY string of last error message. |
|
317 |
*/ |
|
74
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
318 |
__EXPORT__ const char *PHYSFS_getLastError(void); |
1 | 319 |
|
320 |
||
321 |
/** |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
322 |
* Get a platform-dependent dir separator. This is "\\" on win32, "/" on Unix, |
1 | 323 |
* and ":" on MacOS. It may be more than one character, depending on the |
324 |
* platform, and your code should take that into account. Note that this is |
|
325 |
* only useful for setting up the search/write paths, since access into those |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
326 |
* dirs always use '/' (platform-independent notation) to separate |
2
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
327 |
* directories. This is also handy for getting platform-independent access |
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
328 |
* when using stdio calls. |
1 | 329 |
* |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
330 |
* @return READ ONLY null-terminated string of platform's dir separator. |
1 | 331 |
*/ |
74
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
332 |
__EXPORT__ const char *PHYSFS_getDirSeparator(void); |
1 | 333 |
|
334 |
||
335 |
/** |
|
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
336 |
* Enable symbolic links. Some physical filesystems and archives contain |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
337 |
* files that are just pointers to other files. On the physical filesystem, |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
338 |
* opening such a link will (transparently) open the file that is pointed to. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
339 |
* |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
340 |
* By default, PhysicsFS will check if a file is really a symlink during open |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
341 |
* calls and fail if it is. Otherwise, the link could take you outside the |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
342 |
* write and search paths, and compromise security. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
343 |
* |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
344 |
* If you want to take that risk, call this function with a non-zero parameter. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
345 |
* Note that this is more for sandboxing a program's scripting language, in |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
346 |
* case untrusted scripts try to compromise the system. Generally speaking, |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
347 |
* a user could very well have a legitimate reason to set up a symlink, so |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
348 |
* unless you feel there's a specific danger in allowing them, you should |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
349 |
* permit them. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
350 |
* |
39
bc29e1ee7ef6
Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents:
33
diff
changeset
|
351 |
* Symlinks are only explicitly checked when dealing with filenames |
bc29e1ee7ef6
Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents:
33
diff
changeset
|
352 |
* in platform-independent notation. That is, when setting up your |
bc29e1ee7ef6
Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents:
33
diff
changeset
|
353 |
* search and write paths, etc, symlinks are never checked for. |
bc29e1ee7ef6
Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents:
33
diff
changeset
|
354 |
* |
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
355 |
* Symbolic link permission can be enabled or disabled at any time, and is |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
356 |
* disabled by default. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
357 |
* |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
358 |
* @param allow nonzero to permit symlinks, zero to deny linking. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
359 |
*/ |
74
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
360 |
__EXPORT__ void PHYSFS_permitSymbolicLinks(int allow); |
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
361 |
|
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
362 |
|
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
363 |
/** |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
364 |
* Get an array of dirs to available CD-ROM drives. |
1 | 365 |
* |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
366 |
* The dirs returned are platform-dependent ("D:\" on Win32, "/cdrom" or |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
367 |
* whatnot on Unix). Dirs are only returned if there is a disc ready and |
1 | 368 |
* accessible in the drive. So if you've got two drives (D: and E:), and only |
369 |
* E: has a disc in it, then that's all you get. If the user inserts a disc |
|
370 |
* in D: and you call this function again, you get both drives. If, on a |
|
371 |
* Unix box, the user unmounts a disc and remounts it elsewhere, the next |
|
372 |
* call to this function will reflect that change. Fun. |
|
373 |
* |
|
374 |
* The returned value is an array of strings, with a NULL entry to signify the |
|
375 |
* end of the list: |
|
376 |
* |
|
8
41e4c6031535
Typo fixes, clarifications, and corrections.
Ryan C. Gordon <icculus@icculus.org>
parents:
6
diff
changeset
|
377 |
* char **cds = PHYSFS_getCdRomDirs(); |
1 | 378 |
* char **i; |
379 |
* |
|
8
41e4c6031535
Typo fixes, clarifications, and corrections.
Ryan C. Gordon <icculus@icculus.org>
parents:
6
diff
changeset
|
380 |
* for (i = cds; *i != NULL; i++) |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
381 |
* printf("cdrom dir [%s] is available.\n", *i); |
1 | 382 |
* |
8
41e4c6031535
Typo fixes, clarifications, and corrections.
Ryan C. Gordon <icculus@icculus.org>
parents:
6
diff
changeset
|
383 |
* PHYSFS_freeList(cds); |
41e4c6031535
Typo fixes, clarifications, and corrections.
Ryan C. Gordon <icculus@icculus.org>
parents:
6
diff
changeset
|
384 |
* |
1 | 385 |
* This call may block while drives spin up. Be forewarned. |
386 |
* |
|
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
387 |
* When you are done with the returned information, you may dispose of the |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
388 |
* resources by calling PHYSFS_freeList() with the returned pointer. |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
389 |
* |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
390 |
* @return Null-terminated array of null-terminated strings. |
1 | 391 |
*/ |
74
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
392 |
__EXPORT__ char **PHYSFS_getCdRomDirs(void); |
1 | 393 |
|
394 |
||
395 |
/** |
|
396 |
* Helper function. |
|
397 |
* |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
398 |
* Get the "base dir". This is the directory where the application was run |
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
399 |
* from, which is probably the installation directory, and may or may not |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
400 |
* be the process's current working directory. |
1 | 401 |
* |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
402 |
* You should probably use the base dir in your search path. |
1 | 403 |
* |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
404 |
* @return READ ONLY string of base dir in platform-dependent notation. |
1 | 405 |
*/ |
74
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
406 |
__EXPORT__ const char *PHYSFS_getBaseDir(void); |
1 | 407 |
|
408 |
||
409 |
/** |
|
410 |
* Helper function. |
|
411 |
* |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
412 |
* Get the "user dir". This is meant to be a suggestion of where a specific |
1 | 413 |
* user of the system can store files. On Unix, this is her home directory. |
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
414 |
* On systems with no concept of multiple home directories (MacOS, win95), |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
415 |
* this will default to something like "C:\mybasedir\users\username" |
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
416 |
* where "username" will either be the login name, or "default" if the |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
417 |
* platform doesn't support multiple users, either. |
1 | 418 |
* |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
419 |
* You should probably use the user dir as the basis for your write dir, and |
1 | 420 |
* also put it near the beginning of your search path. |
421 |
* |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
422 |
* @return READ ONLY string of user dir in platform-dependent notation. |
1 | 423 |
*/ |
74
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
424 |
__EXPORT__ const char *PHYSFS_getUserDir(void); |
1 | 425 |
|
426 |
||
427 |
/** |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
428 |
* Get the current write dir. The default write dir is NULL. |
1 | 429 |
* |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
430 |
* @return READ ONLY string of write dir in platform-dependent notation, |
1 | 431 |
* OR NULL IF NO WRITE PATH IS CURRENTLY SET. |
432 |
*/ |
|
74
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
433 |
__EXPORT__ const char *PHYSFS_getWriteDir(void); |
1 | 434 |
|
435 |
||
436 |
/** |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
437 |
* Set a new write dir. This will override the previous setting. If the |
1 | 438 |
* directory or a parent directory doesn't exist in the physical filesystem, |
439 |
* PhysicsFS will attempt to create them as needed. |
|
440 |
* |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
441 |
* This call will fail (and fail to change the write dir) if the current |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
442 |
* write dir still has files open in it. |
1 | 443 |
* |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
444 |
* @param newDir The new directory to be the root of the write dir, |
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
445 |
* specified in platform-dependent notation. Setting to NULL |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
446 |
* disables the write dir, so no files can be opened for |
1 | 447 |
* writing via PhysicsFS. |
448 |
* @return non-zero on success, zero on failure. All attempts to open a file |
|
449 |
* for writing via PhysicsFS will fail until this call succeeds. |
|
450 |
* Specifics of the error can be gleaned from PHYSFS_getLastError(). |
|
451 |
* |
|
452 |
*/ |
|
74
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
453 |
__EXPORT__ int PHYSFS_setWriteDir(const char *newDir); |
1 | 454 |
|
455 |
||
456 |
/** |
|
457 |
* Add a directory or archive to the search path. If this is a duplicate, the |
|
458 |
* entry is not added again, even though the function succeeds. |
|
459 |
* |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
460 |
* @param newDir directory or archive to add to the path, in |
1 | 461 |
* platform-dependent notation. |
462 |
* @param appendToPath nonzero to append to search path, zero to prepend. |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
463 |
* @return nonzero if added to path, zero on failure (bogus archive, dir |
1 | 464 |
* missing, etc). Specifics of the error can be |
465 |
* gleaned from PHYSFS_getLastError(). |
|
466 |
*/ |
|
74
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
467 |
__EXPORT__ int PHYSFS_addToSearchPath(const char *newDir, int appendToPath); |
1 | 468 |
|
469 |
||
470 |
/** |
|
2
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
471 |
* Remove a directory or archive from the search path. |
1 | 472 |
* |
473 |
* This must be a (case-sensitive) match to a dir or archive already in the |
|
474 |
* search path, specified in platform-dependent notation. |
|
475 |
* |
|
476 |
* This call will fail (and fail to remove from the path) if the element still |
|
477 |
* has files open in it. |
|
478 |
* |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
479 |
* @param oldDir dir/archive to remove. |
1 | 480 |
* @return nonzero on success, zero on failure. |
481 |
* Specifics of the error can be gleaned from PHYSFS_getLastError(). |
|
482 |
*/ |
|
74
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
483 |
__EXPORT__ int PHYSFS_removeFromSearchPath(const char *oldDir); |
1 | 484 |
|
485 |
||
486 |
/** |
|
487 |
* Get the current search path. The default search path is an empty list. |
|
488 |
* |
|
489 |
* The returned value is an array of strings, with a NULL entry to signify the |
|
490 |
* end of the list: |
|
491 |
* |
|
492 |
* char **i; |
|
493 |
* |
|
494 |
* for (i = PHYSFS_getSearchPath(); *i != NULL; i++) |
|
495 |
* printf("[%s] is in the search path.\n", *i); |
|
496 |
* |
|
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
497 |
* When you are done with the returned information, you may dispose of the |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
498 |
* resources by calling PHYSFS_freeList() with the returned pointer. |
1 | 499 |
* |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
500 |
* @return Null-terminated array of null-terminated strings. NULL if there |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
501 |
* was a problem (read: OUT OF MEMORY). |
1 | 502 |
*/ |
74
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
503 |
__EXPORT__ char **PHYSFS_getSearchPath(void); |
1 | 504 |
|
505 |
||
506 |
/** |
|
507 |
* Helper function. |
|
508 |
* |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
509 |
* Set up sane, default paths. The write dir will be set to |
101
bd18e17ad6ad
Changed PHYSFS_setSaneConfig()'s behaviour. API BREAKAGE.
Ryan C. Gordon <icculus@icculus.org>
parents:
99
diff
changeset
|
510 |
* "userdir/.organization/appName", which is created if it doesn't exist. |
1 | 511 |
* |
512 |
* The above is sufficient to make sure your program's configuration directory |
|
513 |
* is separated from other clutter, and platform-independent. The period |
|
514 |
* before "mygame" even hides the directory on Unix systems. |
|
515 |
* |
|
516 |
* The search path will be: |
|
517 |
* |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
518 |
* - The Write Dir (created if it doesn't exist) |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
519 |
* - The Base Dir (PHYSFS_getBaseDir()) |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
520 |
* - All found CD-ROM dirs (optionally) |
1 | 521 |
* |
522 |
* These directories are then searched for files ending with the extension |
|
523 |
* (archiveExt), which, if they are valid and supported archives, will also |
|
524 |
* be added to the search path. If you specified "PKG" for (archiveExt), and |
|
525 |
* there's a file named data.PKG in the base dir, it'll be checked. Archives |
|
526 |
* can either be appended or prepended to the search path in alphabetical |
|
527 |
* order, regardless of which directories they were found in. |
|
528 |
* |
|
529 |
* All of this can be accomplished from the application, but this just does it |
|
2
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
530 |
* all for you. Feel free to add more to the search path manually, too. |
1 | 531 |
* |
101
bd18e17ad6ad
Changed PHYSFS_setSaneConfig()'s behaviour. API BREAKAGE.
Ryan C. Gordon <icculus@icculus.org>
parents:
99
diff
changeset
|
532 |
* @param organization Name of your company/group/etc to be used as a |
bd18e17ad6ad
Changed PHYSFS_setSaneConfig()'s behaviour. API BREAKAGE.
Ryan C. Gordon <icculus@icculus.org>
parents:
99
diff
changeset
|
533 |
* dirname, so keep it small, and no-frills. |
bd18e17ad6ad
Changed PHYSFS_setSaneConfig()'s behaviour. API BREAKAGE.
Ryan C. Gordon <icculus@icculus.org>
parents:
99
diff
changeset
|
534 |
* |
1 | 535 |
* @param appName Program-specific name of your program, to separate it |
536 |
* from other programs using PhysicsFS. |
|
537 |
* |
|
538 |
* @param archiveExt File extention used by your program to specify an |
|
539 |
* archive. For example, Quake 3 uses "pk3", even though |
|
540 |
* they are just zipfiles. Specify NULL to not dig out |
|
8
41e4c6031535
Typo fixes, clarifications, and corrections.
Ryan C. Gordon <icculus@icculus.org>
parents:
6
diff
changeset
|
541 |
* archives automatically. Do not specify the '.' char; |
41e4c6031535
Typo fixes, clarifications, and corrections.
Ryan C. Gordon <icculus@icculus.org>
parents:
6
diff
changeset
|
542 |
* If you want to look for ZIP files, specify "ZIP" and |
41e4c6031535
Typo fixes, clarifications, and corrections.
Ryan C. Gordon <icculus@icculus.org>
parents:
6
diff
changeset
|
543 |
* not ".ZIP" ... the archive search is case-insensitive. |
1 | 544 |
* |
545 |
* @param includeCdRoms Non-zero to include CD-ROMs in the search path, and |
|
2
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
546 |
* (if (archiveExt) != NULL) search them for archives. |
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
547 |
* This may cause a significant amount of blocking |
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
548 |
* while discs are accessed, and if there are no discs |
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
549 |
* in the drive (or even not mounted on Unix systems), |
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
550 |
* then they may not be made available anyhow. You may |
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
551 |
* want to specify zero and handle the disc setup |
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
552 |
* yourself. |
1 | 553 |
* |
554 |
* @param archivesFirst Non-zero to prepend the archives to the search path. |
|
2
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
555 |
* Zero to append them. Ignored if !(archiveExt). |
101
bd18e17ad6ad
Changed PHYSFS_setSaneConfig()'s behaviour. API BREAKAGE.
Ryan C. Gordon <icculus@icculus.org>
parents:
99
diff
changeset
|
556 |
* |
8
41e4c6031535
Typo fixes, clarifications, and corrections.
Ryan C. Gordon <icculus@icculus.org>
parents:
6
diff
changeset
|
557 |
* @return nonzero on success, zero on error. Specifics of the error can be |
41e4c6031535
Typo fixes, clarifications, and corrections.
Ryan C. Gordon <icculus@icculus.org>
parents:
6
diff
changeset
|
558 |
* gleaned from PHYSFS_getLastError(). |
1 | 559 |
*/ |
101
bd18e17ad6ad
Changed PHYSFS_setSaneConfig()'s behaviour. API BREAKAGE.
Ryan C. Gordon <icculus@icculus.org>
parents:
99
diff
changeset
|
560 |
__EXPORT__ int PHYSFS_setSaneConfig(const char *organization, |
bd18e17ad6ad
Changed PHYSFS_setSaneConfig()'s behaviour. API BREAKAGE.
Ryan C. Gordon <icculus@icculus.org>
parents:
99
diff
changeset
|
561 |
const char *appName, |
74
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
562 |
const char *archiveExt, |
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
563 |
int includeCdRoms, |
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
564 |
int archivesFirst); |
1 | 565 |
|
566 |
||
567 |
/** |
|
568 |
* Create a directory. This is specified in platform-independent notation in |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
569 |
* relation to the write dir. All missing parent directories are also |
1 | 570 |
* created if they don't exist. |
571 |
* |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
572 |
* So if you've got the write dir set to "C:\mygame\writedir" and call |
1 | 573 |
* PHYSFS_mkdir("downloads/maps") then the directories |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
574 |
* "C:\mygame\writedir\downloads" and "C:\mygame\writedir\downloads\maps" |
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
575 |
* will be created if possible. If the creation of "maps" fails after we |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
576 |
* have successfully created "downloads", then the function leaves the |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
577 |
* created directory behind and reports failure. |
1 | 578 |
* |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
579 |
* @param dirname New dir to create. |
1 | 580 |
* @return nonzero on success, zero on error. Specifics of the error can be |
581 |
* gleaned from PHYSFS_getLastError(). |
|
582 |
*/ |
|
74
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
583 |
__EXPORT__ int PHYSFS_mkdir(const char *dirName); |
1 | 584 |
|
585 |
||
586 |
/** |
|
587 |
* Delete a file or directory. This is specified in platform-independent |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
588 |
* notation in relation to the write dir. |
1 | 589 |
* |
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
590 |
* A directory must be empty before this call can delete it. |
1 | 591 |
* |
137
66bddb94b6e0
Abstracted file deletion, so we don't rely on C library for it anymore.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
592 |
* Deleting a symlink will remove the link, not what it points to, regardless |
66bddb94b6e0
Abstracted file deletion, so we don't rely on C library for it anymore.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
593 |
* of whether you "permitSymLinks" or not. |
66bddb94b6e0
Abstracted file deletion, so we don't rely on C library for it anymore.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
594 |
* |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
595 |
* So if you've got the write dir set to "C:\mygame\writedir" and call |
1 | 596 |
* PHYSFS_delete("downloads/maps/level1.map") then the file |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
597 |
* "C:\mygame\writedir\downloads\maps\level1.map" is removed from the |
1 | 598 |
* physical filesystem, if it exists and the operating system permits the |
599 |
* deletion. |
|
600 |
* |
|
2
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
601 |
* Note that on Unix systems, deleting a file may be successful, but the |
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
602 |
* actual file won't be removed until all processes that have an open |
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
603 |
* filehandle to it (including your program) close their handles. |
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
604 |
* |
137
66bddb94b6e0
Abstracted file deletion, so we don't rely on C library for it anymore.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
605 |
* Chances are, the bits that make up the file still exist, they are just |
66bddb94b6e0
Abstracted file deletion, so we don't rely on C library for it anymore.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
606 |
* made available to be written over at a later point. Don't consider this |
66bddb94b6e0
Abstracted file deletion, so we don't rely on C library for it anymore.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
607 |
* a security method or anything. :) |
66bddb94b6e0
Abstracted file deletion, so we don't rely on C library for it anymore.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
608 |
* |
1 | 609 |
* @param filename Filename to delete. |
610 |
* @return nonzero on success, zero on error. Specifics of the error can be |
|
611 |
* gleaned from PHYSFS_getLastError(). |
|
612 |
*/ |
|
74
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
613 |
__EXPORT__ int PHYSFS_delete(const char *filename); |
1 | 614 |
|
615 |
||
616 |
/** |
|
617 |
* Figure out where in the search path a file resides. The file is specified |
|
618 |
* in platform-independent notation. The returned filename will be the |
|
619 |
* element of the search path where the file was found, which may be a |
|
620 |
* directory, or an archive. Even if there are multiple matches in different |
|
621 |
* parts of the search path, only the first one found is used, just like |
|
622 |
* when opening a file. |
|
623 |
* |
|
624 |
* So, if you look for "maps/level1.map", and C:\mygame is in your search |
|
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
625 |
* path and C:\mygame\maps\level1.map exists, then "C:\mygame" is returned. |
1 | 626 |
* |
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
627 |
* If a any part of a match is a symbolic link, and you've not explicitly |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
628 |
* permitted symlinks, then it will be ignored, and the search for a match |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
629 |
* will continue. |
2
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
630 |
* |
1 | 631 |
* @param filename file to look for. |
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
632 |
* @return READ ONLY string of element of search path containing the |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
633 |
* the file in question. NULL if not found. |
1 | 634 |
*/ |
74
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
635 |
__EXPORT__ const char *PHYSFS_getRealDir(const char *filename); |
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
636 |
|
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
637 |
|
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
638 |
|
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
639 |
/** |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
640 |
* Get a file listing of a search path's directory. Matching directories are |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
641 |
* interpolated. That is, if "C:\mydir" is in the search path and contains a |
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
642 |
* directory "savegames" that contains "x.sav", "y.sav", and "z.sav", and |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
643 |
* there is also a "C:\userdir" in the search path that has a "savegames" |
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
644 |
* subdirectory with "w.sav", then the following code: |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
645 |
* |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
646 |
* ------------------------------------------------ |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
647 |
* char **rc = PHYSFS_enumerateFiles("savegames"); |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
648 |
* char **i; |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
649 |
* |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
650 |
* for (i = rc; *i != NULL; i++) |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
651 |
* printf("We've got [%s].\n", *i); |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
652 |
* |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
653 |
* PHYSFS_freeList(rc); |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
654 |
* ------------------------------------------------ |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
655 |
* |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
656 |
* ...will print: |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
657 |
* |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
658 |
* ------------------------------------------------ |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
659 |
* We've got [x.sav]. |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
660 |
* We've got [y.sav]. |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
661 |
* We've got [z.sav]. |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
662 |
* We've got [w.sav]. |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
663 |
* ------------------------------------------------ |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
664 |
* |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
665 |
* Feel free to sort the list however you like. We only promise there will |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
666 |
* be no duplicates, but not what order the final list will come back in. |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
667 |
* |
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
668 |
* Don't forget to call PHYSFS_freeList() with the return value from this |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
669 |
* function when you are done with it. |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
670 |
* |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
671 |
* @param dir directory in platform-independent notation to enumerate. |
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
672 |
* @return Null-terminated array of null-terminated strings. |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
673 |
*/ |
74
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
674 |
__EXPORT__ char **PHYSFS_enumerateFiles(const char *dir); |
1 | 675 |
|
676 |
||
677 |
/** |
|
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
678 |
* Determine if there is an entry anywhere in the search path by the |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
679 |
* name of (fname). |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
680 |
* |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
681 |
* Note that entries that are symlinks are ignored if |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
682 |
* PHYSFS_permitSymbolicLinks(1) hasn't been called, so you |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
683 |
* might end up further down in the search path than expected. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
684 |
* |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
685 |
* @param fname filename in platform-independent notation. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
686 |
* @return non-zero if filename exists. zero otherwise. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
687 |
*/ |
74
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
688 |
__EXPORT__ int PHYSFS_exists(const char *fname); |
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
689 |
|
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
690 |
|
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
691 |
/** |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
692 |
* Determine if the first occurence of (fname) in the search path is |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
693 |
* really a directory entry. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
694 |
* |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
695 |
* Note that entries that are symlinks are ignored if |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
696 |
* PHYSFS_permitSymbolicLinks(1) hasn't been called, so you |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
697 |
* might end up further down in the search path than expected. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
698 |
* |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
699 |
* @param fname filename in platform-independent notation. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
700 |
* @return non-zero if filename exists and is a directory. zero otherwise. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
701 |
*/ |
74
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
702 |
__EXPORT__ int PHYSFS_isDirectory(const char *fname); |
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
703 |
|
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
704 |
|
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
705 |
/** |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
706 |
* Determine if the first occurence of (fname) in the search path is |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
707 |
* really a symbolic link. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
708 |
* |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
709 |
* Note that entries that are symlinks are ignored if |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
710 |
* PHYSFS_permitSymbolicLinks(1) hasn't been called, and as such, |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
711 |
* this function will always return 0 in that case. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
712 |
* |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
713 |
* @param fname filename in platform-independent notation. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
714 |
* @return non-zero if filename exists and is a symlink. zero otherwise. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
715 |
*/ |
74
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
716 |
__EXPORT__ int PHYSFS_isSymbolicLink(const char *fname); |
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
717 |
|
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
718 |
|
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
719 |
/** |
1 | 720 |
* Open a file for writing, in platform-independent notation and in relation |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
721 |
* to the write dir as the root of the writable filesystem. The specified |
1 | 722 |
* file is created if it doesn't exist. If it does exist, it is truncated to |
723 |
* zero bytes, and the writing offset is set to the start. |
|
724 |
* |
|
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
725 |
* Note that entries that are symlinks are ignored if |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
726 |
* PHYSFS_permitSymbolicLinks(1) hasn't been called, and opening a |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
727 |
* symlink with this function will fail in such a case. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
728 |
* |
1 | 729 |
* @param filename File to open. |
730 |
* @return A valid PhysicsFS filehandle on success, NULL on error. Specifics |
|
731 |
* of the error can be gleaned from PHYSFS_getLastError(). |
|
732 |
*/ |
|
74
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
733 |
__EXPORT__ PHYSFS_file *PHYSFS_openWrite(const char *filename); |
1 | 734 |
|
735 |
||
736 |
/** |
|
737 |
* Open a file for writing, in platform-independent notation and in relation |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
738 |
* to the write dir as the root of the writable filesystem. The specified |
1 | 739 |
* file is created if it doesn't exist. If it does exist, the writing offset |
740 |
* is set to the end of the file, so the first write will be the byte after |
|
741 |
* the end. |
|
742 |
* |
|
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
743 |
* Note that entries that are symlinks are ignored if |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
744 |
* PHYSFS_permitSymbolicLinks(1) hasn't been called, and opening a |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
745 |
* symlink with this function will fail in such a case. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
746 |
* |
1 | 747 |
* @param filename File to open. |
748 |
* @return A valid PhysicsFS filehandle on success, NULL on error. Specifics |
|
749 |
* of the error can be gleaned from PHYSFS_getLastError(). |
|
750 |
*/ |
|
74
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
751 |
__EXPORT__ PHYSFS_file *PHYSFS_openAppend(const char *filename); |
1 | 752 |
|
753 |
||
754 |
/** |
|
755 |
* Open a file for reading, in platform-independent notation. The search path |
|
756 |
* is checked one at a time until a matching file is found, in which case an |
|
757 |
* abstract filehandle is associated with it, and reading may be done. |
|
758 |
* The reading offset is set to the first byte of the file. |
|
759 |
* |
|
15
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
760 |
* Note that entries that are symlinks are ignored if |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
761 |
* PHYSFS_permitSymbolicLinks(1) hasn't been called, and opening a |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
762 |
* symlink with this function will fail in such a case. |
418eacc97ac8
Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents:
8
diff
changeset
|
763 |
* |
1 | 764 |
* @param filename File to open. |
765 |
* @return A valid PhysicsFS filehandle on success, NULL on error. Specifics |
|
766 |
* of the error can be gleaned from PHYSFS_getLastError(). |
|
767 |
*/ |
|
74
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
768 |
__EXPORT__ PHYSFS_file *PHYSFS_openRead(const char *filename); |
1 | 769 |
|
770 |
||
771 |
/** |
|
772 |
* Close a PhysicsFS filehandle. This call is capable of failing if the |
|
773 |
* operating system was buffering writes to this file, and (now forced to |
|
774 |
* write those changes to physical media) can not store the data for any |
|
775 |
* reason. In such a case, the filehandle stays open. A well-written program |
|
776 |
* should ALWAYS check the return value from the close call in addition to |
|
777 |
* every writing call! |
|
778 |
* |
|
779 |
* @param handle handle returned from PHYSFS_open*(). |
|
780 |
* @return nonzero on success, zero on error. Specifics of the error can be |
|
781 |
* gleaned from PHYSFS_getLastError(). |
|
782 |
*/ |
|
74
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
783 |
__EXPORT__ int PHYSFS_close(PHYSFS_file *handle); |
1 | 784 |
|
785 |
||
786 |
/** |
|
787 |
* Read data from a PhysicsFS filehandle. The file must be opened for reading. |
|
788 |
* |
|
789 |
* @param handle handle returned from PHYSFS_openRead(). |
|
790 |
* @param buffer buffer to store read data into. |
|
791 |
* @param objSize size in bytes of objects being read from (handle). |
|
792 |
* @param objCount number of (objSize) objects to read from (handle). |
|
793 |
* @return number of objects read. PHYSFS_getLastError() can shed light on |
|
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
794 |
* the reason this might be < (objCount), as can PHYSFS_eof(). |
8
41e4c6031535
Typo fixes, clarifications, and corrections.
Ryan C. Gordon <icculus@icculus.org>
parents:
6
diff
changeset
|
795 |
* -1 if complete failure. |
1 | 796 |
*/ |
132
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
797 |
__EXPORT__ PHYSFS_sint64 PHYSFS_read(PHYSFS_file *handle, |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
798 |
void *buffer, |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
799 |
PHYSFS_uint32 objSize, |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
800 |
PHYSFS_uint32 objCount); |
1 | 801 |
|
802 |
/** |
|
803 |
* Write data to a PhysicsFS filehandle. The file must be opened for writing. |
|
804 |
* |
|
805 |
* @param handle retval from PHYSFS_openWrite() or PHYSFS_openAppend(). |
|
806 |
* @param buffer buffer to store read data into. |
|
807 |
* @param objSize size in bytes of objects being read from (handle). |
|
808 |
* @param objCount number of (objSize) objects to read from (handle). |
|
8
41e4c6031535
Typo fixes, clarifications, and corrections.
Ryan C. Gordon <icculus@icculus.org>
parents:
6
diff
changeset
|
809 |
* @return number of objects written. PHYSFS_getLastError() can shed light on |
41e4c6031535
Typo fixes, clarifications, and corrections.
Ryan C. Gordon <icculus@icculus.org>
parents:
6
diff
changeset
|
810 |
* the reason this might be < (objCount). -1 if complete failure. |
1 | 811 |
*/ |
132
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
812 |
__EXPORT__ PHYSFS_sint64 PHYSFS_write(PHYSFS_file *handle, |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
813 |
const void *buffer, |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
814 |
PHYSFS_uint32 objSize, |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
815 |
PHYSFS_uint32 objCount); |
1 | 816 |
|
817 |
/** |
|
818 |
* Determine if the end of file has been reached in a PhysicsFS filehandle. |
|
819 |
* |
|
820 |
* @param handle handle returned from PHYSFS_openRead(). |
|
821 |
* @return nonzero if EOF, zero if not. |
|
822 |
*/ |
|
74
a4a5066fb640
Compiles and runs on Visual C. What an uphill climb THAT was.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
823 |
__EXPORT__ int PHYSFS_eof(PHYSFS_file *handle); |
1 | 824 |
|
825 |
||
826 |
/** |
|
827 |
* Determine current position within a PhysicsFS filehandle. |
|
828 |
* |
|
829 |
* @param handle handle returned from PHYSFS_open*(). |
|
830 |
* @return offset in bytes from start of file. -1 if error occurred. |
|
831 |
* Specifics of the error can be gleaned from PHYSFS_getLastError(). |
|
832 |
*/ |
|
132
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
833 |
__EXPORT__ PHYSFS_sint64 PHYSFS_tell(PHYSFS_file *handle); |
1 | 834 |
|
835 |
||
836 |
/** |
|
837 |
* Seek to a new position within a PhysicsFS filehandle. The next read or write |
|
838 |
* will occur at that place. Seeking past the beginning or end of the file is |
|
839 |
* not allowed. |
|
840 |
* |
|
841 |
* @param handle handle returned from PHYSFS_open*(). |
|
842 |
* @param pos number of bytes from start of file to seek to. |
|
843 |
* @return nonzero on success, zero on error. Specifics of the error can be |
|
844 |
* gleaned from PHYSFS_getLastError(). |
|
845 |
*/ |
|
132
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
846 |
__EXPORT__ int PHYSFS_seek(PHYSFS_file *handle, PHYSFS_uint64 pos); |
2
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
847 |
|
28
529214f57d1b
Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents:
23
diff
changeset
|
848 |
|
529214f57d1b
Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents:
23
diff
changeset
|
849 |
/** |
529214f57d1b
Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents:
23
diff
changeset
|
850 |
* Get total length of a file in bytes. Note that if the file size can't |
529214f57d1b
Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents:
23
diff
changeset
|
851 |
* be determined (since the archive is "streamed" or whatnot) than this |
126
f5135b499c0c
const correctness fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
101
diff
changeset
|
852 |
* will report (-1). Also note that if another process/thread is writing |
28
529214f57d1b
Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents:
23
diff
changeset
|
853 |
* to this file at the same time, then the information this function |
529214f57d1b
Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents:
23
diff
changeset
|
854 |
* supplies could be incorrect before you get it. Use with caution, or |
529214f57d1b
Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents:
23
diff
changeset
|
855 |
* better yet, don't use at all. |
529214f57d1b
Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents:
23
diff
changeset
|
856 |
* |
529214f57d1b
Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents:
23
diff
changeset
|
857 |
* @param handle handle returned from PHYSFS_open*(). |
529214f57d1b
Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents:
23
diff
changeset
|
858 |
* @return size in bytes of the file. -1 if can't be determined. |
529214f57d1b
Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents:
23
diff
changeset
|
859 |
*/ |
132
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
128
diff
changeset
|
860 |
__EXPORT__ PHYSFS_sint64 PHYSFS_fileLength(PHYSFS_file *handle); |
28
529214f57d1b
Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents:
23
diff
changeset
|
861 |
|
178
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
862 |
|
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
863 |
/* Byteorder stuff... */ |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
864 |
|
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
865 |
/** |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
866 |
* Take a 16-bit signed value in littleendian format and convert it to |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
867 |
* the platform's native byte order. |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
868 |
* |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
869 |
* @param val value to convert |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
870 |
* @return converted value. |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
871 |
*/ |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
872 |
__EXPORT__ PHYSFS_sint16 PHYSFS_swapSLE16(PHYSFS_sint16 val); |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
873 |
|
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
874 |
|
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
875 |
/** |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
876 |
* Take a 16-bit unsigned value in littleendian format and convert it to |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
877 |
* the platform's native byte order. |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
878 |
* |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
879 |
* @param val value to convert |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
880 |
* @return converted value. |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
881 |
*/ |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
882 |
__EXPORT__ PHYSFS_uint16 PHYSFS_swapULE16(PHYSFS_uint16 val); |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
883 |
|
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
884 |
/** |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
885 |
* Take a 32-bit signed value in littleendian format and convert it to |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
886 |
* the platform's native byte order. |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
887 |
* |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
888 |
* @param val value to convert |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
889 |
* @return converted value. |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
890 |
*/ |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
891 |
__EXPORT__ PHYSFS_sint32 PHYSFS_swapSLE32(PHYSFS_sint32 val); |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
892 |
|
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
893 |
|
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
894 |
/** |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
895 |
* Take a 32-bit unsigned value in littleendian format and convert it to |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
896 |
* the platform's native byte order. |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
897 |
* |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
898 |
* @param val value to convert |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
899 |
* @return converted value. |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
900 |
*/ |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
901 |
__EXPORT__ PHYSFS_uint32 PHYSFS_swapULE32(PHYSFS_uint32 val); |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
902 |
|
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
903 |
/** |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
904 |
* Take a 64-bit signed value in littleendian format and convert it to |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
905 |
* the platform's native byte order. |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
906 |
* |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
907 |
* @param val value to convert |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
908 |
* @return converted value. |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
909 |
*/ |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
910 |
__EXPORT__ PHYSFS_sint64 PHYSFS_swapSLE64(PHYSFS_sint64 val); |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
911 |
|
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
912 |
|
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
913 |
/** |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
914 |
* Take a 64-bit unsigned value in littleendian format and convert it to |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
915 |
* the platform's native byte order. |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
916 |
* |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
917 |
* @param val value to convert |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
918 |
* @return converted value. |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
919 |
*/ |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
920 |
__EXPORT__ PHYSFS_uint64 PHYSFS_swapULE64(PHYSFS_uint64 val); |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
921 |
|
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
922 |
|
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
923 |
/** |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
924 |
* Take a 16-bit signed value in bigendian format and convert it to |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
925 |
* the platform's native byte order. |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
926 |
* |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
927 |
* @param val value to convert |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
928 |
* @return converted value. |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
929 |
*/ |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
930 |
__EXPORT__ PHYSFS_sint16 PHYSFS_swapSBE16(PHYSFS_sint16 val); |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
931 |
|
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
932 |
|
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
933 |
/** |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
934 |
* Take a 16-bit unsigned value in bigendian format and convert it to |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
935 |
* the platform's native byte order. |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
936 |
* |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
937 |
* @param val value to convert |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
938 |
* @return converted value. |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
939 |
*/ |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
940 |
__EXPORT__ PHYSFS_uint16 PHYSFS_swapUBE16(PHYSFS_uint16 val); |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
941 |
|
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
942 |
/** |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
943 |
* Take a 32-bit signed value in bigendian format and convert it to |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
944 |
* the platform's native byte order. |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
945 |
* |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
946 |
* @param val value to convert |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
947 |
* @return converted value. |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
948 |
*/ |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
949 |
__EXPORT__ PHYSFS_sint32 PHYSFS_swapSBE32(PHYSFS_sint32 val); |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
950 |
|
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
951 |
|
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
952 |
/** |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
953 |
* Take a 32-bit unsigned value in bigendian format and convert it to |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
954 |
* the platform's native byte order. |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
955 |
* |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
956 |
* @param val value to convert |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
957 |
* @return converted value. |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
958 |
*/ |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
959 |
__EXPORT__ PHYSFS_uint32 PHYSFS_swapUBE32(PHYSFS_uint32 val); |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
960 |
|
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
961 |
|
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
962 |
/** |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
963 |
* Take a 64-bit signed value in bigendian format and convert it to |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
964 |
* the platform's native byte order. |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
965 |
* |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
966 |
* @param val value to convert |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
967 |
* @return converted value. |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
968 |
*/ |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
969 |
__EXPORT__ PHYSFS_sint64 PHYSFS_swapSBE64(PHYSFS_sint64 val); |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
970 |
|
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
971 |
|
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
972 |
/** |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
973 |
* Take a 64-bit unsigned value in bigendian format and convert it to |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
974 |
* the platform's native byte order. |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
975 |
* |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
976 |
* @param val value to convert |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
977 |
* @return converted value. |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
978 |
*/ |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
979 |
__EXPORT__ PHYSFS_uint64 PHYSFS_swapUBE64(PHYSFS_uint64 val); |
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
980 |
|
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
981 |
|
e71b33bc440f
Added byte ordering API.
Ryan C. Gordon <icculus@icculus.org>
parents:
160
diff
changeset
|
982 |
|
147
5e1eda65ceb3
Updated comment on thread safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
983 |
#if 0 /* !!! FIXME: add this? */ |
5e1eda65ceb3
Updated comment on thread safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
984 |
#undef __EXPORT__ |
5e1eda65ceb3
Updated comment on thread safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
985 |
#endif |
5e1eda65ceb3
Updated comment on thread safety.
Ryan C. Gordon <icculus@icculus.org>
parents:
137
diff
changeset
|
986 |
|
1 | 987 |
#ifdef __cplusplus |
988 |
} |
|
989 |
#endif |
|
990 |
||
991 |
#endif /* !defined _INCLUDE_PHYSFS_H_ */ |
|
992 |
||
993 |
/* end of physfs.h ... */ |
|
994 |