author | Ryan C. Gordon <icculus@icculus.org> |
Thu, 05 Jul 2001 08:19:01 +0000 | |
changeset 6 | 3662cbc014ef |
parent 3 | 0dd785321345 |
child 8 | 41e4c6031535 |
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 |
* |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
105 |
* PhysicsFS is (sort of) NOT thread safe! The error messages returned by |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
106 |
* PHYSFS_getLastError are unique by thread, but that's it. Generally |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
107 |
* speaking, we'd have to request a mutex at the start of each function, |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
108 |
* and release it before returning. Not only is this REALLY slow, it requires |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
109 |
* a thread lock portability layer to be written. All that work is only |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
110 |
* necessary as a safety if the calling application is poorly written. |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
111 |
* Generally speaking, it is safe to call most functions that don't set state |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
112 |
* simultaneously; you can read and write and open and close different files |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
113 |
* at the same time in different threads, but trying to set the write path in |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
114 |
* one thread while opening a file for writing in another will, at best, |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
115 |
* cause a polite error, but depending on the race condition results, you may |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
116 |
* get a segfault and crash, too. Use your head, and implement you own thread |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
117 |
* locks where needed. Also, consider if you REALLY need a multithreaded |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
118 |
* solution in the first place. |
1 | 119 |
* |
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
120 |
* 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
|
121 |
* calls, doing so is not recommended, and you can not use system |
1 | 122 |
* filehandles with PhysicsFS filehandles and vice versa. |
123 |
* |
|
124 |
* 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
|
125 |
* rename it with a .PKG extension, the file will still be recognized as a |
1 | 126 |
* ZIP archive by PhysicsFS; the file's contents are used to determine its |
127 |
* type. |
|
128 |
* |
|
129 |
* Currently supported archive types: |
|
130 |
* - .ZIP (pkZip/WinZip/Info-ZIP compatible) |
|
131 |
* |
|
132 |
* Please see the file LICENSE in the source's root directory. |
|
133 |
* |
|
134 |
* This file written by Ryan C. Gordon. |
|
135 |
*/ |
|
136 |
||
137 |
#ifndef _INCLUDE_PHYSFS_H_ |
|
138 |
#define _INCLUDE_PHYSFS_H_ |
|
139 |
||
140 |
#ifdef __cplusplus |
|
141 |
extern "C" { |
|
142 |
#endif |
|
143 |
||
144 |
||
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
145 |
typedef struct __PHYSFS_FILE__ |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
146 |
{ |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
147 |
void *opaque; |
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
148 |
} PHYSFS_file; |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
149 |
|
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
150 |
typedef struct __PHYSFS_ARCHIVEINFO__ |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
151 |
{ |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
152 |
const char *extension; |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
153 |
const char *description; |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
154 |
} PHYSFS_ArchiveInfo; |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
155 |
|
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
156 |
|
1 | 157 |
/* functions... */ |
158 |
||
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
159 |
typedef struct __PHYSFS_VERSION__ |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
160 |
{ |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
161 |
int major; |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
162 |
int minor; |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
163 |
int patch; |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
164 |
} PHYSFS_Version; |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
165 |
|
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
166 |
#define PHYSFS_VER_MAJOR 0 |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
167 |
#define PHYSFS_VER_MINOR 1 |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
168 |
#define PHYSFS_VER_PATCH 0 |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
169 |
|
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
170 |
#define PHYSFS_VERSION(x) { \ |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
171 |
x->major = PHYSFS_VER_MAJOR; \ |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
172 |
x->minor = PHYSFS_VER_MINOR; \ |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
173 |
x->patch = PHYSFS_VER_PATCH; \ |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
174 |
} |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
175 |
|
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
176 |
/** |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
177 |
* 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
|
178 |
* 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
|
179 |
* 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
|
180 |
* |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
181 |
* 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
|
182 |
* of PhysFS you compiled against: |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
183 |
* |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
184 |
* PHYSFS_Version compiled; |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
185 |
* PHYSFS_Version linked; |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
186 |
* |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
187 |
* PHYSFS_VERSION(&compiled); |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
188 |
* PHYSFS_getLinkedVersion(&linked); |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
189 |
* 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
|
190 |
* compiled.major, compiled.minor, compiled.patch); |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
191 |
* 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
|
192 |
* linked.major, linked.minor, linked.patch); |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
193 |
* |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
194 |
* 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
|
195 |
*/ |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
196 |
void PHYSFS_getLinkedVersion(PHYSFS_Version *ver); |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
197 |
|
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
198 |
|
2
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
199 |
/** |
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
200 |
* 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
|
201 |
* function. |
2
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
202 |
* |
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
203 |
* @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
|
204 |
* @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
|
205 |
* 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
|
206 |
*/ |
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
207 |
int PHYSFS_init(const char *argv0); |
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
208 |
|
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
209 |
|
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
210 |
/** |
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
211 |
* 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
|
212 |
* 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
|
213 |
* |
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
214 |
* Once deinitialized, PHYSFS_init() can be called again to restart the |
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
215 |
* subsystem. |
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
216 |
* |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
217 |
* This function can be used with atexit(), if you feel it's prudent to do so. |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
218 |
* |
2
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
219 |
* @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
|
220 |
* 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
|
221 |
* 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
|
222 |
*/ |
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
223 |
void PHYSFS_deinit(void); |
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
224 |
|
1 | 225 |
|
226 |
/** |
|
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
227 |
* 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
|
228 |
* 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
|
229 |
* 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
|
230 |
* 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
|
231 |
* 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
|
232 |
* |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
233 |
* 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
|
234 |
* 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
|
235 |
* |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
236 |
* PHYSFS_ArchiveInfo **i; |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
237 |
* |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
238 |
* for (i = PHYSFS_supportedArchiveTypes(); *i != NULL; i++) |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
239 |
* { |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
240 |
* 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
|
241 |
* i->extension, i->description); |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
242 |
* } |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
243 |
* |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
244 |
* 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
|
245 |
* be considered READ ONLY, and never freed. |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
246 |
* |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
247 |
* @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
|
248 |
*/ |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
249 |
const PHYSFS_ArchiveInfo **PHYSFS_supportedArchiveTypes(void); |
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
250 |
|
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
251 |
|
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
252 |
/** |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
253 |
* 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
|
254 |
* 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
|
255 |
* |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
256 |
* @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
|
257 |
*/ |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
258 |
void PHYSFS_freeList(void *list); |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
259 |
|
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
260 |
|
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
261 |
/** |
1 | 262 |
* Get the last PhysicsFS error message as a null-terminated string. |
263 |
* 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
|
264 |
* 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
|
265 |
* 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
|
266 |
* 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
|
267 |
* 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
|
268 |
* before PHYSFS_init(). |
1 | 269 |
* |
270 |
* @return READ ONLY string of last error message. |
|
271 |
*/ |
|
272 |
const char *PHYSFS_getLastError(void); |
|
273 |
||
274 |
||
275 |
/** |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
276 |
* Get a platform-dependent dir separator. This is "\\" on win32, "/" on Unix, |
1 | 277 |
* and ":" on MacOS. It may be more than one character, depending on the |
278 |
* platform, and your code should take that into account. Note that this is |
|
279 |
* 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
|
280 |
* 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
|
281 |
* 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
|
282 |
* when using stdio calls. |
1 | 283 |
* |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
284 |
* @return READ ONLY null-terminated string of platform's dir separator. |
1 | 285 |
*/ |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
286 |
const char *PHYSFS_getDirSeparator(void); |
1 | 287 |
|
288 |
||
289 |
/** |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
290 |
* Get an array of dirs to available CD-ROM drives. |
1 | 291 |
* |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
292 |
* 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
|
293 |
* whatnot on Unix). Dirs are only returned if there is a disc ready and |
1 | 294 |
* accessible in the drive. So if you've got two drives (D: and E:), and only |
295 |
* E: has a disc in it, then that's all you get. If the user inserts a disc |
|
296 |
* in D: and you call this function again, you get both drives. If, on a |
|
297 |
* Unix box, the user unmounts a disc and remounts it elsewhere, the next |
|
298 |
* call to this function will reflect that change. Fun. |
|
299 |
* |
|
300 |
* The returned value is an array of strings, with a NULL entry to signify the |
|
301 |
* end of the list: |
|
302 |
* |
|
303 |
* char **i; |
|
304 |
* |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
305 |
* for (i = PHYSFS_getCdRomDirs(); *i != NULL; i++) |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
306 |
* printf("cdrom dir [%s] is available.\n", *i); |
1 | 307 |
* |
308 |
* This call may block while drives spin up. Be forewarned. |
|
309 |
* |
|
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
310 |
* 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
|
311 |
* 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
|
312 |
* |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
313 |
* @return Null-terminated array of null-terminated strings. |
1 | 314 |
*/ |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
315 |
char **PHYSFS_getCdRomDirs(void); |
1 | 316 |
|
317 |
||
318 |
/** |
|
319 |
* Helper function. |
|
320 |
* |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
321 |
* 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
|
322 |
* 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
|
323 |
* be the process's current working directory. |
1 | 324 |
* |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
325 |
* You should probably use the base dir in your search path. |
1 | 326 |
* |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
327 |
* @return READ ONLY string of base dir in platform-dependent notation. |
1 | 328 |
*/ |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
329 |
const char *PHYSFS_getBaseDir(void); |
1 | 330 |
|
331 |
||
332 |
/** |
|
333 |
* Helper function. |
|
334 |
* |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
335 |
* Get the "user dir". This is meant to be a suggestion of where a specific |
1 | 336 |
* 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
|
337 |
* 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
|
338 |
* 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
|
339 |
* 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
|
340 |
* platform doesn't support multiple users, either. |
1 | 341 |
* |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
342 |
* You should probably use the user dir as the basis for your write dir, and |
1 | 343 |
* also put it near the beginning of your search path. |
344 |
* |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
345 |
* @return READ ONLY string of user dir in platform-dependent notation. |
1 | 346 |
*/ |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
347 |
const char *PHYSFS_getUserDir(void); |
1 | 348 |
|
349 |
||
350 |
/** |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
351 |
* Get the current write dir. The default write dir is NULL. |
1 | 352 |
* |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
353 |
* @return READ ONLY string of write dir in platform-dependent notation, |
1 | 354 |
* OR NULL IF NO WRITE PATH IS CURRENTLY SET. |
355 |
*/ |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
356 |
const char *PHYSFS_getWriteDir(void); |
1 | 357 |
|
358 |
||
359 |
/** |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
360 |
* Set a new write dir. This will override the previous setting. If the |
1 | 361 |
* directory or a parent directory doesn't exist in the physical filesystem, |
362 |
* PhysicsFS will attempt to create them as needed. |
|
363 |
* |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
364 |
* 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
|
365 |
* write dir still has files open in it. |
1 | 366 |
* |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
367 |
* @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
|
368 |
* specified in platform-dependent notation. Setting to NULL |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
369 |
* disables the write dir, so no files can be opened for |
1 | 370 |
* writing via PhysicsFS. |
371 |
* @return non-zero on success, zero on failure. All attempts to open a file |
|
372 |
* for writing via PhysicsFS will fail until this call succeeds. |
|
373 |
* Specifics of the error can be gleaned from PHYSFS_getLastError(). |
|
374 |
* |
|
375 |
*/ |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
376 |
int PHYSFS_setWriteDir(const char *newDir); |
1 | 377 |
|
378 |
||
379 |
/** |
|
380 |
* Add a directory or archive to the search path. If this is a duplicate, the |
|
381 |
* entry is not added again, even though the function succeeds. |
|
382 |
* |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
383 |
* @param newDir directory or archive to add to the path, in |
1 | 384 |
* platform-dependent notation. |
385 |
* @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
|
386 |
* @return nonzero if added to path, zero on failure (bogus archive, dir |
1 | 387 |
* missing, etc). Specifics of the error can be |
388 |
* gleaned from PHYSFS_getLastError(). |
|
389 |
*/ |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
390 |
int PHYSFS_addToSearchPath(const char *newDir, int appendToPath); |
1 | 391 |
|
392 |
||
393 |
/** |
|
2
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
394 |
* Remove a directory or archive from the search path. |
1 | 395 |
* |
396 |
* This must be a (case-sensitive) match to a dir or archive already in the |
|
397 |
* search path, specified in platform-dependent notation. |
|
398 |
* |
|
399 |
* This call will fail (and fail to remove from the path) if the element still |
|
400 |
* has files open in it. |
|
401 |
* |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
402 |
* @param oldDir dir/archive to remove. |
1 | 403 |
* @return nonzero on success, zero on failure. |
404 |
* Specifics of the error can be gleaned from PHYSFS_getLastError(). |
|
405 |
*/ |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
406 |
int PHYSFS_removeFromSearchPath(const char *oldDir); |
1 | 407 |
|
408 |
||
409 |
/** |
|
410 |
* Get the current search path. The default search path is an empty list. |
|
411 |
* |
|
412 |
* The returned value is an array of strings, with a NULL entry to signify the |
|
413 |
* end of the list: |
|
414 |
* |
|
415 |
* char **i; |
|
416 |
* |
|
417 |
* for (i = PHYSFS_getSearchPath(); *i != NULL; i++) |
|
418 |
* printf("[%s] is in the search path.\n", *i); |
|
419 |
* |
|
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
420 |
* 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
|
421 |
* resources by calling PHYSFS_freeList() with the returned pointer. |
1 | 422 |
* |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
423 |
* @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
|
424 |
* was a problem (read: OUT OF MEMORY). |
1 | 425 |
*/ |
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
426 |
char **PHYSFS_getSearchPath(void); |
1 | 427 |
|
428 |
||
429 |
/** |
|
430 |
* Helper function. |
|
431 |
* |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
432 |
* Set up sane, default paths. The write dir will be set to |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
433 |
* "userdir/.appName", which is created if it doesn't exist. |
1 | 434 |
* |
435 |
* The above is sufficient to make sure your program's configuration directory |
|
436 |
* is separated from other clutter, and platform-independent. The period |
|
437 |
* before "mygame" even hides the directory on Unix systems. |
|
438 |
* |
|
439 |
* The search path will be: |
|
440 |
* |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
441 |
* - The Write Dir (created if it doesn't exist) |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
442 |
* - The Write Dir/appName (created if it doesn't exist) |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
443 |
* - The Base Dir (PHYSFS_getBaseDir()) |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
444 |
* - The Base Dir/appName (if it exists) |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
445 |
* - All found CD-ROM dirs (optionally) |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
446 |
* - All found CD-ROM dirs/appName (optionally, and if they exist) |
1 | 447 |
* |
448 |
* These directories are then searched for files ending with the extension |
|
449 |
* (archiveExt), which, if they are valid and supported archives, will also |
|
450 |
* be added to the search path. If you specified "PKG" for (archiveExt), and |
|
451 |
* there's a file named data.PKG in the base dir, it'll be checked. Archives |
|
452 |
* can either be appended or prepended to the search path in alphabetical |
|
453 |
* order, regardless of which directories they were found in. |
|
454 |
* |
|
455 |
* 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
|
456 |
* all for you. Feel free to add more to the search path manually, too. |
1 | 457 |
* |
458 |
* @param appName Program-specific name of your program, to separate it |
|
459 |
* from other programs using PhysicsFS. |
|
460 |
* |
|
461 |
* @param archiveExt File extention used by your program to specify an |
|
462 |
* archive. For example, Quake 3 uses "pk3", even though |
|
463 |
* they are just zipfiles. Specify NULL to not dig out |
|
464 |
* archives automatically. |
|
465 |
* |
|
466 |
* @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
|
467 |
* (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
|
468 |
* 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
|
469 |
* 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
|
470 |
* 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
|
471 |
* 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
|
472 |
* 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
|
473 |
* yourself. |
1 | 474 |
* |
475 |
* @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
|
476 |
* Zero to append them. Ignored if !(archiveExt). |
1 | 477 |
*/ |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
478 |
void PHYSFS_setSaneConfig(const char *appName, const char *archiveExt, |
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
479 |
int includeCdRoms, int archivesFirst); |
1 | 480 |
|
481 |
||
482 |
/** |
|
483 |
* 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
|
484 |
* relation to the write dir. All missing parent directories are also |
1 | 485 |
* created if they don't exist. |
486 |
* |
|
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
487 |
* So if you've got the write dir set to "C:\mygame\writedir" and call |
1 | 488 |
* PHYSFS_mkdir("downloads/maps") then the directories |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
489 |
* "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
|
490 |
* 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
|
491 |
* 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
|
492 |
* created directory behind and reports failure. |
1 | 493 |
* |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
494 |
* @param dirname New dir to create. |
1 | 495 |
* @return nonzero on success, zero on error. Specifics of the error can be |
496 |
* gleaned from PHYSFS_getLastError(). |
|
497 |
*/ |
|
498 |
int PHYSFS_mkdir(const char *dirName); |
|
499 |
||
500 |
||
501 |
/** |
|
502 |
* 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
|
503 |
* notation in relation to the write dir. |
1 | 504 |
* |
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
505 |
* A directory must be empty before this call can delete it. |
1 | 506 |
* |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
507 |
* So if you've got the write dir set to "C:\mygame\writedir" and call |
1 | 508 |
* 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
|
509 |
* "C:\mygame\writedir\downloads\maps\level1.map" is removed from the |
1 | 510 |
* physical filesystem, if it exists and the operating system permits the |
511 |
* deletion. |
|
512 |
* |
|
2
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
513 |
* 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
|
514 |
* 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
|
515 |
* 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
|
516 |
* |
1 | 517 |
* @param filename Filename to delete. |
518 |
* @return nonzero on success, zero on error. Specifics of the error can be |
|
519 |
* gleaned from PHYSFS_getLastError(). |
|
520 |
*/ |
|
521 |
int PHYSFS_delete(const char *filename); |
|
522 |
||
523 |
||
524 |
/** |
|
525 |
* Enable symbolic links. Some physical filesystems and archives contain |
|
526 |
* files that are just pointers to other files. On the physical filesystem, |
|
527 |
* opening such a link will (transparently) open the file that is pointed to. |
|
528 |
* |
|
529 |
* By default, PhysicsFS will check if a file is really a symlink during open |
|
530 |
* calls and fail if it is. Otherwise, the link could take you outside the |
|
531 |
* write and search paths, and compromise security. |
|
532 |
* |
|
533 |
* If you want to take that risk, call this function with a non-zero parameter. |
|
534 |
* Note that this is more for sandboxing a program's scripting language, in |
|
535 |
* case untrusted scripts try to compromise the system. Generally speaking, |
|
536 |
* a user could very well have a legitimate reason to set up a symlink, so |
|
537 |
* unless you feel there's a specific danger in allowing them, you should |
|
538 |
* permit them. |
|
539 |
* |
|
540 |
* Symbolic link permission can be enabled or disabled at any time, and is |
|
541 |
* disabled by default. |
|
542 |
* |
|
543 |
* @param allow nonzero to permit symlinks, zero to deny linking. |
|
544 |
*/ |
|
545 |
void PHYSFS_permitSymbolicLinks(int allow); |
|
546 |
||
547 |
||
548 |
/** |
|
549 |
* Figure out where in the search path a file resides. The file is specified |
|
550 |
* in platform-independent notation. The returned filename will be the |
|
551 |
* element of the search path where the file was found, which may be a |
|
552 |
* directory, or an archive. Even if there are multiple matches in different |
|
553 |
* parts of the search path, only the first one found is used, just like |
|
554 |
* when opening a file. |
|
555 |
* |
|
556 |
* 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
|
557 |
* path and C:\mygame\maps\level1.map exists, then "C:\mygame" is returned. |
1 | 558 |
* |
2
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
559 |
* If a match is a symbolic link, and you've not explicitly permitted symlinks, |
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
560 |
* then it will be ignored, and the search for a match will continue. |
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
561 |
* |
1 | 562 |
* @param filename file to look for. |
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
563 |
* @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
|
564 |
* the file in question. NULL if not found. |
1 | 565 |
*/ |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
566 |
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
|
567 |
|
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
568 |
|
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
569 |
|
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
570 |
/** |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
571 |
* 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
|
572 |
* 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
|
573 |
* 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
|
574 |
* 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
|
575 |
* 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
|
576 |
* |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
577 |
* ------------------------------------------------ |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
578 |
* char **rc = PHYSFS_enumerateFiles("savegames"); |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
579 |
* char **i; |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
580 |
* |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
581 |
* for (i = rc; *i != NULL; i++) |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
582 |
* printf("We've got [%s].\n", *i); |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
583 |
* |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
584 |
* PHYSFS_freeList(rc); |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
585 |
* ------------------------------------------------ |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
586 |
* |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
587 |
* ...will print: |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
588 |
* |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
589 |
* ------------------------------------------------ |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
590 |
* We've got [x.sav]. |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
591 |
* We've got [y.sav]. |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
592 |
* We've got [z.sav]. |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
593 |
* We've got [w.sav]. |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
594 |
* ------------------------------------------------ |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
595 |
* |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
596 |
* 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
|
597 |
* 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
|
598 |
* |
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
599 |
* 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
|
600 |
* function when you are done with it. |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
601 |
* |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
602 |
* @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
|
603 |
* @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
|
604 |
*/ |
6
3662cbc014ef
More updates, corrections, clarifications...
Ryan C. Gordon <icculus@icculus.org>
parents:
3
diff
changeset
|
605 |
char **PHYSFS_enumerateFiles(const char *dir); |
1 | 606 |
|
607 |
||
608 |
/** |
|
609 |
* 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
|
610 |
* to the write dir as the root of the writable filesystem. The specified |
1 | 611 |
* file is created if it doesn't exist. If it does exist, it is truncated to |
612 |
* zero bytes, and the writing offset is set to the start. |
|
613 |
* |
|
614 |
* @param filename File to open. |
|
615 |
* @return A valid PhysicsFS filehandle on success, NULL on error. Specifics |
|
616 |
* of the error can be gleaned from PHYSFS_getLastError(). |
|
617 |
*/ |
|
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
618 |
PHYSFS_file *PHYSFS_openWrite(const char *filename); |
1 | 619 |
|
620 |
||
621 |
/** |
|
622 |
* 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
|
623 |
* to the write dir as the root of the writable filesystem. The specified |
1 | 624 |
* file is created if it doesn't exist. If it does exist, the writing offset |
625 |
* is set to the end of the file, so the first write will be the byte after |
|
626 |
* the end. |
|
627 |
* |
|
628 |
* @param filename File to open. |
|
629 |
* @return A valid PhysicsFS filehandle on success, NULL on error. Specifics |
|
630 |
* of the error can be gleaned from PHYSFS_getLastError(). |
|
631 |
*/ |
|
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
632 |
PHYSFS_file *PHYSFS_openAppend(const char *filename); |
1 | 633 |
|
634 |
||
635 |
/** |
|
636 |
* Open a file for reading, in platform-independent notation. The search path |
|
637 |
* is checked one at a time until a matching file is found, in which case an |
|
638 |
* abstract filehandle is associated with it, and reading may be done. |
|
639 |
* The reading offset is set to the first byte of the file. |
|
640 |
* |
|
641 |
* @param filename File to open. |
|
642 |
* @return A valid PhysicsFS filehandle on success, NULL on error. Specifics |
|
643 |
* of the error can be gleaned from PHYSFS_getLastError(). |
|
644 |
*/ |
|
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
645 |
PHYSFS_file *PHYSFS_openRead(const char *filename); |
1 | 646 |
|
647 |
||
648 |
/** |
|
649 |
* Close a PhysicsFS filehandle. This call is capable of failing if the |
|
650 |
* operating system was buffering writes to this file, and (now forced to |
|
651 |
* write those changes to physical media) can not store the data for any |
|
652 |
* reason. In such a case, the filehandle stays open. A well-written program |
|
653 |
* should ALWAYS check the return value from the close call in addition to |
|
654 |
* every writing call! |
|
655 |
* |
|
656 |
* @param handle handle returned from PHYSFS_open*(). |
|
657 |
* @return nonzero on success, zero on error. Specifics of the error can be |
|
658 |
* gleaned from PHYSFS_getLastError(). |
|
659 |
*/ |
|
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
660 |
int PHYSFS_close(PHYSFS_file *handle); |
1 | 661 |
|
662 |
||
663 |
/** |
|
664 |
* Read data from a PhysicsFS filehandle. The file must be opened for reading. |
|
665 |
* |
|
666 |
* @param handle handle returned from PHYSFS_openRead(). |
|
667 |
* @param buffer buffer to store read data into. |
|
668 |
* @param objSize size in bytes of objects being read from (handle). |
|
669 |
* @param objCount number of (objSize) objects to read from (handle). |
|
670 |
* @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
|
671 |
* the reason this might be < (objCount), as can PHYSFS_eof(). |
1 | 672 |
*/ |
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
673 |
int PHYSFS_read(PHYSFS_file *handle, void *buffer, |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
674 |
unsigned int objSize, unsigned int objCount); |
1 | 675 |
|
676 |
||
677 |
/** |
|
678 |
* Write data to a PhysicsFS filehandle. The file must be opened for writing. |
|
679 |
* |
|
680 |
* @param handle retval from PHYSFS_openWrite() or PHYSFS_openAppend(). |
|
681 |
* @param buffer buffer to store read data into. |
|
682 |
* @param objSize size in bytes of objects being read from (handle). |
|
683 |
* @param objCount number of (objSize) objects to read from (handle). |
|
684 |
* @return number of objects read. PHYSFS_getLastError() can shed light on |
|
685 |
* the reason this might be < (objCount). |
|
686 |
*/ |
|
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
687 |
int PHYSFS_write(PHYSFS_file *handle, void *buffer, |
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
688 |
unsigned int objSize, unsigned int objCount); |
1 | 689 |
|
690 |
||
691 |
/** |
|
692 |
* Determine if the end of file has been reached in a PhysicsFS filehandle. |
|
693 |
* |
|
694 |
* @param handle handle returned from PHYSFS_openRead(). |
|
695 |
* @return nonzero if EOF, zero if not. |
|
696 |
*/ |
|
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
697 |
int PHYSFS_eof(PHYSFS_file *handle); |
1 | 698 |
|
699 |
||
700 |
/** |
|
701 |
* Determine current position within a PhysicsFS filehandle. |
|
702 |
* |
|
703 |
* @param handle handle returned from PHYSFS_open*(). |
|
704 |
* @return offset in bytes from start of file. -1 if error occurred. |
|
705 |
* Specifics of the error can be gleaned from PHYSFS_getLastError(). |
|
706 |
*/ |
|
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
707 |
int PHYSFS_tell(PHYSFS_file *handle); |
1 | 708 |
|
709 |
||
710 |
/** |
|
711 |
* Seek to a new position within a PhysicsFS filehandle. The next read or write |
|
712 |
* will occur at that place. Seeking past the beginning or end of the file is |
|
713 |
* not allowed. |
|
714 |
* |
|
715 |
* @param handle handle returned from PHYSFS_open*(). |
|
716 |
* @param pos number of bytes from start of file to seek to. |
|
717 |
* @return nonzero on success, zero on error. Specifics of the error can be |
|
718 |
* gleaned from PHYSFS_getLastError(). |
|
719 |
*/ |
|
3
0dd785321345
Boatloads of updates to the spec.
Ryan C. Gordon <icculus@icculus.org>
parents:
2
diff
changeset
|
720 |
int PHYSFS_seek(PHYSFS_file *handle, int pos); |
2
24ba671694af
Fixed typos, expanded documentation, added init and deinit functions, and
Ryan C. Gordon <icculus@icculus.org>
parents:
1
diff
changeset
|
721 |
|
1 | 722 |
#ifdef __cplusplus |
723 |
} |
|
724 |
#endif |
|
725 |
||
726 |
#endif /* !defined _INCLUDE_PHYSFS_H_ */ |
|
727 |
||
728 |
/* end of physfs.h ... */ |
|
729 |