1 /**
2  * \file physfs.h
3  *
4  * Main header file for PhysicsFS.
5  */
6 
7 /**
8  * \mainpage PhysicsFS
9  *
10  * The latest version of PhysicsFS can be found at:
11  *     https://icculus.org/physfs/
12  *
13  * PhysicsFS; a portable, flexible file i/o abstraction.
14  *
15  * This API gives you access to a system file system in ways superior to the
16  *  stdio or system i/o calls. The brief benefits:
17  *
18  *   - It's portable.
19  *   - It's safe. No file access is permitted outside the specified dirs.
20  *   - It's flexible. Archives (.ZIP files) can be used transparently as
21  *      directory structures.
22  *
23  * With PhysicsFS, you have a single writing directory and multiple
24  *  directories (the "search path") for reading. You can think of this as a
25  *  filesystem within a filesystem. If (on Windows) you were to set the
26  *  writing directory to "C:\MyGame\MyWritingDirectory", then no PHYSFS calls
27  *  could touch anything above this directory, including the "C:\MyGame" and
28  *  "C:\" directories. This prevents an application's internal scripting
29  *  language from piddling over c:\\config.sys, for example. If you'd rather
30  *  give PHYSFS full access to the system's REAL file system, set the writing
31  *  dir to "C:\", but that's generally A Bad Thing for several reasons.
32  *
33  * Drive letters are hidden in PhysicsFS once you set up your initial paths.
34  *  The search path creates a single, hierarchical directory structure.
35  *  Not only does this lend itself well to general abstraction with archives,
36  *  it also gives better support to operating systems like MacOS and Unix.
37  *  Generally speaking, you shouldn't ever hardcode a drive letter; not only
38  *  does this hurt portability to non-Microsoft OSes, but it limits your win32
39  *  users to a single drive, too. Use the PhysicsFS abstraction functions and
40  *  allow user-defined configuration options, too. When opening a file, you
41  *  specify it like it was on a Unix filesystem: if you want to write to
42  *  "C:\MyGame\MyConfigFiles\game.cfg", then you might set the write dir to
43  *  "C:\MyGame" and then open "MyConfigFiles/game.cfg". This gives an
44  *  abstraction across all platforms. Specifying a file in this way is termed
45  *  "platform-independent notation" in this documentation. Specifying a
46  *  a filename in a form such as "C:\mydir\myfile" or
47  *  "MacOS hard drive:My Directory:My File" is termed "platform-dependent
48  *  notation". The only time you use platform-dependent notation is when
49  *  setting up your write directory and search path; after that, all file
50  *  access into those directories are done with platform-independent notation.
51  *
52  * All files opened for writing are opened in relation to the write directory,
53  *  which is the root of the writable filesystem. When opening a file for
54  *  reading, PhysicsFS goes through the search path. This is NOT the
55  *  same thing as the PATH environment variable. An application using
56  *  PhysicsFS specifies directories to be searched which may be actual
57  *  directories, or archive files that contain files and subdirectories of
58  *  their own. See the end of these docs for currently supported archive
59  *  formats.
60  *
61  * Once the search path is defined, you may open files for reading. If you've
62  *  got the following search path defined (to use a win32 example again):
63  *
64  *  - C:\\mygame
65  *  - C:\\mygame\\myuserfiles
66  *  - D:\\mygamescdromdatafiles
67  *  - C:\\mygame\\installeddatafiles.zip
68  *
69  * Then a call to PHYSFS_openRead("textfiles/myfile.txt") (note the directory
70  *  separator, lack of drive letter, and lack of dir separator at the start of
71  *  the string; this is platform-independent notation) will check for
72  *  C:\\mygame\\textfiles\\myfile.txt, then
73  *  C:\\mygame\\myuserfiles\\textfiles\\myfile.txt, then
74  *  D:\\mygamescdromdatafiles\\textfiles\\myfile.txt, then, finally, for
75  *  textfiles\\myfile.txt inside of C:\\mygame\\installeddatafiles.zip.
76  *  Remember that most archive types and platform filesystems store their
77  *  filenames in a case-sensitive manner, so you should be careful to specify
78  *  it correctly.
79  *
80  * Files opened through PhysicsFS may NOT contain "." or ".." or ":" as dir
81  *  elements. Not only are these meaningless on MacOS Classic and/or Unix,
82  *  they are a security hole. Also, symbolic links (which can be found in
83  *  some archive types and directly in the filesystem on Unix platforms) are
84  *  NOT followed until you call PHYSFS_permitSymbolicLinks(). That's left to
85  *  your own discretion, as following a symlink can allow for access outside
86  *  the write dir and search paths. For portability, there is no mechanism for
87  *  creating new symlinks in PhysicsFS.
88  *
89  * The write dir is not included in the search path unless you specifically
90  *  add it. While you CAN change the write dir as many times as you like,
91  *  you should probably set it once and stick to it. Remember that your
92  *  program will not have permission to write in every directory on Unix and
93  *  NT systems.
94  *
95  * All files are opened in binary mode; there is no endline conversion for
96  *  textfiles. Other than that, PhysicsFS has some convenience functions for
97  *  platform-independence. There is a function to tell you the current
98  *  platform's dir separator ("\\" on windows, "/" on Unix, ":" on MacOS),
99  *  which is needed only to set up your search/write paths. There is a
100  *  function to tell you what CD-ROM drives contain accessible discs, and a
101  *  function to recommend a good search path, etc.
102  *
103  * A recommended order for the search path is the write dir, then the base dir,
104  *  then the cdrom dir, then any archives discovered. Quake 3 does something
105  *  like this, but moves the archives to the start of the search path. Build
106  *  Engine games, like Duke Nukem 3D and Blood, place the archives last, and
107  *  use the base dir for both searching and writing. There is a helper
108  *  function (PHYSFS_setSaneConfig()) that puts together a basic configuration
109  *  for you, based on a few parameters. Also see the comments on
110  *  PHYSFS_getBaseDir(), and PHYSFS_getPrefDir() for info on what those
111  *  are and how they can help you determine an optimal search path.
112  *
113  * PhysicsFS 2.0 adds the concept of "mounting" archives to arbitrary points
114  *  in the search path. If a zipfile contains "maps/level.map" and you mount
115  *  that archive at "mods/mymod", then you would have to open
116  *  "mods/mymod/maps/level.map" to access the file, even though "mods/mymod"
117  *  isn't actually specified in the .zip file. Unlike the Unix mentality of
118  *  mounting a filesystem, "mods/mymod" doesn't actually have to exist when
119  *  mounting the zipfile. It's a "virtual" directory. The mounting mechanism
120  *  allows the developer to seperate archives in the tree and avoid trampling
121  *  over files when added new archives, such as including mod support in a
122  *  game...keeping external content on a tight leash in this manner can be of
123  *  utmost importance to some applications.
124  *
125  * PhysicsFS is mostly thread safe. The errors returned by
126  *  PHYSFS_getLastErrorCode() are unique by thread, and library-state-setting
127  *  functions are mutex'd. For efficiency, individual file accesses are
128  *  not locked, so you can not safely read/write/seek/close/etc the same
129  *  file from two threads at the same time. Other race conditions are bugs
130  *  that should be reported/patched.
131  *
132  * While you CAN use stdio/syscall file access in a program that has PHYSFS_*
133  *  calls, doing so is not recommended, and you can not directly use system
134  *  filehandles with PhysicsFS and vice versa (but as of PhysicsFS 2.1, you
135  *  can wrap them in a PHYSFS_Io interface yourself if you wanted to).
136  *
137  * Note that archives need not be named as such: if you have a ZIP file and
138  *  rename it with a .PKG extension, the file will still be recognized as a
139  *  ZIP archive by PhysicsFS; the file's contents are used to determine its
140  *  type where possible.
141  *
142  * Currently supported archive types:
143  *   - .ZIP (pkZip/WinZip/Info-ZIP compatible)
144  *   - .7Z  (7zip archives)
145  *   - .ISO (ISO9660 files, CD-ROM images)
146  *   - .GRP (Build Engine groupfile archives)
147  *   - .PAK (Quake I/II archive format)
148  *   - .HOG (Descent I/II HOG file archives)
149  *   - .MVL (Descent II movielib archives)
150  *   - .WAD (DOOM engine archives)
151  *   - .VDF (Gothic I/II engine archives)
152  *   - .SLB (Independence War archives)
153  *
154  * String policy for PhysicsFS 2.0 and later:
155  *
156  * PhysicsFS 1.0 could only deal with null-terminated ASCII strings. All high
157  *  ASCII chars resulted in undefined behaviour, and there was no Unicode
158  *  support at all. PhysicsFS 2.0 supports Unicode without breaking binary
159  *  compatibility with the 1.0 API by using UTF-8 encoding of all strings
160  *  passed in and out of the library.
161  *
162  * All strings passed through PhysicsFS are in null-terminated UTF-8 format.
163  *  This means that if all you care about is English (ASCII characters <= 127)
164  *  then you just use regular C strings. If you care about Unicode (and you
165  *  should!) then you need to figure out what your platform wants, needs, and
166  *  offers. If you are on Windows before Win2000 and build with Unicode
167  *  support, your TCHAR strings are two bytes per character (this is called
168  *  "UCS-2 encoding"). Any modern Windows uses UTF-16, which is two bytes
169  *  per character for most characters, but some characters are four. You
170  *  should convert them to UTF-8 before handing them to PhysicsFS with
171  *  PHYSFS_utf8FromUtf16(), which handles both UTF-16 and UCS-2. If you're
172  *  using Unix or Mac OS X, your wchar_t strings are four bytes per character
173  *  ("UCS-4 encoding", sometimes called "UTF-32"). Use PHYSFS_utf8FromUcs4().
174  *  Mac OS X can give you UTF-8 directly from a CFString or NSString, and many
175  *  Unixes generally give you C strings in UTF-8 format everywhere. If you
176  *  have a single-byte high ASCII charset, like so-many European "codepages"
177  *  you may be out of luck. We'll convert from "Latin1" to UTF-8 only, and
178  *  never back to Latin1. If you're above ASCII 127, all bets are off: move
179  *  to Unicode or use your platform's facilities. Passing a C string with
180  *  high-ASCII data that isn't UTF-8 encoded will NOT do what you expect!
181  *
182  * Naturally, there's also PHYSFS_utf8ToUcs2(), PHYSFS_utf8ToUtf16(), and
183  *  PHYSFS_utf8ToUcs4() to get data back into a format you like. Behind the
184  *  scenes, PhysicsFS will use Unicode where possible: the UTF-8 strings on
185  *  Windows will be converted and used with the multibyte Windows APIs, for
186  *  example.
187  *
188  * PhysicsFS offers basic encoding conversion support, but not a whole string
189  *  library. Get your stuff into whatever format you can work with.
190  *
191  * Most platforms supported by PhysicsFS 2.1 and later fully support Unicode.
192  *  Some older platforms have been dropped (Windows 95, Mac OS 9). Some, like
193  *  OS/2, might be able to convert to a local codepage or will just fail to
194  *  open/create the file. Modern OSes (macOS, Linux, Windows, etc) should all
195  *  be fine.
196  *
197  * Many game-specific archivers are seriously unprepared for Unicode (the
198  *  Descent HOG/MVL and Build Engine GRP archivers, for example, only offer a
199  *  DOS 8.3 filename, for example). Nothing can be done for these, but they
200  *  tend to be legacy formats for existing content that was all ASCII (and
201  *  thus, valid UTF-8) anyhow. Other formats, like .ZIP, don't explicitly
202  *  offer Unicode support, but unofficially expect filenames to be UTF-8
203  *  encoded, and thus Just Work. Most everything does the right thing without
204  *  bothering you, but it's good to be aware of these nuances in case they
205  *  don't.
206  *
207  *
208  * Other stuff:
209  *
210  * Please see the file LICENSE.txt in the source's root directory for
211  *  licensing and redistribution rights.
212  *
213  * Please see the file CREDITS.txt in the source's "docs" directory for
214  *  a more or less complete list of who's responsible for this.
215  *
216  *  \author Ryan C. Gordon.
217  */
218 
219 #ifndef _INCLUDE_PHYSFS_H_
220 #define _INCLUDE_PHYSFS_H_
221 
222 #ifdef __cplusplus
223 extern "C" {
224 #endif
225 
226 #if defined(PHYSFS_DECL)
227 /* do nothing. */
228 #elif defined(_MSC_VER)
229 #define PHYSFS_DECL __declspec(dllexport)
230 #elif defined(__SUNPRO_C)
231 #define PHYSFS_DECL __global
232 #elif ((__GNUC__ >= 3) && (!defined(__EMX__)) && (!defined(sun)))
233 #define PHYSFS_DECL __attribute__((visibility("default")))
234 #else
235 #define PHYSFS_DECL
236 #endif
237 
238 #if defined(PHYSFS_DEPRECATED)
239 /* do nothing. */
240 #elif (__GNUC__ >= 4)  /* technically, this arrived in gcc 3.1, but oh well. */
241 #define PHYSFS_DEPRECATED __attribute__((deprecated))
242 #else
243 #define PHYSFS_DEPRECATED
244 #endif
245 
246 #if 0  /* !!! FIXME: look into this later. */
247 #if defined(PHYSFS_CALL)
248 /* do nothing. */
249 #elif defined(__WIN32__) && !defined(__GNUC__)
250 #define PHYSFS_CALL __cdecl
251 #elif defined(__OS2__) || defined(OS2) /* should work across all compilers. */
252 #define PHYSFS_CALL _System
253 #else
254 #define PHYSFS_CALL
255 #endif
256 #endif
257 
258 /**
259  * \typedef PHYSFS_uint8
260  * \brief An unsigned, 8-bit integer type.
261  */
262 typedef unsigned char         PHYSFS_uint8;
263 
264 /**
265  * \typedef PHYSFS_sint8
266  * \brief A signed, 8-bit integer type.
267  */
268 typedef signed char           PHYSFS_sint8;
269 
270 /**
271  * \typedef PHYSFS_uint16
272  * \brief An unsigned, 16-bit integer type.
273  */
274 typedef unsigned short        PHYSFS_uint16;
275 
276 /**
277  * \typedef PHYSFS_sint16
278  * \brief A signed, 16-bit integer type.
279  */
280 typedef signed short          PHYSFS_sint16;
281 
282 /**
283  * \typedef PHYSFS_uint32
284  * \brief An unsigned, 32-bit integer type.
285  */
286 typedef unsigned int          PHYSFS_uint32;
287 
288 /**
289  * \typedef PHYSFS_sint32
290  * \brief A signed, 32-bit integer type.
291  */
292 typedef signed int            PHYSFS_sint32;
293 
294 /**
295  * \typedef PHYSFS_uint64
296  * \brief An unsigned, 64-bit integer type.
297  * \warning on platforms without any sort of 64-bit datatype, this is
298  *           equivalent to PHYSFS_uint32!
299  */
300 
301 /**
302  * \typedef PHYSFS_sint64
303  * \brief A signed, 64-bit integer type.
304  * \warning on platforms without any sort of 64-bit datatype, this is
305  *           equivalent to PHYSFS_sint32!
306  */
307 
308 
309 #if (defined PHYSFS_NO_64BIT_SUPPORT)  /* oh well. */
310 typedef PHYSFS_uint32         PHYSFS_uint64;
311 typedef PHYSFS_sint32         PHYSFS_sint64;
312 #elif (defined _MSC_VER)
313 typedef signed __int64        PHYSFS_sint64;
314 typedef unsigned __int64      PHYSFS_uint64;
315 #else
316 typedef unsigned long long    PHYSFS_uint64;
317 typedef signed long long      PHYSFS_sint64;
318 #endif
319 
320 
321 #ifndef DOXYGEN_SHOULD_IGNORE_THIS
322 /* Make sure the types really have the right sizes */
323 #define PHYSFS_COMPILE_TIME_ASSERT(name, x) \
324        typedef int PHYSFS_compile_time_assert_##name[(x) * 2 - 1]
325 
326 PHYSFS_COMPILE_TIME_ASSERT(uint8IsOneByte, sizeof(PHYSFS_uint8) == 1);
327 PHYSFS_COMPILE_TIME_ASSERT(sint8IsOneByte, sizeof(PHYSFS_sint8) == 1);
328 PHYSFS_COMPILE_TIME_ASSERT(uint16IsTwoBytes, sizeof(PHYSFS_uint16) == 2);
329 PHYSFS_COMPILE_TIME_ASSERT(sint16IsTwoBytes, sizeof(PHYSFS_sint16) == 2);
330 PHYSFS_COMPILE_TIME_ASSERT(uint32IsFourBytes, sizeof(PHYSFS_uint32) == 4);
331 PHYSFS_COMPILE_TIME_ASSERT(sint32IsFourBytes, sizeof(PHYSFS_sint32) == 4);
332 
333 #ifndef PHYSFS_NO_64BIT_SUPPORT
334 PHYSFS_COMPILE_TIME_ASSERT(uint64IsEightBytes, sizeof(PHYSFS_uint64) == 8);
335 PHYSFS_COMPILE_TIME_ASSERT(sint64IsEightBytes, sizeof(PHYSFS_sint64) == 8);
336 #endif
337 
338 #undef PHYSFS_COMPILE_TIME_ASSERT
339 
340 #endif  /* DOXYGEN_SHOULD_IGNORE_THIS */
341 
342 
343 /**
344  * \struct PHYSFS_File
345  * \brief A PhysicsFS file handle.
346  *
347  * You get a pointer to one of these when you open a file for reading,
348  *  writing, or appending via PhysicsFS.
349  *
350  * As you can see from the lack of meaningful fields, you should treat this
351  *  as opaque data. Don't try to manipulate the file handle, just pass the
352  *  pointer you got, unmolested, to various PhysicsFS APIs.
353  *
354  * \sa PHYSFS_openRead
355  * \sa PHYSFS_openWrite
356  * \sa PHYSFS_openAppend
357  * \sa PHYSFS_close
358  * \sa PHYSFS_read
359  * \sa PHYSFS_write
360  * \sa PHYSFS_seek
361  * \sa PHYSFS_tell
362  * \sa PHYSFS_eof
363  * \sa PHYSFS_setBuffer
364  * \sa PHYSFS_flush
365  */
366 typedef struct PHYSFS_File
367 {
368     void *opaque;  /**< That's all you get. Don't touch. */
369 } PHYSFS_File;
370 
371 
372 /**
373  * \def PHYSFS_file
374  * \brief 1.0 API compatibility define.
375  *
376  * PHYSFS_file is identical to PHYSFS_File. This #define is here for backwards
377  *  compatibility with the 1.0 API, which had an inconsistent capitalization
378  *  convention in this case. New code should use PHYSFS_File, as this #define
379  *  may go away someday.
380  *
381  * \sa PHYSFS_File
382  */
383 #define PHYSFS_file PHYSFS_File
384 
385 
386 /**
387  * \struct PHYSFS_ArchiveInfo
388  * \brief Information on various PhysicsFS-supported archives.
389  *
390  * This structure gives you details on what sort of archives are supported
391  *  by this implementation of PhysicsFS. Archives tend to be things like
392  *  ZIP files and such.
393  *
394  * \warning Not all binaries are created equal! PhysicsFS can be built with
395  *          or without support for various archives. You can check with
396  *          PHYSFS_supportedArchiveTypes() to see if your archive type is
397  *          supported.
398  *
399  * \sa PHYSFS_supportedArchiveTypes
400  * \sa PHYSFS_registerArchiver
401  * \sa PHYSFS_deregisterArchiver
402  */
403 typedef struct PHYSFS_ArchiveInfo
404 {
405     const char *extension;   /**< Archive file extension: "ZIP", for example. */
406     const char *description; /**< Human-readable archive description. */
407     const char *author;      /**< Person who did support for this archive. */
408     const char *url;         /**< URL related to this archive */
409     int supportsSymlinks;    /**< non-zero if archive offers symbolic links. */
410 } PHYSFS_ArchiveInfo;
411 
412 
413 /**
414  * \struct PHYSFS_Version
415  * \brief Information the version of PhysicsFS in use.
416  *
417  * Represents the library's version as three levels: major revision
418  *  (increments with massive changes, additions, and enhancements),
419  *  minor revision (increments with backwards-compatible changes to the
420  *  major revision), and patchlevel (increments with fixes to the minor
421  *  revision).
422  *
423  * \sa PHYSFS_VERSION
424  * \sa PHYSFS_getLinkedVersion
425  */
426 typedef struct PHYSFS_Version
427 {
428     PHYSFS_uint8 major; /**< major revision */
429     PHYSFS_uint8 minor; /**< minor revision */
430     PHYSFS_uint8 patch; /**< patchlevel */
431 } PHYSFS_Version;
432 
433 
434 #ifndef DOXYGEN_SHOULD_IGNORE_THIS
435 #define PHYSFS_VER_MAJOR 3
436 #define PHYSFS_VER_MINOR 0
437 #define PHYSFS_VER_PATCH 2
438 #endif  /* DOXYGEN_SHOULD_IGNORE_THIS */
439 
440 
441 /* PhysicsFS state stuff ... */
442 
443 /**
444  * \def PHYSFS_VERSION(x)
445  * \brief Macro to determine PhysicsFS version program was compiled against.
446  *
447  * This macro fills in a PHYSFS_Version structure with the version of the
448  *  library you compiled against. This is determined by what header the
449  *  compiler uses. Note that if you dynamically linked the library, you might
450  *  have a slightly newer or older version at runtime. That version can be
451  *  determined with PHYSFS_getLinkedVersion(), which, unlike PHYSFS_VERSION,
452  *  is not a macro.
453  *
454  * \param x A pointer to a PHYSFS_Version struct to initialize.
455  *
456  * \sa PHYSFS_Version
457  * \sa PHYSFS_getLinkedVersion
458  */
459 #define PHYSFS_VERSION(x) \
460 { \
461     (x)->major = PHYSFS_VER_MAJOR; \
462     (x)->minor = PHYSFS_VER_MINOR; \
463     (x)->patch = PHYSFS_VER_PATCH; \
464 }
465 
466 
467 /**
468  * \fn void PHYSFS_getLinkedVersion(PHYSFS_Version *ver)
469  * \brief Get the version of PhysicsFS that is linked against your program.
470  *
471  * If you are using a shared library (DLL) version of PhysFS, then it is
472  *  possible that it will be different than the version you compiled against.
473  *
474  * This is a real function; the macro PHYSFS_VERSION tells you what version
475  *  of PhysFS you compiled against:
476  *
477  * \code
478  * PHYSFS_Version compiled;
479  * PHYSFS_Version linked;
480  *
481  * PHYSFS_VERSION(&compiled);
482  * PHYSFS_getLinkedVersion(&linked);
483  * printf("We compiled against PhysFS version %d.%d.%d ...\n",
484  *           compiled.major, compiled.minor, compiled.patch);
485  * printf("But we linked against PhysFS version %d.%d.%d.\n",
486  *           linked.major, linked.minor, linked.patch);
487  * \endcode
488  *
489  * This function may be called safely at any time, even before PHYSFS_init().
490  *
491  * \sa PHYSFS_VERSION
492  */
493 PHYSFS_DECL void PHYSFS_getLinkedVersion(PHYSFS_Version *ver);
494 
495 
496 /**
497  * \fn int PHYSFS_init(const char *argv0)
498  * \brief Initialize the PhysicsFS library.
499  *
500  * This must be called before any other PhysicsFS function.
501  *
502  * This should be called prior to any attempts to change your process's
503  *  current working directory.
504  *
505  *   \param argv0 the argv[0] string passed to your program's mainline.
506  *          This may be NULL on most platforms (such as ones without a
507  *          standard main() function), but you should always try to pass
508  *          something in here. Unix-like systems such as Linux _need_ to
509  *          pass argv[0] from main() in here.
510  *  \return nonzero on success, zero on error. Specifics of the error can be
511  *          gleaned from PHYSFS_getLastError().
512  *
513  * \sa PHYSFS_deinit
514  * \sa PHYSFS_isInit
515  */
516 PHYSFS_DECL int PHYSFS_init(const char *argv0);
517 
518 
519 /**
520  * \fn int PHYSFS_deinit(void)
521  * \brief Deinitialize the PhysicsFS library.
522  *
523  * This closes any files opened via PhysicsFS, blanks the search/write paths,
524  *  frees memory, and invalidates all of your file handles.
525  *
526  * Note that this call can FAIL if there's a file open for writing that
527  *  refuses to close (for example, the underlying operating system was
528  *  buffering writes to network filesystem, and the fileserver has crashed,
529  *  or a hard drive has failed, etc). It is usually best to close all write
530  *  handles yourself before calling this function, so that you can gracefully
531  *  handle a specific failure.
532  *
533  * Once successfully deinitialized, PHYSFS_init() can be called again to
534  *  restart the subsystem. All default API states are restored at this
535  *  point, with the exception of any custom allocator you might have
536  *  specified, which survives between initializations.
537  *
538  *  \return nonzero on success, zero on error. Specifics of the error can be
539  *          gleaned from PHYSFS_getLastError(). If failure, state of PhysFS is
540  *          undefined, and probably badly screwed up.
541  *
542  * \sa PHYSFS_init
543  * \sa PHYSFS_isInit
544  */
545 PHYSFS_DECL int PHYSFS_deinit(void);
546 
547 
548 /**
549  * \fn const PHYSFS_ArchiveInfo **PHYSFS_supportedArchiveTypes(void)
550  * \brief Get a list of supported archive types.
551  *
552  * Get a list of archive types supported by this implementation of PhysicFS.
553  *  These are the file formats usable for search path entries. This is for
554  *  informational purposes only. Note that the extension listed is merely
555  *  convention: if we list "ZIP", you can open a PkZip-compatible archive
556  *  with an extension of "XYZ", if you like.
557  *
558  * The returned value is an array of pointers to PHYSFS_ArchiveInfo structures,
559  *  with a NULL entry to signify the end of the list:
560  *
561  * \code
562  * PHYSFS_ArchiveInfo **i;
563  *
564  * for (i = PHYSFS_supportedArchiveTypes(); *i != NULL; i++)
565  * {
566  *     printf("Supported archive: [%s], which is [%s].\n",
567  *              (*i)->extension, (*i)->description);
568  * }
569  * \endcode
570  *
571  * The return values are pointers to internal memory, and should
572  *  be considered READ ONLY, and never freed. The returned values are
573  *  valid until the next call to PHYSFS_deinit(), PHYSFS_registerArchiver(),
574  *  or PHYSFS_deregisterArchiver().
575  *
576  *   \return READ ONLY Null-terminated array of READ ONLY structures.
577  *
578  * \sa PHYSFS_registerArchiver
579  * \sa PHYSFS_deregisterArchiver
580  */
581 PHYSFS_DECL const PHYSFS_ArchiveInfo **PHYSFS_supportedArchiveTypes(void);
582 
583 
584 /**
585  * \fn void PHYSFS_freeList(void *listVar)
586  * \brief Deallocate resources of lists returned by PhysicsFS.
587  *
588  * Certain PhysicsFS functions return lists of information that are
589  *  dynamically allocated. Use this function to free those resources.
590  *
591  * It is safe to pass a NULL here, but doing so will cause a crash in versions
592  *  before PhysicsFS 2.1.0.
593  *
594  *   \param listVar List of information specified as freeable by this function.
595  *                  Passing NULL is safe; it is a valid no-op.
596  *
597  * \sa PHYSFS_getCdRomDirs
598  * \sa PHYSFS_enumerateFiles
599  * \sa PHYSFS_getSearchPath
600  */
601 PHYSFS_DECL void PHYSFS_freeList(void *listVar);
602 
603 
604 /**
605  * \fn const char *PHYSFS_getLastError(void)
606  * \brief Get human-readable error information.
607  *
608  * \deprecated Use PHYSFS_getLastErrorCode() and PHYSFS_getErrorByCode() instead.
609  *
610  * \warning As of PhysicsFS 2.1, this function has been nerfed.
611  *          Before PhysicsFS 2.1, this function was the only way to get
612  *          error details beyond a given function's basic return value.
613  *          This was meant to be a human-readable string in one of several
614  *          languages, and was not useful for application parsing. This was
615  *          a problem, because the developer and not the user chose the
616  *          language at compile time, and the PhysicsFS maintainers had
617  *          to (poorly) maintain a significant amount of localization work.
618  *          The app couldn't parse the strings, even if they counted on a
619  *          specific language, since some were dynamically generated.
620  *          In 2.1 and later, this always returns a static string in
621  *          English; you may use it as a key string for your own
622  *          localizations if you like, as we'll promise not to change
623  *          existing error strings. Also, if your application wants to
624  *          look at specific errors, we now offer a better option:
625  *          use PHYSFS_getLastErrorCode() instead.
626  *
627  * Get the last PhysicsFS error message as a human-readable, null-terminated
628  *  string. This will return NULL if there's been no error since the last call
629  *  to this function. The pointer returned by this call points to an internal
630  *  buffer. Each thread has a unique error state associated with it, but each
631  *  time a new error message is set, it will overwrite the previous one
632  *  associated with that thread. It is safe to call this function at anytime,
633  *  even before PHYSFS_init().
634  *
635  * PHYSFS_getLastError() and PHYSFS_getLastErrorCode() both reset the same
636  *  thread-specific error state. Calling one will wipe out the other's
637  *  data. If you need both, call PHYSFS_getLastErrorCode(), then pass that
638  *  value to PHYSFS_getErrorByCode().
639  *
640  * As of PhysicsFS 2.1, this function only presents text in the English
641  *  language, but the strings are static, so you can use them as keys into
642  *  your own localization dictionary. These strings are meant to be passed on
643  *  directly to the user.
644  *
645  * Generally, applications should only concern themselves with whether a
646  *  given function failed; however, if your code require more specifics, you
647  *  should use PHYSFS_getLastErrorCode() instead of this function.
648  *
649  *   \return READ ONLY string of last error message.
650  *
651  * \sa PHYSFS_getLastErrorCode
652  * \sa PHYSFS_getErrorByCode
653  */
654 PHYSFS_DECL const char *PHYSFS_getLastError(void) PHYSFS_DEPRECATED;
655 
656 
657 /**
658  * \fn const char *PHYSFS_getDirSeparator(void)
659  * \brief Get platform-dependent dir separator string.
660  *
661  * This returns "\\" on win32, "/" on Unix, and ":" on MacOS. It may be more
662  *  than one character, depending on the platform, and your code should take
663  *  that into account. Note that this is only useful for setting up the
664  *  search/write paths, since access into those dirs always use '/'
665  *  (platform-independent notation) to separate directories. This is also
666  *  handy for getting platform-independent access when using stdio calls.
667  *
668  *   \return READ ONLY null-terminated string of platform's dir separator.
669  */
670 PHYSFS_DECL const char *PHYSFS_getDirSeparator(void);
671 
672 
673 /**
674  * \fn void PHYSFS_permitSymbolicLinks(int allow)
675  * \brief Enable or disable following of symbolic links.
676  *
677  * Some physical filesystems and archives contain files that are just pointers
678  *  to other files. On the physical filesystem, opening such a link will
679  *  (transparently) open the file that is pointed to.
680  *
681  * By default, PhysicsFS will check if a file is really a symlink during open
682  *  calls and fail if it is. Otherwise, the link could take you outside the
683  *  write and search paths, and compromise security.
684  *
685  * If you want to take that risk, call this function with a non-zero parameter.
686  *  Note that this is more for sandboxing a program's scripting language, in
687  *  case untrusted scripts try to compromise the system. Generally speaking,
688  *  a user could very well have a legitimate reason to set up a symlink, so
689  *  unless you feel there's a specific danger in allowing them, you should
690  *  permit them.
691  *
692  * Symlinks are only explicitly checked when dealing with filenames
693  *  in platform-independent notation. That is, when setting up your
694  *  search and write paths, etc, symlinks are never checked for.
695  *
696  * Please note that PHYSFS_stat() will always check the path specified; if
697  *  that path is a symlink, it will not be followed in any case. If symlinks
698  *  aren't permitted through this function, PHYSFS_stat() ignores them, and
699  *  would treat the query as if the path didn't exist at all.
700  *
701  * Symbolic link permission can be enabled or disabled at any time after
702  *  you've called PHYSFS_init(), and is disabled by default.
703  *
704  *   \param allow nonzero to permit symlinks, zero to deny linking.
705  *
706  * \sa PHYSFS_symbolicLinksPermitted
707  */
708 PHYSFS_DECL void PHYSFS_permitSymbolicLinks(int allow);
709 
710 
711 /**
712  * \fn char **PHYSFS_getCdRomDirs(void)
713  * \brief Get an array of paths to available CD-ROM drives.
714  *
715  * The dirs returned are platform-dependent ("D:\" on Win32, "/cdrom" or
716  *  whatnot on Unix). Dirs are only returned if there is a disc ready and
717  *  accessible in the drive. So if you've got two drives (D: and E:), and only
718  *  E: has a disc in it, then that's all you get. If the user inserts a disc
719  *  in D: and you call this function again, you get both drives. If, on a
720  *  Unix box, the user unmounts a disc and remounts it elsewhere, the next
721  *  call to this function will reflect that change.
722  *
723  * This function refers to "CD-ROM" media, but it really means "inserted disc
724  *  media," such as DVD-ROM, HD-DVD, CDRW, and Blu-Ray discs. It looks for
725  *  filesystems, and as such won't report an audio CD, unless there's a
726  *  mounted filesystem track on it.
727  *
728  * The returned value is an array of strings, with a NULL entry to signify the
729  *  end of the list:
730  *
731  * \code
732  * char **cds = PHYSFS_getCdRomDirs();
733  * char **i;
734  *
735  * for (i = cds; *i != NULL; i++)
736  *     printf("cdrom dir [%s] is available.\n", *i);
737  *
738  * PHYSFS_freeList(cds);
739  * \endcode
740  *
741  * This call may block while drives spin up. Be forewarned.
742  *
743  * When you are done with the returned information, you may dispose of the
744  *  resources by calling PHYSFS_freeList() with the returned pointer.
745  *
746  *   \return Null-terminated array of null-terminated strings.
747  *
748  * \sa PHYSFS_getCdRomDirsCallback
749  */
750 PHYSFS_DECL char **PHYSFS_getCdRomDirs(void);
751 
752 
753 /**
754  * \fn const char *PHYSFS_getBaseDir(void)
755  * \brief Get the path where the application resides.
756  *
757  * Helper function.
758  *
759  * Get the "base dir". This is the directory where the application was run
760  *  from, which is probably the installation directory, and may or may not
761  *  be the process's current working directory.
762  *
763  * You should probably use the base dir in your search path.
764  *
765  *  \return READ ONLY string of base dir in platform-dependent notation.
766  *
767  * \sa PHYSFS_getPrefDir
768  */
769 PHYSFS_DECL const char *PHYSFS_getBaseDir(void);
770 
771 
772 /**
773  * \fn const char *PHYSFS_getUserDir(void)
774  * \brief Get the path where user's home directory resides.
775  *
776  * \deprecated As of PhysicsFS 2.1, you probably want PHYSFS_getPrefDir().
777  *
778  * Helper function.
779  *
780  * Get the "user dir". This is meant to be a suggestion of where a specific
781  *  user of the system can store files. On Unix, this is her home directory.
782  *  On systems with no concept of multiple home directories (MacOS, win95),
783  *  this will default to something like "C:\mybasedir\users\username"
784  *  where "username" will either be the login name, or "default" if the
785  *  platform doesn't support multiple users, either.
786  *
787  *  \return READ ONLY string of user dir in platform-dependent notation.
788  *
789  * \sa PHYSFS_getBaseDir
790  * \sa PHYSFS_getPrefDir
791  */
792 PHYSFS_DECL const char *PHYSFS_getUserDir(void) PHYSFS_DEPRECATED;
793 
794 
795 /**
796  * \fn const char *PHYSFS_getWriteDir(void)
797  * \brief Get path where PhysicsFS will allow file writing.
798  *
799  * Get the current write dir. The default write dir is NULL.
800  *
801  *  \return READ ONLY string of write dir in platform-dependent notation,
802  *           OR NULL IF NO WRITE PATH IS CURRENTLY SET.
803  *
804  * \sa PHYSFS_setWriteDir
805  */
806 PHYSFS_DECL const char *PHYSFS_getWriteDir(void);
807 
808 
809 /**
810  * \fn int PHYSFS_setWriteDir(const char *newDir)
811  * \brief Tell PhysicsFS where it may write files.
812  *
813  * Set a new write dir. This will override the previous setting.
814  *
815  * This call will fail (and fail to change the write dir) if the current
816  *  write dir still has files open in it.
817  *
818  *   \param newDir The new directory to be the root of the write dir,
819  *                   specified in platform-dependent notation. Setting to NULL
820  *                   disables the write dir, so no files can be opened for
821  *                   writing via PhysicsFS.
822  *  \return non-zero on success, zero on failure. All attempts to open a file
823  *           for writing via PhysicsFS will fail until this call succeeds.
824  *           Use PHYSFS_getLastErrorCode() to obtain the specific error.
825  *
826  * \sa PHYSFS_getWriteDir
827  */
828 PHYSFS_DECL int PHYSFS_setWriteDir(const char *newDir);
829 
830 
831 /**
832  * \fn int PHYSFS_addToSearchPath(const char *newDir, int appendToPath)
833  * \brief Add an archive or directory to the search path.
834  *
835  * \deprecated As of PhysicsFS 2.0, use PHYSFS_mount() instead. This
836  *             function just wraps it anyhow.
837  *
838  * This function is equivalent to:
839  *
840  * \code
841  *  PHYSFS_mount(newDir, NULL, appendToPath);
842  * \endcode
843  *
844  * You must use this and not PHYSFS_mount if binary compatibility with
845  *  PhysicsFS 1.0 is important (which it may not be for many people).
846  *
847  * \sa PHYSFS_mount
848  * \sa PHYSFS_removeFromSearchPath
849  * \sa PHYSFS_getSearchPath
850  */
851 PHYSFS_DECL int PHYSFS_addToSearchPath(const char *newDir, int appendToPath)
852                                         PHYSFS_DEPRECATED;
853 
854 /**
855  * \fn int PHYSFS_removeFromSearchPath(const char *oldDir)
856  * \brief Remove a directory or archive from the search path.
857  *
858  * \deprecated As of PhysicsFS 2.1, use PHYSFS_unmount() instead. This
859  *             function just wraps it anyhow. There's no functional difference
860  *             except the vocabulary changed from "adding to the search path"
861  *             to "mounting" when that functionality was extended, and thus
862  *             the preferred way to accomplish this function's work is now
863  *             called "unmounting."
864  *
865  * This function is equivalent to:
866  *
867  * \code
868  *  PHYSFS_unmount(oldDir);
869  * \endcode
870  *
871  * You must use this and not PHYSFS_unmount if binary compatibility with
872  *  PhysicsFS 1.0 is important (which it may not be for many people).
873  *
874  * \sa PHYSFS_addToSearchPath
875  * \sa PHYSFS_getSearchPath
876  * \sa PHYSFS_unmount
877  */
878 PHYSFS_DECL int PHYSFS_removeFromSearchPath(const char *oldDir)
879                                             PHYSFS_DEPRECATED;
880 
881 
882 /**
883  * \fn char **PHYSFS_getSearchPath(void)
884  * \brief Get the current search path.
885  *
886  * The default search path is an empty list.
887  *
888  * The returned value is an array of strings, with a NULL entry to signify the
889  *  end of the list:
890  *
891  * \code
892  * char **i;
893  *
894  * for (i = PHYSFS_getSearchPath(); *i != NULL; i++)
895  *     printf("[%s] is in the search path.\n", *i);
896  * \endcode
897  *
898  * When you are done with the returned information, you may dispose of the
899  *  resources by calling PHYSFS_freeList() with the returned pointer.
900  *
901  *   \return Null-terminated array of null-terminated strings. NULL if there
902  *            was a problem (read: OUT OF MEMORY).
903  *
904  * \sa PHYSFS_getSearchPathCallback
905  * \sa PHYSFS_addToSearchPath
906  * \sa PHYSFS_removeFromSearchPath
907  */
908 PHYSFS_DECL char **PHYSFS_getSearchPath(void);
909 
910 
911 /**
912  * \fn int PHYSFS_setSaneConfig(const char *organization, const char *appName, const char *archiveExt, int includeCdRoms, int archivesFirst)
913  * \brief Set up sane, default paths.
914  *
915  * Helper function.
916  *
917  * The write dir will be set to the pref dir returned by
918  *  \code PHYSFS_getPrefDir(organization, appName) \endcode, which is
919  *  created if it doesn't exist.
920  *
921  * The above is sufficient to make sure your program's configuration directory
922  *  is separated from other clutter, and platform-independent.
923  *
924  *  The search path will be:
925  *
926  *    - The Write Dir (created if it doesn't exist)
927  *    - The Base Dir (PHYSFS_getBaseDir())
928  *    - All found CD-ROM dirs (optionally)
929  *
930  * These directories are then searched for files ending with the extension
931  *  (archiveExt), which, if they are valid and supported archives, will also
932  *  be added to the search path. If you specified "PKG" for (archiveExt), and
933  *  there's a file named data.PKG in the base dir, it'll be checked. Archives
934  *  can either be appended or prepended to the search path in alphabetical
935  *  order, regardless of which directories they were found in. All archives
936  *  are mounted in the root of the virtual file system ("/").
937  *
938  * All of this can be accomplished from the application, but this just does it
939  *  all for you. Feel free to add more to the search path manually, too.
940  *
941  *    \param organization Name of your company/group/etc to be used as a
942  *                         dirname, so keep it small, and no-frills.
943  *
944  *    \param appName Program-specific name of your program, to separate it
945  *                   from other programs using PhysicsFS.
946  *
947  *    \param archiveExt File extension used by your program to specify an
948  *                      archive. For example, Quake 3 uses "pk3", even though
949  *                      they are just zipfiles. Specify NULL to not dig out
950  *                      archives automatically. Do not specify the '.' char;
951  *                      If you want to look for ZIP files, specify "ZIP" and
952  *                      not ".ZIP" ... the archive search is case-insensitive.
953  *
954  *    \param includeCdRoms Non-zero to include CD-ROMs in the search path, and
955  *                         (if (archiveExt) != NULL) search them for archives.
956  *                         This may cause a significant amount of blocking
957  *                         while discs are accessed, and if there are no discs
958  *                         in the drive (or even not mounted on Unix systems),
959  *                         then they may not be made available anyhow. You may
960  *                         want to specify zero and handle the disc setup
961  *                         yourself.
962  *
963  *    \param archivesFirst Non-zero to prepend the archives to the search path.
964  *                         Zero to append them. Ignored if !(archiveExt).
965  *
966  *  \return nonzero on success, zero on error. Use PHYSFS_getLastErrorCode()
967  *          to obtain the specific error.
968  */
969 PHYSFS_DECL int PHYSFS_setSaneConfig(const char *organization,
970                                      const char *appName,
971                                      const char *archiveExt,
972                                      int includeCdRoms,
973                                      int archivesFirst);
974 
975 
976 /* Directory management stuff ... */
977 
978 /**
979  * \fn int PHYSFS_mkdir(const char *dirName)
980  * \brief Create a directory.
981  *
982  * This is specified in platform-independent notation in relation to the
983  *  write dir. All missing parent directories are also created if they
984  *  don't exist.
985  *
986  * So if you've got the write dir set to "C:\mygame\writedir" and call
987  *  PHYSFS_mkdir("downloads/maps") then the directories
988  *  "C:\mygame\writedir\downloads" and "C:\mygame\writedir\downloads\maps"
989  *  will be created if possible. If the creation of "maps" fails after we
990  *  have successfully created "downloads", then the function leaves the
991  *  created directory behind and reports failure.
992  *
993  *   \param dirName New dir to create.
994  *  \return nonzero on success, zero on error. Use
995  *          PHYSFS_getLastErrorCode() to obtain the specific error.
996  *
997  * \sa PHYSFS_delete
998  */
999 PHYSFS_DECL int PHYSFS_mkdir(const char *dirName);
1000 
1001 
1002 /**
1003  * \fn int PHYSFS_delete(const char *filename)
1004  * \brief Delete a file or directory.
1005  *
1006  * (filename) is specified in platform-independent notation in relation to the
1007  *  write dir.
1008  *
1009  * A directory must be empty before this call can delete it.
1010  *
1011  * Deleting a symlink will remove the link, not what it points to, regardless
1012  *  of whether you "permitSymLinks" or not.
1013  *
1014  * So if you've got the write dir set to "C:\mygame\writedir" and call
1015  *  PHYSFS_delete("downloads/maps/level1.map") then the file
1016  *  "C:\mygame\writedir\downloads\maps\level1.map" is removed from the
1017  *  physical filesystem, if it exists and the operating system permits the
1018  *  deletion.
1019  *
1020  * Note that on Unix systems, deleting a file may be successful, but the
1021  *  actual file won't be removed until all processes that have an open
1022  *  filehandle to it (including your program) close their handles.
1023  *
1024  * Chances are, the bits that make up the file still exist, they are just
1025  *  made available to be written over at a later point. Don't consider this
1026  *  a security method or anything.  :)
1027  *
1028  *   \param filename Filename to delete.
1029  *  \return nonzero on success, zero on error. Use PHYSFS_getLastErrorCode()
1030  *          to obtain the specific error.
1031  */
1032 PHYSFS_DECL int PHYSFS_delete(const char *filename);
1033 
1034 
1035 /**
1036  * \fn const char *PHYSFS_getRealDir(const char *filename)
1037  * \brief Figure out where in the search path a file resides.
1038  *
1039  * The file is specified in platform-independent notation. The returned
1040  *  filename will be the element of the search path where the file was found,
1041  *  which may be a directory, or an archive. Even if there are multiple
1042  *  matches in different parts of the search path, only the first one found
1043  *  is used, just like when opening a file.
1044  *
1045  * So, if you look for "maps/level1.map", and C:\\mygame is in your search
1046  *  path and C:\\mygame\\maps\\level1.map exists, then "C:\mygame" is returned.
1047  *
1048  * If a any part of a match is a symbolic link, and you've not explicitly
1049  *  permitted symlinks, then it will be ignored, and the search for a match
1050  *  will continue.
1051  *
1052  * If you specify a fake directory that only exists as a mount point, it'll
1053  *  be associated with the first archive mounted there, even though that
1054  *  directory isn't necessarily contained in a real archive.
1055  *
1056  * \warning This will return NULL if there is no real directory associated
1057  *          with (filename). Specifically, PHYSFS_mountIo(),
1058  *          PHYSFS_mountMemory(), and PHYSFS_mountHandle() will return NULL
1059  *          even if the filename is found in the search path. Plan accordingly.
1060  *
1061  *     \param filename file to look for.
1062  *    \return READ ONLY string of element of search path containing the
1063  *             the file in question. NULL if not found.
1064  */
1065 PHYSFS_DECL const char *PHYSFS_getRealDir(const char *filename);
1066 
1067 
1068 /**
1069  * \fn char **PHYSFS_enumerateFiles(const char *dir)
1070  * \brief Get a file listing of a search path's directory.
1071  *
1072  * \warning In PhysicsFS versions prior to 2.1, this function would return
1073  *          as many items as it could in the face of a failure condition
1074  *          (out of memory, disk i/o error, etc). Since this meant apps
1075  *          couldn't distinguish between complete success and partial failure,
1076  *          and since the function could always return NULL to report
1077  *          catastrophic failures anyway, in PhysicsFS 2.1 this function's
1078  *          policy changed: it will either return a list of complete results
1079  *          or it will return NULL for any failure of any kind, so we can
1080  *          guarantee that the enumeration ran to completion and has no gaps
1081  *          in its results.
1082  *
1083  * Matching directories are interpolated. That is, if "C:\mydir" is in the
1084  *  search path and contains a directory "savegames" that contains "x.sav",
1085  *  "y.sav", and "z.sav", and there is also a "C:\userdir" in the search path
1086  *  that has a "savegames" subdirectory with "w.sav", then the following code:
1087  *
1088  * \code
1089  * char **rc = PHYSFS_enumerateFiles("savegames");
1090  * char **i;
1091  *
1092  * for (i = rc; *i != NULL; i++)
1093  *     printf(" * We've got [%s].\n", *i);
1094  *
1095  * PHYSFS_freeList(rc);
1096  * \endcode
1097  *
1098  *  \...will print:
1099  *
1100  * \verbatim
1101  * We've got [x.sav].
1102  * We've got [y.sav].
1103  * We've got [z.sav].
1104  * We've got [w.sav].\endverbatim
1105  *
1106  * Feel free to sort the list however you like. However, the returned data
1107  *  will always contain no duplicates, and will be always sorted in alphabetic
1108  *  (rather: case-sensitive Unicode) order for you.
1109  *
1110  * Don't forget to call PHYSFS_freeList() with the return value from this
1111  *  function when you are done with it.
1112  *
1113  *    \param dir directory in platform-independent notation to enumerate.
1114  *   \return Null-terminated array of null-terminated strings, or NULL for
1115  *           failure cases.
1116  *
1117  * \sa PHYSFS_enumerate
1118  */
1119 PHYSFS_DECL char **PHYSFS_enumerateFiles(const char *dir);
1120 
1121 
1122 /**
1123  * \fn int PHYSFS_exists(const char *fname)
1124  * \brief Determine if a file exists in the search path.
1125  *
1126  * Reports true if there is an entry anywhere in the search path by the
1127  *  name of (fname).
1128  *
1129  * Note that entries that are symlinks are ignored if
1130  *  PHYSFS_permitSymbolicLinks(1) hasn't been called, so you
1131  *  might end up further down in the search path than expected.
1132  *
1133  *    \param fname filename in platform-independent notation.
1134  *   \return non-zero if filename exists. zero otherwise.
1135  */
1136 PHYSFS_DECL int PHYSFS_exists(const char *fname);
1137 
1138 
1139 /**
1140  * \fn int PHYSFS_isDirectory(const char *fname)
1141  * \brief Determine if a file in the search path is really a directory.
1142  *
1143  * \deprecated As of PhysicsFS 2.1, use PHYSFS_stat() instead. This
1144  *             function just wraps it anyhow.
1145  *
1146  * Determine if the first occurence of (fname) in the search path is
1147  *  really a directory entry.
1148  *
1149  * Note that entries that are symlinks are ignored if
1150  *  PHYSFS_permitSymbolicLinks(1) hasn't been called, so you
1151  *  might end up further down in the search path than expected.
1152  *
1153  *    \param fname filename in platform-independent notation.
1154  *   \return non-zero if filename exists and is a directory.  zero otherwise.
1155  *
1156  * \sa PHYSFS_stat
1157  * \sa PHYSFS_exists
1158  */
1159 PHYSFS_DECL int PHYSFS_isDirectory(const char *fname) PHYSFS_DEPRECATED;
1160 
1161 
1162 /**
1163  * \fn int PHYSFS_isSymbolicLink(const char *fname)
1164  * \brief Determine if a file in the search path is really a symbolic link.
1165  *
1166  * \deprecated As of PhysicsFS 2.1, use PHYSFS_stat() instead. This
1167  *             function just wraps it anyhow.
1168  *
1169  * Determine if the first occurence of (fname) in the search path is
1170  *  really a symbolic link.
1171  *
1172  * Note that entries that are symlinks are ignored if
1173  *  PHYSFS_permitSymbolicLinks(1) hasn't been called, and as such,
1174  *  this function will always return 0 in that case.
1175  *
1176  *    \param fname filename in platform-independent notation.
1177  *   \return non-zero if filename exists and is a symlink.  zero otherwise.
1178  *
1179  * \sa PHYSFS_stat
1180  * \sa PHYSFS_exists
1181  */
1182 PHYSFS_DECL int PHYSFS_isSymbolicLink(const char *fname) PHYSFS_DEPRECATED;
1183 
1184 
1185 /**
1186  * \fn PHYSFS_sint64 PHYSFS_getLastModTime(const char *filename)
1187  * \brief Get the last modification time of a file.
1188  *
1189  * \deprecated As of PhysicsFS 2.1, use PHYSFS_stat() instead. This
1190  *             function just wraps it anyhow.
1191  *
1192  * The modtime is returned as a number of seconds since the Unix epoch
1193  *  (midnight, Jan 1, 1970). The exact derivation and accuracy of this time
1194  *  depends on the particular archiver. If there is no reasonable way to
1195  *  obtain this information for a particular archiver, or there was some sort
1196  *  of error, this function returns (-1).
1197  *
1198  * You must use this and not PHYSFS_stat() if binary compatibility with
1199  *  PhysicsFS 2.0 is important (which it may not be for many people).
1200  *
1201  *   \param filename filename to check, in platform-independent notation.
1202  *  \return last modified time of the file. -1 if it can't be determined.
1203  *
1204  * \sa PHYSFS_stat
1205  */
1206 PHYSFS_DECL PHYSFS_sint64 PHYSFS_getLastModTime(const char *filename)
1207                                                 PHYSFS_DEPRECATED;
1208 
1209 
1210 /* i/o stuff... */
1211 
1212 /**
1213  * \fn PHYSFS_File *PHYSFS_openWrite(const char *filename)
1214  * \brief Open a file for writing.
1215  *
1216  * Open a file for writing, in platform-independent notation and in relation
1217  *  to the write dir as the root of the writable filesystem. The specified
1218  *  file is created if it doesn't exist. If it does exist, it is truncated to
1219  *  zero bytes, and the writing offset is set to the start.
1220  *
1221  * Note that entries that are symlinks are ignored if
1222  *  PHYSFS_permitSymbolicLinks(1) hasn't been called, and opening a
1223  *  symlink with this function will fail in such a case.
1224  *
1225  *   \param filename File to open.
1226  *  \return A valid PhysicsFS filehandle on success, NULL on error. Use
1227  *          PHYSFS_getLastErrorCode() to obtain the specific error.
1228  *
1229  * \sa PHYSFS_openRead
1230  * \sa PHYSFS_openAppend
1231  * \sa PHYSFS_write
1232  * \sa PHYSFS_close
1233  */
1234 PHYSFS_DECL PHYSFS_File *PHYSFS_openWrite(const char *filename);
1235 
1236 
1237 /**
1238  * \fn PHYSFS_File *PHYSFS_openAppend(const char *filename)
1239  * \brief Open a file for appending.
1240  *
1241  * Open a file for writing, in platform-independent notation and in relation
1242  *  to the write dir as the root of the writable filesystem. The specified
1243  *  file is created if it doesn't exist. If it does exist, the writing offset
1244  *  is set to the end of the file, so the first write will be the byte after
1245  *  the end.
1246  *
1247  * Note that entries that are symlinks are ignored if
1248  *  PHYSFS_permitSymbolicLinks(1) hasn't been called, and opening a
1249  *  symlink with this function will fail in such a case.
1250  *
1251  *   \param filename File to open.
1252  *  \return A valid PhysicsFS filehandle on success, NULL on error. Use
1253  *          PHYSFS_getLastErrorCode() to obtain the specific error.
1254  *
1255  * \sa PHYSFS_openRead
1256  * \sa PHYSFS_openWrite
1257  * \sa PHYSFS_write
1258  * \sa PHYSFS_close
1259  */
1260 PHYSFS_DECL PHYSFS_File *PHYSFS_openAppend(const char *filename);
1261 
1262 
1263 /**
1264  * \fn PHYSFS_File *PHYSFS_openRead(const char *filename)
1265  * \brief Open a file for reading.
1266  *
1267  * Open a file for reading, in platform-independent notation. The search path
1268  *  is checked one at a time until a matching file is found, in which case an
1269  *  abstract filehandle is associated with it, and reading may be done.
1270  *  The reading offset is set to the first byte of the file.
1271  *
1272  * Note that entries that are symlinks are ignored if
1273  *  PHYSFS_permitSymbolicLinks(1) hasn't been called, and opening a
1274  *  symlink with this function will fail in such a case.
1275  *
1276  *   \param filename File to open.
1277  *  \return A valid PhysicsFS filehandle on success, NULL on error.
1278  *          Use PHYSFS_getLastErrorCode() to obtain the specific error.
1279  *
1280  * \sa PHYSFS_openWrite
1281  * \sa PHYSFS_openAppend
1282  * \sa PHYSFS_read
1283  * \sa PHYSFS_close
1284  */
1285 PHYSFS_DECL PHYSFS_File *PHYSFS_openRead(const char *filename);
1286 
1287 
1288 /**
1289  * \fn int PHYSFS_close(PHYSFS_File *handle)
1290  * \brief Close a PhysicsFS filehandle.
1291  *
1292  * This call is capable of failing if the operating system was buffering
1293  *  writes to the physical media, and, now forced to write those changes to
1294  *  physical media, can not store the data for some reason. In such a case,
1295  *  the filehandle stays open. A well-written program should ALWAYS check the
1296  *  return value from the close call in addition to every writing call!
1297  *
1298  *   \param handle handle returned from PHYSFS_open*().
1299  *  \return nonzero on success, zero on error. Use PHYSFS_getLastErrorCode()
1300  *          to obtain the specific error.
1301  *
1302  * \sa PHYSFS_openRead
1303  * \sa PHYSFS_openWrite
1304  * \sa PHYSFS_openAppend
1305  */
1306 PHYSFS_DECL int PHYSFS_close(PHYSFS_File *handle);
1307 
1308 
1309 /**
1310  * \fn PHYSFS_sint64 PHYSFS_read(PHYSFS_File *handle, void *buffer, PHYSFS_uint32 objSize, PHYSFS_uint32 objCount)
1311  * \brief Read data from a PhysicsFS filehandle
1312  *
1313  * The file must be opened for reading.
1314  *
1315  * \deprecated As of PhysicsFS 2.1, use PHYSFS_readBytes() instead. This
1316  *             function just wraps it anyhow. This function never clarified
1317  *             what would happen if you managed to read a partial object, so
1318  *             working at the byte level makes this cleaner for everyone,
1319  *             especially now that PHYSFS_Io interfaces can be supplied by the
1320  *             application.
1321  *
1322  *   \param handle handle returned from PHYSFS_openRead().
1323  *   \param buffer buffer to store read data into.
1324  *   \param objSize size in bytes of objects being read from (handle).
1325  *   \param objCount number of (objSize) objects to read from (handle).
1326  *  \return number of objects read. PHYSFS_getLastErrorCode() can shed light
1327  *          on the reason this might be < (objCount), as can PHYSFS_eof().
1328  *          -1 if complete failure.
1329  *
1330  * \sa PHYSFS_readBytes
1331  * \sa PHYSFS_eof
1332  */
1333 PHYSFS_DECL PHYSFS_sint64 PHYSFS_read(PHYSFS_File *handle,
1334                                       void *buffer,
1335                                       PHYSFS_uint32 objSize,
1336                                       PHYSFS_uint32 objCount)
1337                                         PHYSFS_DEPRECATED;
1338 
1339 /**
1340  * \fn PHYSFS_sint64 PHYSFS_write(PHYSFS_File *handle, const void *buffer, PHYSFS_uint32 objSize, PHYSFS_uint32 objCount)
1341  * \brief Write data to a PhysicsFS filehandle
1342  *
1343  * The file must be opened for writing.
1344  *
1345  * \deprecated As of PhysicsFS 2.1, use PHYSFS_writeBytes() instead. This
1346  *             function just wraps it anyhow. This function never clarified
1347  *             what would happen if you managed to write a partial object, so
1348  *             working at the byte level makes this cleaner for everyone,
1349  *             especially now that PHYSFS_Io interfaces can be supplied by the
1350  *             application.
1351  *
1352  *   \param handle retval from PHYSFS_openWrite() or PHYSFS_openAppend().
1353  *   \param buffer buffer of bytes to write to (handle).
1354  *   \param objSize size in bytes of objects being written to (handle).
1355  *   \param objCount number of (objSize) objects to write to (handle).
1356  *  \return number of objects written. PHYSFS_getLastErrorCode() can shed
1357  *          light on the reason this might be < (objCount). -1 if complete
1358  *          failure.
1359  *
1360  * \sa PHYSFS_writeBytes
1361  */
1362 PHYSFS_DECL PHYSFS_sint64 PHYSFS_write(PHYSFS_File *handle,
1363                                        const void *buffer,
1364                                        PHYSFS_uint32 objSize,
1365                                        PHYSFS_uint32 objCount)
1366                                         PHYSFS_DEPRECATED;
1367 
1368 
1369 /* File position stuff... */
1370 
1371 /**
1372  * \fn int PHYSFS_eof(PHYSFS_File *handle)
1373  * \brief Check for end-of-file state on a PhysicsFS filehandle.
1374  *
1375  * Determine if the end of file has been reached in a PhysicsFS filehandle.
1376  *
1377  *   \param handle handle returned from PHYSFS_openRead().
1378  *  \return nonzero if EOF, zero if not.
1379  *
1380  * \sa PHYSFS_read
1381  * \sa PHYSFS_tell
1382  */
1383 PHYSFS_DECL int PHYSFS_eof(PHYSFS_File *handle);
1384 
1385 
1386 /**
1387  * \fn PHYSFS_sint64 PHYSFS_tell(PHYSFS_File *handle)
1388  * \brief Determine current position within a PhysicsFS filehandle.
1389  *
1390  *   \param handle handle returned from PHYSFS_open*().
1391  *  \return offset in bytes from start of file. -1 if error occurred.
1392  *           Use PHYSFS_getLastErrorCode() to obtain the specific error.
1393  *
1394  * \sa PHYSFS_seek
1395  */
1396 PHYSFS_DECL PHYSFS_sint64 PHYSFS_tell(PHYSFS_File *handle);
1397 
1398 
1399 /**
1400  * \fn int PHYSFS_seek(PHYSFS_File *handle, PHYSFS_uint64 pos)
1401  * \brief Seek to a new position within a PhysicsFS filehandle.
1402  *
1403  * The next read or write will occur at that place. Seeking past the
1404  *  beginning or end of the file is not allowed, and causes an error.
1405  *
1406  *   \param handle handle returned from PHYSFS_open*().
1407  *   \param pos number of bytes from start of file to seek to.
1408  *  \return nonzero on success, zero on error. Use PHYSFS_getLastErrorCode()
1409  *          to obtain the specific error.
1410  *
1411  * \sa PHYSFS_tell
1412  */
1413 PHYSFS_DECL int PHYSFS_seek(PHYSFS_File *handle, PHYSFS_uint64 pos);
1414 
1415 
1416 /**
1417  * \fn PHYSFS_sint64 PHYSFS_fileLength(PHYSFS_File *handle)
1418  * \brief Get total length of a file in bytes.
1419  *
1420  * Note that if another process/thread is writing to this file at the same
1421  *  time, then the information this function supplies could be incorrect
1422  *  before you get it. Use with caution, or better yet, don't use at all.
1423  *
1424  *   \param handle handle returned from PHYSFS_open*().
1425  *  \return size in bytes of the file. -1 if can't be determined.
1426  *
1427  * \sa PHYSFS_tell
1428  * \sa PHYSFS_seek
1429  */
1430 PHYSFS_DECL PHYSFS_sint64 PHYSFS_fileLength(PHYSFS_File *handle);
1431 
1432 
1433 /* Buffering stuff... */
1434 
1435 /**
1436  * \fn int PHYSFS_setBuffer(PHYSFS_File *handle, PHYSFS_uint64 bufsize)
1437  * \brief Set up buffering for a PhysicsFS file handle.
1438  *
1439  * Define an i/o buffer for a file handle. A memory block of (bufsize) bytes
1440  *  will be allocated and associated with (handle).
1441  *
1442  * For files opened for reading, up to (bufsize) bytes are read from (handle)
1443  *  and stored in the internal buffer. Calls to PHYSFS_read() will pull
1444  *  from this buffer until it is empty, and then refill it for more reading.
1445  *  Note that compressed files, like ZIP archives, will decompress while
1446  *  buffering, so this can be handy for offsetting CPU-intensive operations.
1447  *  The buffer isn't filled until you do your next read.
1448  *
1449  * For files opened for writing, data will be buffered to memory until the
1450  *  buffer is full or the buffer is flushed. Closing a handle implicitly
1451  *  causes a flush...check your return values!
1452  *
1453  * Seeking, etc transparently accounts for buffering.
1454  *
1455  * You can resize an existing buffer by calling this function more than once
1456  *  on the same file. Setting the buffer size to zero will free an existing
1457  *  buffer.
1458  *
1459  * PhysicsFS file handles are unbuffered by default.
1460  *
1461  * Please check the return value of this function! Failures can include
1462  *  not being able to seek backwards in a read-only file when removing the
1463  *  buffer, not being able to allocate the buffer, and not being able to
1464  *  flush the buffer to disk, among other unexpected problems.
1465  *
1466  *   \param handle handle returned from PHYSFS_open*().
1467  *   \param bufsize size, in bytes, of buffer to allocate.
1468  *  \return nonzero if successful, zero on error.
1469  *
1470  * \sa PHYSFS_flush
1471  * \sa PHYSFS_read
1472  * \sa PHYSFS_write
1473  * \sa PHYSFS_close
1474  */
1475 PHYSFS_DECL int PHYSFS_setBuffer(PHYSFS_File *handle, PHYSFS_uint64 bufsize);
1476 
1477 
1478 /**
1479  * \fn int PHYSFS_flush(PHYSFS_File *handle)
1480  * \brief Flush a buffered PhysicsFS file handle.
1481  *
1482  * For buffered files opened for writing, this will put the current contents
1483  *  of the buffer to disk and flag the buffer as empty if possible.
1484  *
1485  * For buffered files opened for reading or unbuffered files, this is a safe
1486  *  no-op, and will report success.
1487  *
1488  *   \param handle handle returned from PHYSFS_open*().
1489  *  \return nonzero if successful, zero on error.
1490  *
1491  * \sa PHYSFS_setBuffer
1492  * \sa PHYSFS_close
1493  */
1494 PHYSFS_DECL int PHYSFS_flush(PHYSFS_File *handle);
1495 
1496 
1497 /* Byteorder stuff... */
1498 
1499 /**
1500  * \fn PHYSFS_sint16 PHYSFS_swapSLE16(PHYSFS_sint16 val)
1501  * \brief Swap littleendian signed 16 to platform's native byte order.
1502  *
1503  * Take a 16-bit signed value in littleendian format and convert it to
1504  *  the platform's native byte order.
1505  *
1506  *    \param val value to convert
1507  *   \return converted value.
1508  */
1509 PHYSFS_DECL PHYSFS_sint16 PHYSFS_swapSLE16(PHYSFS_sint16 val);
1510 
1511 
1512 /**
1513  * \fn PHYSFS_uint16 PHYSFS_swapULE16(PHYSFS_uint16 val)
1514  * \brief Swap littleendian unsigned 16 to platform's native byte order.
1515  *
1516  * Take a 16-bit unsigned value in littleendian format and convert it to
1517  *  the platform's native byte order.
1518  *
1519  *    \param val value to convert
1520  *   \return converted value.
1521  */
1522 PHYSFS_DECL PHYSFS_uint16 PHYSFS_swapULE16(PHYSFS_uint16 val);
1523 
1524 /**
1525  * \fn PHYSFS_sint32 PHYSFS_swapSLE32(PHYSFS_sint32 val)
1526  * \brief Swap littleendian signed 32 to platform's native byte order.
1527  *
1528  * Take a 32-bit signed value in littleendian format and convert it to
1529  *  the platform's native byte order.
1530  *
1531  *    \param val value to convert
1532  *   \return converted value.
1533  */
1534 PHYSFS_DECL PHYSFS_sint32 PHYSFS_swapSLE32(PHYSFS_sint32 val);
1535 
1536 
1537 /**
1538  * \fn PHYSFS_uint32 PHYSFS_swapULE32(PHYSFS_uint32 val)
1539  * \brief Swap littleendian unsigned 32 to platform's native byte order.
1540  *
1541  * Take a 32-bit unsigned value in littleendian format and convert it to
1542  *  the platform's native byte order.
1543  *
1544  *    \param val value to convert
1545  *   \return converted value.
1546  */
1547 PHYSFS_DECL PHYSFS_uint32 PHYSFS_swapULE32(PHYSFS_uint32 val);
1548 
1549 /**
1550  * \fn PHYSFS_sint64 PHYSFS_swapSLE64(PHYSFS_sint64 val)
1551  * \brief Swap littleendian signed 64 to platform's native byte order.
1552  *
1553  * Take a 64-bit signed value in littleendian format and convert it to
1554  *  the platform's native byte order.
1555  *
1556  *    \param val value to convert
1557  *   \return converted value.
1558  *
1559  * \warning Remember, PHYSFS_sint64 is only 32 bits on platforms without
1560  *          any sort of 64-bit support.
1561  */
1562 PHYSFS_DECL PHYSFS_sint64 PHYSFS_swapSLE64(PHYSFS_sint64 val);
1563 
1564 
1565 /**
1566  * \fn PHYSFS_uint64 PHYSFS_swapULE64(PHYSFS_uint64 val)
1567  * \brief Swap littleendian unsigned 64 to platform's native byte order.
1568  *
1569  * Take a 64-bit unsigned value in littleendian format and convert it to
1570  *  the platform's native byte order.
1571  *
1572  *    \param val value to convert
1573  *   \return converted value.
1574  *
1575  * \warning Remember, PHYSFS_uint64 is only 32 bits on platforms without
1576  *          any sort of 64-bit support.
1577  */
1578 PHYSFS_DECL PHYSFS_uint64 PHYSFS_swapULE64(PHYSFS_uint64 val);
1579 
1580 
1581 /**
1582  * \fn PHYSFS_sint16 PHYSFS_swapSBE16(PHYSFS_sint16 val)
1583  * \brief Swap bigendian signed 16 to platform's native byte order.
1584  *
1585  * Take a 16-bit signed value in bigendian format and convert it to
1586  *  the platform's native byte order.
1587  *
1588  *    \param val value to convert
1589  *   \return converted value.
1590  */
1591 PHYSFS_DECL PHYSFS_sint16 PHYSFS_swapSBE16(PHYSFS_sint16 val);
1592 
1593 
1594 /**
1595  * \fn PHYSFS_uint16 PHYSFS_swapUBE16(PHYSFS_uint16 val)
1596  * \brief Swap bigendian unsigned 16 to platform's native byte order.
1597  *
1598  * Take a 16-bit unsigned value in bigendian format and convert it to
1599  *  the platform's native byte order.
1600  *
1601  *    \param val value to convert
1602  *   \return converted value.
1603  */
1604 PHYSFS_DECL PHYSFS_uint16 PHYSFS_swapUBE16(PHYSFS_uint16 val);
1605 
1606 /**
1607  * \fn PHYSFS_sint32 PHYSFS_swapSBE32(PHYSFS_sint32 val)
1608  * \brief Swap bigendian signed 32 to platform's native byte order.
1609  *
1610  * Take a 32-bit signed value in bigendian format and convert it to
1611  *  the platform's native byte order.
1612  *
1613  *    \param val value to convert
1614  *   \return converted value.
1615  */
1616 PHYSFS_DECL PHYSFS_sint32 PHYSFS_swapSBE32(PHYSFS_sint32 val);
1617 
1618 
1619 /**
1620  * \fn PHYSFS_uint32 PHYSFS_swapUBE32(PHYSFS_uint32 val)
1621  * \brief Swap bigendian unsigned 32 to platform's native byte order.
1622  *
1623  * Take a 32-bit unsigned value in bigendian format and convert it to
1624  *  the platform's native byte order.
1625  *
1626  *    \param val value to convert
1627  *   \return converted value.
1628  */
1629 PHYSFS_DECL PHYSFS_uint32 PHYSFS_swapUBE32(PHYSFS_uint32 val);
1630 
1631 
1632 /**
1633  * \fn PHYSFS_sint64 PHYSFS_swapSBE64(PHYSFS_sint64 val)
1634  * \brief Swap bigendian signed 64 to platform's native byte order.
1635  *
1636  * Take a 64-bit signed value in bigendian format and convert it to
1637  *  the platform's native byte order.
1638  *
1639  *    \param val value to convert
1640  *   \return converted value.
1641  *
1642  * \warning Remember, PHYSFS_sint64 is only 32 bits on platforms without
1643  *          any sort of 64-bit support.
1644  */
1645 PHYSFS_DECL PHYSFS_sint64 PHYSFS_swapSBE64(PHYSFS_sint64 val);
1646 
1647 
1648 /**
1649  * \fn PHYSFS_uint64 PHYSFS_swapUBE64(PHYSFS_uint64 val)
1650  * \brief Swap bigendian unsigned 64 to platform's native byte order.
1651  *
1652  * Take a 64-bit unsigned value in bigendian format and convert it to
1653  *  the platform's native byte order.
1654  *
1655  *    \param val value to convert
1656  *   \return converted value.
1657  *
1658  * \warning Remember, PHYSFS_uint64 is only 32 bits on platforms without
1659  *          any sort of 64-bit support.
1660  */
1661 PHYSFS_DECL PHYSFS_uint64 PHYSFS_swapUBE64(PHYSFS_uint64 val);
1662 
1663 
1664 /**
1665  * \fn int PHYSFS_readSLE16(PHYSFS_File *file, PHYSFS_sint16 *val)
1666  * \brief Read and convert a signed 16-bit littleendian value.
1667  *
1668  * Convenience function. Read a signed 16-bit littleendian value from a
1669  *  file and convert it to the platform's native byte order.
1670  *
1671  *    \param file PhysicsFS file handle from which to read.
1672  *    \param val pointer to where value should be stored.
1673  *   \return zero on failure, non-zero on success. If successful, (*val) will
1674  *           store the result. On failure, you can find out what went wrong
1675  *           from PHYSFS_getLastErrorCode().
1676  */
1677 PHYSFS_DECL int PHYSFS_readSLE16(PHYSFS_File *file, PHYSFS_sint16 *val);
1678 
1679 
1680 /**
1681  * \fn int PHYSFS_readULE16(PHYSFS_File *file, PHYSFS_uint16 *val)
1682  * \brief Read and convert an unsigned 16-bit littleendian value.
1683  *
1684  * Convenience function. Read an unsigned 16-bit littleendian value from a
1685  *  file and convert it to the platform's native byte order.
1686  *
1687  *    \param file PhysicsFS file handle from which to read.
1688  *    \param val pointer to where value should be stored.
1689  *   \return zero on failure, non-zero on success. If successful, (*val) will
1690  *           store the result. On failure, you can find out what went wrong
1691  *           from PHYSFS_getLastErrorCode().
1692  *
1693  */
1694 PHYSFS_DECL int PHYSFS_readULE16(PHYSFS_File *file, PHYSFS_uint16 *val);
1695 
1696 
1697 /**
1698  * \fn int PHYSFS_readSBE16(PHYSFS_File *file, PHYSFS_sint16 *val)
1699  * \brief Read and convert a signed 16-bit bigendian value.
1700  *
1701  * Convenience function. Read a signed 16-bit bigendian value from a
1702  *  file and convert it to the platform's native byte order.
1703  *
1704  *    \param file PhysicsFS file handle from which to read.
1705  *    \param val pointer to where value should be stored.
1706  *   \return zero on failure, non-zero on success. If successful, (*val) will
1707  *           store the result. On failure, you can find out what went wrong
1708  *           from PHYSFS_getLastErrorCode().
1709  */
1710 PHYSFS_DECL int PHYSFS_readSBE16(PHYSFS_File *file, PHYSFS_sint16 *val);
1711 
1712 
1713 /**
1714  * \fn int PHYSFS_readUBE16(PHYSFS_File *file, PHYSFS_uint16 *val)
1715  * \brief Read and convert an unsigned 16-bit bigendian value.
1716  *
1717  * Convenience function. Read an unsigned 16-bit bigendian value from a
1718  *  file and convert it to the platform's native byte order.
1719  *
1720  *    \param file PhysicsFS file handle from which to read.
1721  *    \param val pointer to where value should be stored.
1722  *   \return zero on failure, non-zero on success. If successful, (*val) will
1723  *           store the result. On failure, you can find out what went wrong
1724  *           from PHYSFS_getLastErrorCode().
1725  *
1726  */
1727 PHYSFS_DECL int PHYSFS_readUBE16(PHYSFS_File *file, PHYSFS_uint16 *val);
1728 
1729 
1730 /**
1731  * \fn int PHYSFS_readSLE32(PHYSFS_File *file, PHYSFS_sint32 *val)
1732  * \brief Read and convert a signed 32-bit littleendian value.
1733  *
1734  * Convenience function. Read a signed 32-bit littleendian value from a
1735  *  file and convert it to the platform's native byte order.
1736  *
1737  *    \param file PhysicsFS file handle from which to read.
1738  *    \param val pointer to where value should be stored.
1739  *   \return zero on failure, non-zero on success. If successful, (*val) will
1740  *           store the result. On failure, you can find out what went wrong
1741  *           from PHYSFS_getLastErrorCode().
1742  */
1743 PHYSFS_DECL int PHYSFS_readSLE32(PHYSFS_File *file, PHYSFS_sint32 *val);
1744 
1745 
1746 /**
1747  * \fn int PHYSFS_readULE32(PHYSFS_File *file, PHYSFS_uint32 *val)
1748  * \brief Read and convert an unsigned 32-bit littleendian value.
1749  *
1750  * Convenience function. Read an unsigned 32-bit littleendian value from a
1751  *  file and convert it to the platform's native byte order.
1752  *
1753  *    \param file PhysicsFS file handle from which to read.
1754  *    \param val pointer to where value should be stored.
1755  *   \return zero on failure, non-zero on success. If successful, (*val) will
1756  *           store the result. On failure, you can find out what went wrong
1757  *           from PHYSFS_getLastErrorCode().
1758  *
1759  */
1760 PHYSFS_DECL int PHYSFS_readULE32(PHYSFS_File *file, PHYSFS_uint32 *val);
1761 
1762 
1763 /**
1764  * \fn int PHYSFS_readSBE32(PHYSFS_File *file, PHYSFS_sint32 *val)
1765  * \brief Read and convert a signed 32-bit bigendian value.
1766  *
1767  * Convenience function. Read a signed 32-bit bigendian value from a
1768  *  file and convert it to the platform's native byte order.
1769  *
1770  *    \param file PhysicsFS file handle from which to read.
1771  *    \param val pointer to where value should be stored.
1772  *   \return zero on failure, non-zero on success. If successful, (*val) will
1773  *           store the result. On failure, you can find out what went wrong
1774  *           from PHYSFS_getLastErrorCode().
1775  */
1776 PHYSFS_DECL int PHYSFS_readSBE32(PHYSFS_File *file, PHYSFS_sint32 *val);
1777 
1778 
1779 /**
1780  * \fn int PHYSFS_readUBE32(PHYSFS_File *file, PHYSFS_uint32 *val)
1781  * \brief Read and convert an unsigned 32-bit bigendian value.
1782  *
1783  * Convenience function. Read an unsigned 32-bit bigendian value from a
1784  *  file and convert it to the platform's native byte order.
1785  *
1786  *    \param file PhysicsFS file handle from which to read.
1787  *    \param val pointer to where value should be stored.
1788  *   \return zero on failure, non-zero on success. If successful, (*val) will
1789  *           store the result. On failure, you can find out what went wrong
1790  *           from PHYSFS_getLastErrorCode().
1791  *
1792  */
1793 PHYSFS_DECL int PHYSFS_readUBE32(PHYSFS_File *file, PHYSFS_uint32 *val);
1794 
1795 
1796 /**
1797  * \fn int PHYSFS_readSLE64(PHYSFS_File *file, PHYSFS_sint64 *val)
1798  * \brief Read and convert a signed 64-bit littleendian value.
1799  *
1800  * Convenience function. Read a signed 64-bit littleendian value from a
1801  *  file and convert it to the platform's native byte order.
1802  *
1803  *    \param file PhysicsFS file handle from which to read.
1804  *    \param val pointer to where value should be stored.
1805  *   \return zero on failure, non-zero on success. If successful, (*val) will
1806  *           store the result. On failure, you can find out what went wrong
1807  *           from PHYSFS_getLastErrorCode().
1808  *
1809  * \warning Remember, PHYSFS_sint64 is only 32 bits on platforms without
1810  *          any sort of 64-bit support.
1811  */
1812 PHYSFS_DECL int PHYSFS_readSLE64(PHYSFS_File *file, PHYSFS_sint64 *val);
1813 
1814 
1815 /**
1816  * \fn int PHYSFS_readULE64(PHYSFS_File *file, PHYSFS_uint64 *val)
1817  * \brief Read and convert an unsigned 64-bit littleendian value.
1818  *
1819  * Convenience function. Read an unsigned 64-bit littleendian value from a
1820  *  file and convert it to the platform's native byte order.
1821  *
1822  *    \param file PhysicsFS file handle from which to read.
1823  *    \param val pointer to where value should be stored.
1824  *   \return zero on failure, non-zero on success. If successful, (*val) will
1825  *           store the result. On failure, you can find out what went wrong
1826  *           from PHYSFS_getLastErrorCode().
1827  *
1828  * \warning Remember, PHYSFS_uint64 is only 32 bits on platforms without
1829  *          any sort of 64-bit support.
1830  */
1831 PHYSFS_DECL int PHYSFS_readULE64(PHYSFS_File *file, PHYSFS_uint64 *val);
1832 
1833 
1834 /**
1835  * \fn int PHYSFS_readSBE64(PHYSFS_File *file, PHYSFS_sint64 *val)
1836  * \brief Read and convert a signed 64-bit bigendian value.
1837  *
1838  * Convenience function. Read a signed 64-bit bigendian value from a
1839  *  file and convert it to the platform's native byte order.
1840  *
1841  *    \param file PhysicsFS file handle from which to read.
1842  *    \param val pointer to where value should be stored.
1843  *   \return zero on failure, non-zero on success. If successful, (*val) will
1844  *           store the result. On failure, you can find out what went wrong
1845  *           from PHYSFS_getLastErrorCode().
1846  *
1847  * \warning Remember, PHYSFS_sint64 is only 32 bits on platforms without
1848  *          any sort of 64-bit support.
1849  */
1850 PHYSFS_DECL int PHYSFS_readSBE64(PHYSFS_File *file, PHYSFS_sint64 *val);
1851 
1852 
1853 /**
1854  * \fn int PHYSFS_readUBE64(PHYSFS_File *file, PHYSFS_uint64 *val)
1855  * \brief Read and convert an unsigned 64-bit bigendian value.
1856  *
1857  * Convenience function. Read an unsigned 64-bit bigendian value from a
1858  *  file and convert it to the platform's native byte order.
1859  *
1860  *    \param file PhysicsFS file handle from which to read.
1861  *    \param val pointer to where value should be stored.
1862  *   \return zero on failure, non-zero on success. If successful, (*val) will
1863  *           store the result. On failure, you can find out what went wrong
1864  *           from PHYSFS_getLastErrorCode().
1865  *
1866  * \warning Remember, PHYSFS_uint64 is only 32 bits on platforms without
1867  *          any sort of 64-bit support.
1868  */
1869 PHYSFS_DECL int PHYSFS_readUBE64(PHYSFS_File *file, PHYSFS_uint64 *val);
1870 
1871 
1872 /**
1873  * \fn int PHYSFS_writeSLE16(PHYSFS_File *file, PHYSFS_sint16 val)
1874  * \brief Convert and write a signed 16-bit littleendian value.
1875  *
1876  * Convenience function. Convert a signed 16-bit value from the platform's
1877  *  native byte order to littleendian and write it to a file.
1878  *
1879  *    \param file PhysicsFS file handle to which to write.
1880  *    \param val Value to convert and write.
1881  *   \return zero on failure, non-zero on success. On failure, you can
1882  *           find out what went wrong from PHYSFS_getLastErrorCode().
1883  */
1884 PHYSFS_DECL int PHYSFS_writeSLE16(PHYSFS_File *file, PHYSFS_sint16 val);
1885 
1886 
1887 /**
1888  * \fn int PHYSFS_writeULE16(PHYSFS_File *file, PHYSFS_uint16 val)
1889  * \brief Convert and write an unsigned 16-bit littleendian value.
1890  *
1891  * Convenience function. Convert an unsigned 16-bit value from the platform's
1892  *  native byte order to littleendian and write it to a file.
1893  *
1894  *    \param file PhysicsFS file handle to which to write.
1895  *    \param val Value to convert and write.
1896  *   \return zero on failure, non-zero on success. On failure, you can
1897  *           find out what went wrong from PHYSFS_getLastErrorCode().
1898  */
1899 PHYSFS_DECL int PHYSFS_writeULE16(PHYSFS_File *file, PHYSFS_uint16 val);
1900 
1901 
1902 /**
1903  * \fn int PHYSFS_writeSBE16(PHYSFS_File *file, PHYSFS_sint16 val)
1904  * \brief Convert and write a signed 16-bit bigendian value.
1905  *
1906  * Convenience function. Convert a signed 16-bit value from the platform's
1907  *  native byte order to bigendian and write it to a file.
1908  *
1909  *    \param file PhysicsFS file handle to which to write.
1910  *    \param val Value to convert and write.
1911  *   \return zero on failure, non-zero on success. On failure, you can
1912  *           find out what went wrong from PHYSFS_getLastErrorCode().
1913  */
1914 PHYSFS_DECL int PHYSFS_writeSBE16(PHYSFS_File *file, PHYSFS_sint16 val);
1915 
1916 
1917 /**
1918  * \fn int PHYSFS_writeUBE16(PHYSFS_File *file, PHYSFS_uint16 val)
1919  * \brief Convert and write an unsigned 16-bit bigendian value.
1920  *
1921  * Convenience function. Convert an unsigned 16-bit value from the platform's
1922  *  native byte order to bigendian and write it to a file.
1923  *
1924  *    \param file PhysicsFS file handle to which to write.
1925  *    \param val Value to convert and write.
1926  *   \return zero on failure, non-zero on success. On failure, you can
1927  *           find out what went wrong from PHYSFS_getLastErrorCode().
1928  */
1929 PHYSFS_DECL int PHYSFS_writeUBE16(PHYSFS_File *file, PHYSFS_uint16 val);
1930 
1931 
1932 /**
1933  * \fn int PHYSFS_writeSLE32(PHYSFS_File *file, PHYSFS_sint32 val)
1934  * \brief Convert and write a signed 32-bit littleendian value.
1935  *
1936  * Convenience function. Convert a signed 32-bit value from the platform's
1937  *  native byte order to littleendian and write it to a file.
1938  *
1939  *    \param file PhysicsFS file handle to which to write.
1940  *    \param val Value to convert and write.
1941  *   \return zero on failure, non-zero on success. On failure, you can
1942  *           find out what went wrong from PHYSFS_getLastErrorCode().
1943  */
1944 PHYSFS_DECL int PHYSFS_writeSLE32(PHYSFS_File *file, PHYSFS_sint32 val);
1945 
1946 
1947 /**
1948  * \fn int PHYSFS_writeULE32(PHYSFS_File *file, PHYSFS_uint32 val)
1949  * \brief Convert and write an unsigned 32-bit littleendian value.
1950  *
1951  * Convenience function. Convert an unsigned 32-bit value from the platform's
1952  *  native byte order to littleendian and write it to a file.
1953  *
1954  *    \param file PhysicsFS file handle to which to write.
1955  *    \param val Value to convert and write.
1956  *   \return zero on failure, non-zero on success. On failure, you can
1957  *           find out what went wrong from PHYSFS_getLastErrorCode().
1958  */
1959 PHYSFS_DECL int PHYSFS_writeULE32(PHYSFS_File *file, PHYSFS_uint32 val);
1960 
1961 
1962 /**
1963  * \fn int PHYSFS_writeSBE32(PHYSFS_File *file, PHYSFS_sint32 val)
1964  * \brief Convert and write a signed 32-bit bigendian value.
1965  *
1966  * Convenience function. Convert a signed 32-bit value from the platform's
1967  *  native byte order to bigendian and write it to a file.
1968  *
1969  *    \param file PhysicsFS file handle to which to write.
1970  *    \param val Value to convert and write.
1971  *   \return zero on failure, non-zero on success. On failure, you can
1972  *           find out what went wrong from PHYSFS_getLastErrorCode().
1973  */
1974 PHYSFS_DECL int PHYSFS_writeSBE32(PHYSFS_File *file, PHYSFS_sint32 val);
1975 
1976 
1977 /**
1978  * \fn int PHYSFS_writeUBE32(PHYSFS_File *file, PHYSFS_uint32 val)
1979  * \brief Convert and write an unsigned 32-bit bigendian value.
1980  *
1981  * Convenience function. Convert an unsigned 32-bit value from the platform's
1982  *  native byte order to bigendian and write it to a file.
1983  *
1984  *    \param file PhysicsFS file handle to which to write.
1985  *    \param val Value to convert and write.
1986  *   \return zero on failure, non-zero on success. On failure, you can
1987  *           find out what went wrong from PHYSFS_getLastErrorCode().
1988  */
1989 PHYSFS_DECL int PHYSFS_writeUBE32(PHYSFS_File *file, PHYSFS_uint32 val);
1990 
1991 
1992 /**
1993  * \fn int PHYSFS_writeSLE64(PHYSFS_File *file, PHYSFS_sint64 val)
1994  * \brief Convert and write a signed 64-bit littleendian value.
1995  *
1996  * Convenience function. Convert a signed 64-bit value from the platform's
1997  *  native byte order to littleendian and write it to a file.
1998  *
1999  *    \param file PhysicsFS file handle to which to write.
2000  *    \param val Value to convert and write.
2001  *   \return zero on failure, non-zero on success. On failure, you can
2002  *           find out what went wrong from PHYSFS_getLastErrorCode().
2003  *
2004  * \warning Remember, PHYSFS_sint64 is only 32 bits on platforms without
2005  *          any sort of 64-bit support.
2006  */
2007 PHYSFS_DECL int PHYSFS_writeSLE64(PHYSFS_File *file, PHYSFS_sint64 val);
2008 
2009 
2010 /**
2011  * \fn int PHYSFS_writeULE64(PHYSFS_File *file, PHYSFS_uint64 val)
2012  * \brief Convert and write an unsigned 64-bit littleendian value.
2013  *
2014  * Convenience function. Convert an unsigned 64-bit value from the platform's
2015  *  native byte order to littleendian and write it to a file.
2016  *
2017  *    \param file PhysicsFS file handle to which to write.
2018  *    \param val Value to convert and write.
2019  *   \return zero on failure, non-zero on success. On failure, you can
2020  *           find out what went wrong from PHYSFS_getLastErrorCode().
2021  *
2022  * \warning Remember, PHYSFS_uint64 is only 32 bits on platforms without
2023  *          any sort of 64-bit support.
2024  */
2025 PHYSFS_DECL int PHYSFS_writeULE64(PHYSFS_File *file, PHYSFS_uint64 val);
2026 
2027 
2028 /**
2029  * \fn int PHYSFS_writeSBE64(PHYSFS_File *file, PHYSFS_sint64 val)
2030  * \brief Convert and write a signed 64-bit bigending value.
2031  *
2032  * Convenience function. Convert a signed 64-bit value from the platform's
2033  *  native byte order to bigendian and write it to a file.
2034  *
2035  *    \param file PhysicsFS file handle to which to write.
2036  *    \param val Value to convert and write.
2037  *   \return zero on failure, non-zero on success. On failure, you can
2038  *           find out what went wrong from PHYSFS_getLastErrorCode().
2039  *
2040  * \warning Remember, PHYSFS_sint64 is only 32 bits on platforms without
2041  *          any sort of 64-bit support.
2042  */
2043 PHYSFS_DECL int PHYSFS_writeSBE64(PHYSFS_File *file, PHYSFS_sint64 val);
2044 
2045 
2046 /**
2047  * \fn int PHYSFS_writeUBE64(PHYSFS_File *file, PHYSFS_uint64 val)
2048  * \brief Convert and write an unsigned 64-bit bigendian value.
2049  *
2050  * Convenience function. Convert an unsigned 64-bit value from the platform's
2051  *  native byte order to bigendian and write it to a file.
2052  *
2053  *    \param file PhysicsFS file handle to which to write.
2054  *    \param val Value to convert and write.
2055  *   \return zero on failure, non-zero on success. On failure, you can
2056  *           find out what went wrong from PHYSFS_getLastErrorCode().
2057  *
2058  * \warning Remember, PHYSFS_uint64 is only 32 bits on platforms without
2059  *          any sort of 64-bit support.
2060  */
2061 PHYSFS_DECL int PHYSFS_writeUBE64(PHYSFS_File *file, PHYSFS_uint64 val);
2062 
2063 
2064 /* Everything above this line is part of the PhysicsFS 1.0 API. */
2065 
2066 /**
2067  * \fn int PHYSFS_isInit(void)
2068  * \brief Determine if the PhysicsFS library is initialized.
2069  *
2070  * Once PHYSFS_init() returns successfully, this will return non-zero.
2071  *  Before a successful PHYSFS_init() and after PHYSFS_deinit() returns
2072  *  successfully, this will return zero. This function is safe to call at
2073  *  any time.
2074  *
2075  *  \return non-zero if library is initialized, zero if library is not.
2076  *
2077  * \sa PHYSFS_init
2078  * \sa PHYSFS_deinit
2079  */
2080 PHYSFS_DECL int PHYSFS_isInit(void);
2081 
2082 
2083 /**
2084  * \fn int PHYSFS_symbolicLinksPermitted(void)
2085  * \brief Determine if the symbolic links are permitted.
2086  *
2087  * This reports the setting from the last call to PHYSFS_permitSymbolicLinks().
2088  *  If PHYSFS_permitSymbolicLinks() hasn't been called since the library was
2089  *  last initialized, symbolic links are implicitly disabled.
2090  *
2091  *  \return non-zero if symlinks are permitted, zero if not.
2092  *
2093  * \sa PHYSFS_permitSymbolicLinks
2094  */
2095 PHYSFS_DECL int PHYSFS_symbolicLinksPermitted(void);
2096 
2097 
2098 /**
2099  * \struct PHYSFS_Allocator
2100  * \brief PhysicsFS allocation function pointers.
2101  *
2102  * (This is for limited, hardcore use. If you don't immediately see a need
2103  *  for it, you can probably ignore this forever.)
2104  *
2105  * You create one of these structures for use with PHYSFS_setAllocator.
2106  *  Allocators are assumed to be reentrant by the caller; please mutex
2107  *  accordingly.
2108  *
2109  * Allocations are always discussed in 64-bits, for future expansion...we're
2110  *  on the cusp of a 64-bit transition, and we'll probably be allocating 6
2111  *  gigabytes like it's nothing sooner or later, and I don't want to change
2112  *  this again at that point. If you're on a 32-bit platform and have to
2113  *  downcast, it's okay to return NULL if the allocation is greater than
2114  *  4 gigabytes, since you'd have to do so anyhow.
2115  *
2116  * \sa PHYSFS_setAllocator
2117  */
2118 typedef struct PHYSFS_Allocator
2119 {
2120     int (*Init)(void);   /**< Initialize. Can be NULL. Zero on failure. */
2121     void (*Deinit)(void);  /**< Deinitialize your allocator. Can be NULL. */
2122     void *(*Malloc)(PHYSFS_uint64);  /**< Allocate like malloc(). */
2123     void *(*Realloc)(void *, PHYSFS_uint64); /**< Reallocate like realloc(). */
2124     void (*Free)(void *); /**< Free memory from Malloc or Realloc. */
2125 } PHYSFS_Allocator;
2126 
2127 
2128 /**
2129  * \fn int PHYSFS_setAllocator(const PHYSFS_Allocator *allocator)
2130  * \brief Hook your own allocation routines into PhysicsFS.
2131  *
2132  * (This is for limited, hardcore use. If you don't immediately see a need
2133  *  for it, you can probably ignore this forever.)
2134  *
2135  * By default, PhysicsFS will use whatever is reasonable for a platform
2136  *  to manage dynamic memory (usually ANSI C malloc/realloc/free, but
2137  *  some platforms might use something else), but in some uncommon cases, the
2138  *  app might want more control over the library's memory management. This
2139  *  lets you redirect PhysicsFS to use your own allocation routines instead.
2140  *  You can only call this function before PHYSFS_init(); if the library is
2141  *  initialized, it'll reject your efforts to change the allocator mid-stream.
2142  *  You may call this function after PHYSFS_deinit() if you are willing to
2143  *  shut down the library and restart it with a new allocator; this is a safe
2144  *  and supported operation. The allocator remains intact between deinit/init
2145  *  calls. If you want to return to the platform's default allocator, pass a
2146  *  NULL in here.
2147  *
2148  * If you aren't immediately sure what to do with this function, you can
2149  *  safely ignore it altogether.
2150  *
2151  *    \param allocator Structure containing your allocator's entry points.
2152  *   \return zero on failure, non-zero on success. This call only fails
2153  *           when used between PHYSFS_init() and PHYSFS_deinit() calls.
2154  */
2155 PHYSFS_DECL int PHYSFS_setAllocator(const PHYSFS_Allocator *allocator);
2156 
2157 
2158 /**
2159  * \fn int PHYSFS_mount(const char *newDir, const char *mountPoint, int appendToPath)
2160  * \brief Add an archive or directory to the search path.
2161  *
2162  * If this is a duplicate, the entry is not added again, even though the
2163  *  function succeeds. You may not add the same archive to two different
2164  *  mountpoints: duplicate checking is done against the archive and not the
2165  *  mountpoint.
2166  *
2167  * When you mount an archive, it is added to a virtual file system...all files
2168  *  in all of the archives are interpolated into a single hierachical file
2169  *  tree. Two archives mounted at the same place (or an archive with files
2170  *  overlapping another mountpoint) may have overlapping files: in such a case,
2171  *  the file earliest in the search path is selected, and the other files are
2172  *  inaccessible to the application. This allows archives to be used to
2173  *  override previous revisions; you can use the mounting mechanism to place
2174  *  archives at a specific point in the file tree and prevent overlap; this
2175  *  is useful for downloadable mods that might trample over application data
2176  *  or each other, for example.
2177  *
2178  * The mountpoint does not need to exist prior to mounting, which is different
2179  *  than those familiar with the Unix concept of "mounting" may expect.
2180  *  As well, more than one archive can be mounted to the same mountpoint, or
2181  *  mountpoints and archive contents can overlap...the interpolation mechanism
2182  *  still functions as usual.
2183  *
2184  * Specifying a symbolic link to an archive or directory is allowed here,
2185  *  regardless of the state of PHYSFS_permitSymbolicLinks(). That function
2186  *  only deals with symlinks inside the mounted directory or archive.
2187  *
2188  *   \param newDir directory or archive to add to the path, in
2189  *                   platform-dependent notation.
2190  *   \param mountPoint Location in the interpolated tree that this archive
2191  *                     will be "mounted", in platform-independent notation.
2192  *                     NULL or "" is equivalent to "/".
2193  *   \param appendToPath nonzero to append to search path, zero to prepend.
2194  *  \return nonzero if added to path, zero on failure (bogus archive, dir
2195  *          missing, etc). Use PHYSFS_getLastErrorCode() to obtain
2196  *          the specific error.
2197  *
2198  * \sa PHYSFS_removeFromSearchPath
2199  * \sa PHYSFS_getSearchPath
2200  * \sa PHYSFS_getMountPoint
2201  * \sa PHYSFS_mountIo
2202  */
2203 PHYSFS_DECL int PHYSFS_mount(const char *newDir,
2204                              const char *mountPoint,
2205                              int appendToPath);
2206 
2207 /**
2208  * \fn int PHYSFS_getMountPoint(const char *dir)
2209  * \brief Determine a mounted archive's mountpoint.
2210  *
2211  * You give this function the name of an archive or dir you successfully
2212  *  added to the search path, and it reports the location in the interpolated
2213  *  tree where it is mounted. Files mounted with a NULL mountpoint or through
2214  *  PHYSFS_addToSearchPath() will report "/". The return value is READ ONLY
2215  *  and valid until the archive is removed from the search path.
2216  *
2217  *   \param dir directory or archive previously added to the path, in
2218  *              platform-dependent notation. This must match the string
2219  *              used when adding, even if your string would also reference
2220  *              the same file with a different string of characters.
2221  *  \return READ-ONLY string of mount point if added to path, NULL on failure
2222  *          (bogus archive, etc). Use PHYSFS_getLastErrorCode() to obtain the
2223  *          specific error.
2224  *
2225  * \sa PHYSFS_removeFromSearchPath
2226  * \sa PHYSFS_getSearchPath
2227  * \sa PHYSFS_getMountPoint
2228  */
2229 PHYSFS_DECL const char *PHYSFS_getMountPoint(const char *dir);
2230 
2231 
2232 /**
2233  * \typedef PHYSFS_StringCallback
2234  * \brief Function signature for callbacks that report strings.
2235  *
2236  * These are used to report a list of strings to an original caller, one
2237  *  string per callback. All strings are UTF-8 encoded. Functions should not
2238  *  try to modify or free the string's memory.
2239  *
2240  * These callbacks are used, starting in PhysicsFS 1.1, as an alternative to
2241  *  functions that would return lists that need to be cleaned up with
2242  *  PHYSFS_freeList(). The callback means that the library doesn't need to
2243  *  allocate an entire list and all the strings up front.
2244  *
2245  * Be aware that promises data ordering in the list versions are not
2246  *  necessarily so in the callback versions. Check the documentation on
2247  *  specific APIs, but strings may not be sorted as you expect.
2248  *
2249  *    \param data User-defined data pointer, passed through from the API
2250  *                that eventually called the callback.
2251  *    \param str The string data about which the callback is meant to inform.
2252  *
2253  * \sa PHYSFS_getCdRomDirsCallback
2254  * \sa PHYSFS_getSearchPathCallback
2255  */
2256 typedef void (*PHYSFS_StringCallback)(void *data, const char *str);
2257 
2258 
2259 /**
2260  * \typedef PHYSFS_EnumFilesCallback
2261  * \brief Function signature for callbacks that enumerate files.
2262  *
2263  * \warning As of PhysicsFS 2.1, Use PHYSFS_EnumerateCallback with
2264  *  PHYSFS_enumerate() instead; it gives you more control over the process.
2265  *
2266  * These are used to report a list of directory entries to an original caller,
2267  *  one file/dir/symlink per callback. All strings are UTF-8 encoded.
2268  *  Functions should not try to modify or free any string's memory.
2269  *
2270  * These callbacks are used, starting in PhysicsFS 1.1, as an alternative to
2271  *  functions that would return lists that need to be cleaned up with
2272  *  PHYSFS_freeList(). The callback means that the library doesn't need to
2273  *  allocate an entire list and all the strings up front.
2274  *
2275  * Be aware that promised data ordering in the list versions are not
2276  *  necessarily so in the callback versions. Check the documentation on
2277  *  specific APIs, but strings may not be sorted as you expect and you might
2278  *  get duplicate strings.
2279  *
2280  *    \param data User-defined data pointer, passed through from the API
2281  *                that eventually called the callback.
2282  *    \param origdir A string containing the full path, in platform-independent
2283  *                   notation, of the directory containing this file. In most
2284  *                   cases, this is the directory on which you requested
2285  *                   enumeration, passed in the callback for your convenience.
2286  *    \param fname The filename that is being enumerated. It may not be in
2287  *                 alphabetical order compared to other callbacks that have
2288  *                 fired, and it will not contain the full path. You can
2289  *                 recreate the fullpath with $origdir/$fname ... The file
2290  *                 can be a subdirectory, a file, a symlink, etc.
2291  *
2292  * \sa PHYSFS_enumerateFilesCallback
2293  */
2294 typedef void (*PHYSFS_EnumFilesCallback)(void *data, const char *origdir,
2295                                          const char *fname);
2296 
2297 
2298 /**
2299  * \fn void PHYSFS_getCdRomDirsCallback(PHYSFS_StringCallback c, void *d)
2300  * \brief Enumerate CD-ROM directories, using an application-defined callback.
2301  *
2302  * Internally, PHYSFS_getCdRomDirs() just calls this function and then builds
2303  *  a list before returning to the application, so functionality is identical
2304  *  except for how the information is represented to the application.
2305  *
2306  * Unlike PHYSFS_getCdRomDirs(), this function does not return an array.
2307  *  Rather, it calls a function specified by the application once per
2308  *  detected disc:
2309  *
2310  * \code
2311  *
2312  * static void foundDisc(void *data, const char *cddir)
2313  * {
2314  *     printf("cdrom dir [%s] is available.\n", cddir);
2315  * }
2316  *
2317  * // ...
2318  * PHYSFS_getCdRomDirsCallback(foundDisc, NULL);
2319  * \endcode
2320  *
2321  * This call may block while drives spin up. Be forewarned.
2322  *
2323  *    \param c Callback function to notify about detected drives.
2324  *    \param d Application-defined data passed to callback. Can be NULL.
2325  *
2326  * \sa PHYSFS_StringCallback
2327  * \sa PHYSFS_getCdRomDirs
2328  */
2329 PHYSFS_DECL void PHYSFS_getCdRomDirsCallback(PHYSFS_StringCallback c, void *d);
2330 
2331 
2332 /**
2333  * \fn void PHYSFS_getSearchPathCallback(PHYSFS_StringCallback c, void *d)
2334  * \brief Enumerate the search path, using an application-defined callback.
2335  *
2336  * Internally, PHYSFS_getSearchPath() just calls this function and then builds
2337  *  a list before returning to the application, so functionality is identical
2338  *  except for how the information is represented to the application.
2339  *
2340  * Unlike PHYSFS_getSearchPath(), this function does not return an array.
2341  *  Rather, it calls a function specified by the application once per
2342  *  element of the search path:
2343  *
2344  * \code
2345  *
2346  * static void printSearchPath(void *data, const char *pathItem)
2347  * {
2348  *     printf("[%s] is in the search path.\n", pathItem);
2349  * }
2350  *
2351  * // ...
2352  * PHYSFS_getSearchPathCallback(printSearchPath, NULL);
2353  * \endcode
2354  *
2355  * Elements of the search path are reported in order search priority, so the
2356  *  first archive/dir that would be examined when looking for a file is the
2357  *  first element passed through the callback.
2358  *
2359  *    \param c Callback function to notify about search path elements.
2360  *    \param d Application-defined data passed to callback. Can be NULL.
2361  *
2362  * \sa PHYSFS_StringCallback
2363  * \sa PHYSFS_getSearchPath
2364  */
2365 PHYSFS_DECL void PHYSFS_getSearchPathCallback(PHYSFS_StringCallback c, void *d);
2366 
2367 
2368 /**
2369  * \fn void PHYSFS_enumerateFilesCallback(const char *dir, PHYSFS_EnumFilesCallback c, void *d)
2370  * \brief Get a file listing of a search path's directory, using an application-defined callback.
2371  *
2372  * \deprecated As of PhysicsFS 2.1, use PHYSFS_enumerate() instead. This
2373  *  function has no way to report errors (or to have the callback signal an
2374  *  error or request a stop), so if data will be lost, your callback has no
2375  *  way to direct the process, and your calling app has no way to know.
2376  *
2377  * As of PhysicsFS 2.1, this function just wraps PHYSFS_enumerate() and
2378  *  ignores errors. Consider using PHYSFS_enumerate() or
2379  *  PHYSFS_enumerateFiles() instead.
2380  *
2381  * \sa PHYSFS_enumerate
2382  * \sa PHYSFS_enumerateFiles
2383  * \sa PHYSFS_EnumFilesCallback
2384  */
2385 PHYSFS_DECL void PHYSFS_enumerateFilesCallback(const char *dir,
2386                                                PHYSFS_EnumFilesCallback c,
2387                                                void *d) PHYSFS_DEPRECATED;
2388 
2389 /**
2390  * \fn void PHYSFS_utf8FromUcs4(const PHYSFS_uint32 *src, char *dst, PHYSFS_uint64 len)
2391  * \brief Convert a UCS-4 string to a UTF-8 string.
2392  *
2393  * \warning This function will not report an error if there are invalid UCS-4
2394  *          values in the source string. It will replace them with a '?'
2395  *          character and continue on.
2396  *
2397  * UCS-4 (aka UTF-32) strings are 32-bits per character: \c wchar_t on Unix.
2398  *
2399  * To ensure that the destination buffer is large enough for the conversion,
2400  *  please allocate a buffer that is the same size as the source buffer. UTF-8
2401  *  never uses more than 32-bits per character, so while it may shrink a UCS-4
2402  *  string, it will never expand it.
2403  *
2404  * Strings that don't fit in the destination buffer will be truncated, but
2405  *  will always be null-terminated and never have an incomplete UTF-8
2406  *  sequence at the end. If the buffer length is 0, this function does nothing.
2407  *
2408  *   \param src Null-terminated source string in UCS-4 format.
2409  *   \param dst Buffer to store converted UTF-8 string.
2410  *   \param len Size, in bytes, of destination buffer.
2411  */
2412 PHYSFS_DECL void PHYSFS_utf8FromUcs4(const PHYSFS_uint32 *src, char *dst,
2413                                      PHYSFS_uint64 len);
2414 
2415 /**
2416  * \fn void PHYSFS_utf8ToUcs4(const char *src, PHYSFS_uint32 *dst, PHYSFS_uint64 len)
2417  * \brief Convert a UTF-8 string to a UCS-4 string.
2418  *
2419  * \warning This function will not report an error if there are invalid UTF-8
2420  *          sequences in the source string. It will replace them with a '?'
2421  *          character and continue on.
2422  *
2423  * UCS-4 (aka UTF-32) strings are 32-bits per character: \c wchar_t on Unix.
2424  *
2425  * To ensure that the destination buffer is large enough for the conversion,
2426  *  please allocate a buffer that is four times the size of the source buffer.
2427  *  UTF-8 uses from one to four bytes per character, but UCS-4 always uses
2428  *  four, so an entirely low-ASCII string will quadruple in size!
2429  *
2430  * Strings that don't fit in the destination buffer will be truncated, but
2431  *  will always be null-terminated and never have an incomplete UCS-4
2432  *  sequence at the end. If the buffer length is 0, this function does nothing.
2433  *
2434  *   \param src Null-terminated source string in UTF-8 format.
2435  *   \param dst Buffer to store converted UCS-4 string.
2436  *   \param len Size, in bytes, of destination buffer.
2437  */
2438 PHYSFS_DECL void PHYSFS_utf8ToUcs4(const char *src, PHYSFS_uint32 *dst,
2439                                    PHYSFS_uint64 len);
2440 
2441 /**
2442  * \fn void PHYSFS_utf8FromUcs2(const PHYSFS_uint16 *src, char *dst, PHYSFS_uint64 len)
2443  * \brief Convert a UCS-2 string to a UTF-8 string.
2444  *
2445  * \warning you almost certainly should use PHYSFS_utf8FromUtf16(), which
2446  *  became available in PhysicsFS 2.1, unless you know what you're doing.
2447  *
2448  * \warning This function will not report an error if there are invalid UCS-2
2449  *          values in the source string. It will replace them with a '?'
2450  *          character and continue on.
2451  *
2452  * UCS-2 strings are 16-bits per character: \c TCHAR on Windows, when building
2453  *  with Unicode support. Please note that modern versions of Windows use
2454  *  UTF-16, which is an extended form of UCS-2, and not UCS-2 itself. You
2455  *  almost certainly want PHYSFS_utf8FromUtf16() instead.
2456  *
2457  * To ensure that the destination buffer is large enough for the conversion,
2458  *  please allocate a buffer that is double the size of the source buffer.
2459  *  UTF-8 never uses more than 32-bits per character, so while it may shrink
2460  *  a UCS-2 string, it may also expand it.
2461  *
2462  * Strings that don't fit in the destination buffer will be truncated, but
2463  *  will always be null-terminated and never have an incomplete UTF-8
2464  *  sequence at the end. If the buffer length is 0, this function does nothing.
2465  *
2466  *   \param src Null-terminated source string in UCS-2 format.
2467  *   \param dst Buffer to store converted UTF-8 string.
2468  *   \param len Size, in bytes, of destination buffer.
2469  *
2470  * \sa PHYSFS_utf8FromUtf16
2471  */
2472 PHYSFS_DECL void PHYSFS_utf8FromUcs2(const PHYSFS_uint16 *src, char *dst,
2473                                      PHYSFS_uint64 len);
2474 
2475 /**
2476  * \fn PHYSFS_utf8ToUcs2(const char *src, PHYSFS_uint16 *dst, PHYSFS_uint64 len)
2477  * \brief Convert a UTF-8 string to a UCS-2 string.
2478  *
2479  * \warning you almost certainly should use PHYSFS_utf8ToUtf16(), which
2480  *  became available in PhysicsFS 2.1, unless you know what you're doing.
2481  *
2482  * \warning This function will not report an error if there are invalid UTF-8
2483  *          sequences in the source string. It will replace them with a '?'
2484  *          character and continue on.
2485  *
2486  * UCS-2 strings are 16-bits per character: \c TCHAR on Windows, when building
2487  *  with Unicode support. Please note that modern versions of Windows use
2488  *  UTF-16, which is an extended form of UCS-2, and not UCS-2 itself. You
2489  *  almost certainly want PHYSFS_utf8ToUtf16() instead, but you need to
2490  *  understand how that changes things, too.
2491  *
2492  * To ensure that the destination buffer is large enough for the conversion,
2493  *  please allocate a buffer that is double the size of the source buffer.
2494  *  UTF-8 uses from one to four bytes per character, but UCS-2 always uses
2495  *  two, so an entirely low-ASCII string will double in size!
2496  *
2497  * Strings that don't fit in the destination buffer will be truncated, but
2498  *  will always be null-terminated and never have an incomplete UCS-2
2499  *  sequence at the end. If the buffer length is 0, this function does nothing.
2500  *
2501  *   \param src Null-terminated source string in UTF-8 format.
2502  *   \param dst Buffer to store converted UCS-2 string.
2503  *   \param len Size, in bytes, of destination buffer.
2504  *
2505  * \sa PHYSFS_utf8ToUtf16
2506  */
2507 PHYSFS_DECL void PHYSFS_utf8ToUcs2(const char *src, PHYSFS_uint16 *dst,
2508                                    PHYSFS_uint64 len);
2509 
2510 /**
2511  * \fn void PHYSFS_utf8FromLatin1(const char *src, char *dst, PHYSFS_uint64 len)
2512  * \brief Convert a UTF-8 string to a Latin1 string.
2513  *
2514  * Latin1 strings are 8-bits per character: a popular "high ASCII" encoding.
2515  *
2516  * To ensure that the destination buffer is large enough for the conversion,
2517  *  please allocate a buffer that is double the size of the source buffer.
2518  *  UTF-8 expands latin1 codepoints over 127 from 1 to 2 bytes, so the string
2519  *  may grow in some cases.
2520  *
2521  * Strings that don't fit in the destination buffer will be truncated, but
2522  *  will always be null-terminated and never have an incomplete UTF-8
2523  *  sequence at the end. If the buffer length is 0, this function does nothing.
2524  *
2525  * Please note that we do not supply a UTF-8 to Latin1 converter, since Latin1
2526  *  can't express most Unicode codepoints. It's a legacy encoding; you should
2527  *  be converting away from it at all times.
2528  *
2529  *   \param src Null-terminated source string in Latin1 format.
2530  *   \param dst Buffer to store converted UTF-8 string.
2531  *   \param len Size, in bytes, of destination buffer.
2532  */
2533 PHYSFS_DECL void PHYSFS_utf8FromLatin1(const char *src, char *dst,
2534                                        PHYSFS_uint64 len);
2535 
2536 /* Everything above this line is part of the PhysicsFS 2.0 API. */
2537 
2538 /**
2539  * \fn int PHYSFS_caseFold(const PHYSFS_uint32 from, PHYSFS_uint32 *to)
2540  * \brief "Fold" a Unicode codepoint to a lowercase equivalent.
2541  *
2542  * (This is for limited, hardcore use. If you don't immediately see a need
2543  *  for it, you can probably ignore this forever.)
2544  *
2545  * This will convert a Unicode codepoint into its lowercase equivalent.
2546  *  Bogus codepoints and codepoints without a lowercase equivalent will
2547  *  be returned unconverted.
2548  *
2549  * Note that you might get multiple codepoints in return! The German Eszett,
2550  *  for example, will fold down to two lowercase latin 's' codepoints. The
2551  *  theory is that if you fold two strings, one with an Eszett and one with
2552  *  "SS" down, they will match.
2553  *
2554  * \warning Anyone that is a student of Unicode knows about the "Turkish I"
2555  *          problem. This API does not handle it. Assume this one letter
2556  *          in all of Unicode will definitely fold sort of incorrectly. If
2557  *          you don't know what this is about, you can probably ignore this
2558  *          problem for most of the planet, but perfection is impossible.
2559  *
2560  *   \param from The codepoint to fold.
2561  *   \param to Buffer to store the folded codepoint values into. This should
2562  *             point to space for at least 3 PHYSFS_uint32 slots.
2563  *  \return The number of codepoints the folding produced. Between 1 and 3.
2564  */
2565 PHYSFS_DECL int PHYSFS_caseFold(const PHYSFS_uint32 from, PHYSFS_uint32 *to);
2566 
2567 
2568 /**
2569  * \fn int PHYSFS_utf8stricmp(const char *str1, const char *str2)
2570  * \brief Case-insensitive compare of two UTF-8 strings.
2571  *
2572  * This is a strcasecmp/stricmp replacement that expects both strings
2573  *  to be in UTF-8 encoding. It will do "case folding" to decide if the
2574  *  Unicode codepoints in the strings match.
2575  *
2576  * If both strings are exclusively low-ASCII characters, this will do the
2577  *  right thing, as that is also valid UTF-8. If there are any high-ASCII
2578  *  chars, this will not do what you expect!
2579  *
2580  * It will report which string is "greater than" the other, but be aware that
2581  *  this doesn't necessarily mean anything: 'a' may be "less than" 'b', but
2582  *  a Japanese kuten has no meaningful alphabetically relationship to
2583  *  a Greek lambda, but being able to assign a reliable "value" makes sorting
2584  *  algorithms possible, if not entirely sane. Most cases should treat the
2585  *  return value as "equal" or "not equal".
2586  *
2587  * Like stricmp, this expects both strings to be NULL-terminated.
2588  *
2589  *   \param str1 First string to compare.
2590  *   \param str2 Second string to compare.
2591  *  \return -1 if str1 is "less than" str2, 1 if "greater than", 0 if equal.
2592  */
2593 PHYSFS_DECL int PHYSFS_utf8stricmp(const char *str1, const char *str2);
2594 
2595 /**
2596  * \fn int PHYSFS_utf16stricmp(const PHYSFS_uint16 *str1, const PHYSFS_uint16 *str2)
2597  * \brief Case-insensitive compare of two UTF-16 strings.
2598  *
2599  * This is a strcasecmp/stricmp replacement that expects both strings
2600  *  to be in UTF-16 encoding. It will do "case folding" to decide if the
2601  *  Unicode codepoints in the strings match.
2602  *
2603  * It will report which string is "greater than" the other, but be aware that
2604  *  this doesn't necessarily mean anything: 'a' may be "less than" 'b', but
2605  *  a Japanese kuten has no meaningful alphabetically relationship to
2606  *  a Greek lambda, but being able to assign a reliable "value" makes sorting
2607  *  algorithms possible, if not entirely sane. Most cases should treat the
2608  *  return value as "equal" or "not equal".
2609  *
2610  * Like stricmp, this expects both strings to be NULL-terminated.
2611  *
2612  *   \param str1 First string to compare.
2613  *   \param str2 Second string to compare.
2614  *  \return -1 if str1 is "less than" str2, 1 if "greater than", 0 if equal.
2615  */
2616 PHYSFS_DECL int PHYSFS_utf16stricmp(const PHYSFS_uint16 *str1,
2617                                     const PHYSFS_uint16 *str2);
2618 
2619 /**
2620  * \fn int PHYSFS_ucs4stricmp(const PHYSFS_uint32 *str1, const PHYSFS_uint32 *str2)
2621  * \brief Case-insensitive compare of two UCS-4 strings.
2622  *
2623  * This is a strcasecmp/stricmp replacement that expects both strings
2624  *  to be in UCS-4 (aka UTF-32) encoding. It will do "case folding" to decide
2625  *  if the Unicode codepoints in the strings match.
2626  *
2627  * It will report which string is "greater than" the other, but be aware that
2628  *  this doesn't necessarily mean anything: 'a' may be "less than" 'b', but
2629  *  a Japanese kuten has no meaningful alphabetically relationship to
2630  *  a Greek lambda, but being able to assign a reliable "value" makes sorting
2631  *  algorithms possible, if not entirely sane. Most cases should treat the
2632  *  return value as "equal" or "not equal".
2633  *
2634  * Like stricmp, this expects both strings to be NULL-terminated.
2635  *
2636  *   \param str1 First string to compare.
2637  *   \param str2 Second string to compare.
2638  *  \return -1 if str1 is "less than" str2, 1 if "greater than", 0 if equal.
2639  */
2640 PHYSFS_DECL int PHYSFS_ucs4stricmp(const PHYSFS_uint32 *str1,
2641                                    const PHYSFS_uint32 *str2);
2642 
2643 
2644 /**
2645  * \typedef PHYSFS_EnumerateCallback
2646  * \brief Possible return values from PHYSFS_EnumerateCallback.
2647  *
2648  * These values dictate if an enumeration callback should continue to fire,
2649  *  or stop (and why it is stopping).
2650  *
2651  * \sa PHYSFS_EnumerateCallback
2652  * \sa PHYSFS_enumerate
2653  */
2654 typedef enum PHYSFS_EnumerateCallbackResult
2655 {
2656     PHYSFS_ENUM_ERROR = -1,   /**< Stop enumerating, report error to app. */
2657     PHYSFS_ENUM_STOP = 0,     /**< Stop enumerating, report success to app. */
2658     PHYSFS_ENUM_OK = 1        /**< Keep enumerating, no problems */
2659 } PHYSFS_EnumerateCallbackResult;
2660 
2661 /**
2662  * \typedef PHYSFS_EnumerateCallback
2663  * \brief Function signature for callbacks that enumerate and return results.
2664  *
2665  * This is the same thing as PHYSFS_EnumFilesCallback from PhysicsFS 2.0,
2666  *  except it can return a result from the callback: namely: if you're looking
2667  *  for something specific, once you find it, you can tell PhysicsFS to stop
2668  *  enumerating further. This is used with PHYSFS_enumerate(), which we
2669  *  hopefully got right this time.  :)
2670  *
2671  *    \param data User-defined data pointer, passed through from the API
2672  *                that eventually called the callback.
2673  *    \param origdir A string containing the full path, in platform-independent
2674  *                   notation, of the directory containing this file. In most
2675  *                   cases, this is the directory on which you requested
2676  *                   enumeration, passed in the callback for your convenience.
2677  *    \param fname The filename that is being enumerated. It may not be in
2678  *                 alphabetical order compared to other callbacks that have
2679  *                 fired, and it will not contain the full path. You can
2680  *                 recreate the fullpath with $origdir/$fname ... The file
2681  *                 can be a subdirectory, a file, a symlink, etc.
2682  *   \return A value from PHYSFS_EnumerateCallbackResult.
2683  *           All other values are (currently) undefined; don't use them.
2684  *
2685  * \sa PHYSFS_enumerate
2686  * \sa PHYSFS_EnumerateCallbackResult
2687  */
2688 typedef PHYSFS_EnumerateCallbackResult (*PHYSFS_EnumerateCallback)(void *data,
2689                                        const char *origdir, const char *fname);
2690 
2691 /**
2692  * \fn int PHYSFS_enumerate(const char *dir, PHYSFS_EnumerateCallback c, void *d)
2693  * \brief Get a file listing of a search path's directory, using an application-defined callback, with errors reported.
2694  *
2695  * Internally, PHYSFS_enumerateFiles() just calls this function and then builds
2696  *  a list before returning to the application, so functionality is identical
2697  *  except for how the information is represented to the application.
2698  *
2699  * Unlike PHYSFS_enumerateFiles(), this function does not return an array.
2700  *  Rather, it calls a function specified by the application once per
2701  *  element of the search path:
2702  *
2703  * \code
2704  *
2705  * static int printDir(void *data, const char *origdir, const char *fname)
2706  * {
2707  *     printf(" * We've got [%s] in [%s].\n", fname, origdir);
2708  *     return 1;  // give me more data, please.
2709  * }
2710  *
2711  * // ...
2712  * PHYSFS_enumerate("/some/path", printDir, NULL);
2713  * \endcode
2714  *
2715  * Items sent to the callback are not guaranteed to be in any order whatsoever.
2716  *  There is no sorting done at this level, and if you need that, you should
2717  *  probably use PHYSFS_enumerateFiles() instead, which guarantees
2718  *  alphabetical sorting. This form reports whatever is discovered in each
2719  *  archive before moving on to the next. Even within one archive, we can't
2720  *  guarantee what order it will discover data. <em>Any sorting you find in
2721  *  these callbacks is just pure luck. Do not rely on it.</em> As this walks
2722  *  the entire list of archives, you may receive duplicate filenames.
2723  *
2724  * This API and the callbacks themselves are capable of reporting errors.
2725  *  Prior to this API, callbacks had to accept every enumerated item, even if
2726  *  they were only looking for a specific thing and wanted to stop after that,
2727  *  or had a serious error and couldn't alert anyone. Furthermore, if
2728  *  PhysicsFS itself had a problem (disk error or whatnot), it couldn't report
2729  *  it to the calling app, it would just have to skip items or stop
2730  *  enumerating outright, and the caller wouldn't know it had lost some data
2731  *  along the way.
2732  *
2733  * Now the caller can be sure it got a complete data set, and its callback has
2734  *  control if it wants enumeration to stop early. See the documentation for
2735  *  PHYSFS_EnumerateCallback for details on how your callback should behave.
2736  *
2737  *    \param dir Directory, in platform-independent notation, to enumerate.
2738  *    \param c Callback function to notify about search path elements.
2739  *    \param d Application-defined data passed to callback. Can be NULL.
2740  *   \return non-zero on success, zero on failure. Use
2741  *           PHYSFS_getLastErrorCode() to obtain the specific error. If the
2742  *           callback returns PHYSFS_ENUM_STOP to stop early, this will be
2743  *           considered success. Callbacks returning PHYSFS_ENUM_ERROR will
2744  *           make this function return zero and set the error code to
2745  *           PHYSFS_ERR_APP_CALLBACK.
2746  *
2747  * \sa PHYSFS_EnumerateCallback
2748  * \sa PHYSFS_enumerateFiles
2749  */
2750 PHYSFS_DECL int PHYSFS_enumerate(const char *dir, PHYSFS_EnumerateCallback c,
2751                                  void *d);
2752 
2753 
2754 /**
2755  * \fn int PHYSFS_unmount(const char *oldDir)
2756  * \brief Remove a directory or archive from the search path.
2757  *
2758  * This is functionally equivalent to PHYSFS_removeFromSearchPath(), but that
2759  *  function is deprecated to keep the vocabulary paired with PHYSFS_mount().
2760  *
2761  * This must be a (case-sensitive) match to a dir or archive already in the
2762  *  search path, specified in platform-dependent notation.
2763  *
2764  * This call will fail (and fail to remove from the path) if the element still
2765  *  has files open in it.
2766  *
2767  * \warning This function wants the path to the archive or directory that was
2768  *          mounted (the same string used for the "newDir" argument of
2769  *          PHYSFS_addToSearchPath or any of the mount functions), not the
2770  *          path where it is mounted in the tree (the "mountPoint" argument
2771  *          to any of the mount functions).
2772  *
2773  *    \param oldDir dir/archive to remove.
2774  *   \return nonzero on success, zero on failure. Use
2775  *           PHYSFS_getLastErrorCode() to obtain the specific error.
2776  *
2777  * \sa PHYSFS_getSearchPath
2778  * \sa PHYSFS_mount
2779  */
2780 PHYSFS_DECL int PHYSFS_unmount(const char *oldDir);
2781 
2782 
2783 /**
2784  * \fn const PHYSFS_Allocator *PHYSFS_getAllocator(void)
2785  * \brief Discover the current allocator.
2786  *
2787  * (This is for limited, hardcore use. If you don't immediately see a need
2788  *  for it, you can probably ignore this forever.)
2789  *
2790  * This function exposes the function pointers that make up the currently used
2791  *  allocator. This can be useful for apps that want to access PhysicsFS's
2792  *  internal, default allocation routines, as well as for external code that
2793  *  wants to share the same allocator, even if the application specified their
2794  *  own.
2795  *
2796  * This call is only valid between PHYSFS_init() and PHYSFS_deinit() calls;
2797  *  it will return NULL if the library isn't initialized. As we can't
2798  *  guarantee the state of the internal allocators unless the library is
2799  *  initialized, you shouldn't use any allocator returned here after a call
2800  *  to PHYSFS_deinit().
2801  *
2802  * Do not call the returned allocator's Init() or Deinit() methods under any
2803  *  circumstances.
2804  *
2805  * If you aren't immediately sure what to do with this function, you can
2806  *  safely ignore it altogether.
2807  *
2808  *  \return Current allocator, as set by PHYSFS_setAllocator(), or PhysicsFS's
2809  *          internal, default allocator if no application defined allocator
2810  *          is currently set. Will return NULL if the library is not
2811  *          initialized.
2812  *
2813  * \sa PHYSFS_Allocator
2814  * \sa PHYSFS_setAllocator
2815  */
2816 PHYSFS_DECL const PHYSFS_Allocator *PHYSFS_getAllocator(void);
2817 
2818 
2819 /**
2820  * \enum PHYSFS_FileType
2821  * \brief Type of a File
2822  *
2823  * Possible types of a file.
2824  *
2825  * \sa PHYSFS_stat
2826  */
2827 typedef enum PHYSFS_FileType
2828 {
2829 	PHYSFS_FILETYPE_REGULAR, /**< a normal file */
2830 	PHYSFS_FILETYPE_DIRECTORY, /**< a directory */
2831 	PHYSFS_FILETYPE_SYMLINK, /**< a symlink */
2832 	PHYSFS_FILETYPE_OTHER /**< something completely different like a device */
2833 } PHYSFS_FileType;
2834 
2835 /**
2836  * \struct PHYSFS_Stat
2837  * \brief Meta data for a file or directory
2838  *
2839  * Container for various meta data about a file in the virtual file system.
2840  *  PHYSFS_stat() uses this structure for returning the information. The time
2841  *  data will be either the number of seconds since the Unix epoch (midnight,
2842  *  Jan 1, 1970), or -1 if the information isn't available or applicable.
2843  *  The (filesize) field is measured in bytes.
2844  *  The (readonly) field tells you whether the archive thinks a file is
2845  *  not writable, but tends to be only an estimate (for example, your write
2846  *  dir might overlap with a .zip file, meaning you _can_ successfully open
2847  *  that path for writing, as it gets created elsewhere.
2848  *
2849  * \sa PHYSFS_stat
2850  * \sa PHYSFS_FileType
2851  */
2852 typedef struct PHYSFS_Stat
2853 {
2854 	PHYSFS_sint64 filesize; /**< size in bytes, -1 for non-files and unknown */
2855 	PHYSFS_sint64 modtime;  /**< last modification time */
2856 	PHYSFS_sint64 createtime; /**< like modtime, but for file creation time */
2857 	PHYSFS_sint64 accesstime; /**< like modtime, but for file access time */
2858 	PHYSFS_FileType filetype; /**< File? Directory? Symlink? */
2859 	int readonly; /**< non-zero if read only, zero if writable. */
2860 } PHYSFS_Stat;
2861 
2862 /**
2863  * \fn int PHYSFS_stat(const char *fname, PHYSFS_Stat *stat)
2864  * \brief Get various information about a directory or a file.
2865  *
2866  * Obtain various information about a file or directory from the meta data.
2867  *
2868  * This function will never follow symbolic links. If you haven't enabled
2869  *  symlinks with PHYSFS_permitSymbolicLinks(), stat'ing a symlink will be
2870  *  treated like stat'ing a non-existant file. If symlinks are enabled,
2871  *  stat'ing a symlink will give you information on the link itself and not
2872  *  what it points to.
2873  *
2874  *    \param fname filename to check, in platform-indepedent notation.
2875  *    \param stat pointer to structure to fill in with data about (fname).
2876  *   \return non-zero on success, zero on failure. On failure, (stat)'s
2877  *           contents are undefined.
2878  *
2879  * \sa PHYSFS_Stat
2880  */
2881 PHYSFS_DECL int PHYSFS_stat(const char *fname, PHYSFS_Stat *stat);
2882 
2883 
2884 /**
2885  * \fn void PHYSFS_utf8FromUtf16(const PHYSFS_uint16 *src, char *dst, PHYSFS_uint64 len)
2886  * \brief Convert a UTF-16 string to a UTF-8 string.
2887  *
2888  * \warning This function will not report an error if there are invalid UTF-16
2889  *          sequences in the source string. It will replace them with a '?'
2890  *          character and continue on.
2891  *
2892  * UTF-16 strings are 16-bits per character (except some chars, which are
2893  *  32-bits): \c TCHAR on Windows, when building with Unicode support. Modern
2894  *  Windows releases use UTF-16. Windows releases before 2000 used TCHAR, but
2895  *  only handled UCS-2. UTF-16 _is_ UCS-2, except for the characters that
2896  *  are 4 bytes, which aren't representable in UCS-2 at all anyhow. If you
2897  *  aren't sure, you should be using UTF-16 at this point on Windows.
2898  *
2899  * To ensure that the destination buffer is large enough for the conversion,
2900  *  please allocate a buffer that is double the size of the source buffer.
2901  *  UTF-8 never uses more than 32-bits per character, so while it may shrink
2902  *  a UTF-16 string, it may also expand it.
2903  *
2904  * Strings that don't fit in the destination buffer will be truncated, but
2905  *  will always be null-terminated and never have an incomplete UTF-8
2906  *  sequence at the end. If the buffer length is 0, this function does nothing.
2907  *
2908  *   \param src Null-terminated source string in UTF-16 format.
2909  *   \param dst Buffer to store converted UTF-8 string.
2910  *   \param len Size, in bytes, of destination buffer.
2911  */
2912 PHYSFS_DECL void PHYSFS_utf8FromUtf16(const PHYSFS_uint16 *src, char *dst,
2913                                       PHYSFS_uint64 len);
2914 
2915 /**
2916  * \fn PHYSFS_utf8ToUtf16(const char *src, PHYSFS_uint16 *dst, PHYSFS_uint64 len)
2917  * \brief Convert a UTF-8 string to a UTF-16 string.
2918  *
2919  * \warning This function will not report an error if there are invalid UTF-8
2920  *          sequences in the source string. It will replace them with a '?'
2921  *          character and continue on.
2922  *
2923  * UTF-16 strings are 16-bits per character (except some chars, which are
2924  *  32-bits): \c TCHAR on Windows, when building with Unicode support. Modern
2925  *  Windows releases use UTF-16. Windows releases before 2000 used TCHAR, but
2926  *  only handled UCS-2. UTF-16 _is_ UCS-2, except for the characters that
2927  *  are 4 bytes, which aren't representable in UCS-2 at all anyhow. If you
2928  *  aren't sure, you should be using UTF-16 at this point on Windows.
2929  *
2930  * To ensure that the destination buffer is large enough for the conversion,
2931  *  please allocate a buffer that is double the size of the source buffer.
2932  *  UTF-8 uses from one to four bytes per character, but UTF-16 always uses
2933  *  two to four, so an entirely low-ASCII string will double in size! The
2934  *  UTF-16 characters that would take four bytes also take four bytes in UTF-8,
2935  *  so you don't need to allocate 4x the space just in case: double will do.
2936  *
2937  * Strings that don't fit in the destination buffer will be truncated, but
2938  *  will always be null-terminated and never have an incomplete UTF-16
2939  *  surrogate pair at the end. If the buffer length is 0, this function does
2940  *  nothing.
2941  *
2942  *   \param src Null-terminated source string in UTF-8 format.
2943  *   \param dst Buffer to store converted UTF-16 string.
2944  *   \param len Size, in bytes, of destination buffer.
2945  *
2946  * \sa PHYSFS_utf8ToUtf16
2947  */
2948 PHYSFS_DECL void PHYSFS_utf8ToUtf16(const char *src, PHYSFS_uint16 *dst,
2949                                     PHYSFS_uint64 len);
2950 
2951 
2952 /**
2953  * \fn PHYSFS_sint64 PHYSFS_readBytes(PHYSFS_File *handle, void *buffer, PHYSFS_uint64 len)
2954  * \brief Read bytes from a PhysicsFS filehandle
2955  *
2956  * The file must be opened for reading.
2957  *
2958  *   \param handle handle returned from PHYSFS_openRead().
2959  *   \param buffer buffer of at least (len) bytes to store read data into.
2960  *   \param len number of bytes being read from (handle).
2961  *  \return number of bytes read. This may be less than (len); this does not
2962  *          signify an error, necessarily (a short read may mean EOF).
2963  *          PHYSFS_getLastErrorCode() can shed light on the reason this might
2964  *          be < (len), as can PHYSFS_eof(). -1 if complete failure.
2965  *
2966  * \sa PHYSFS_eof
2967  */
2968 PHYSFS_DECL PHYSFS_sint64 PHYSFS_readBytes(PHYSFS_File *handle, void *buffer,
2969                                            PHYSFS_uint64 len);
2970 
2971 /**
2972  * \fn PHYSFS_sint64 PHYSFS_writeBytes(PHYSFS_File *handle, const void *buffer, PHYSFS_uint64 len)
2973  * \brief Write data to a PhysicsFS filehandle
2974  *
2975  * The file must be opened for writing.
2976  *
2977  * Please note that while (len) is an unsigned 64-bit integer, you are limited
2978  *  to 63 bits (9223372036854775807 bytes), so we can return a negative value
2979  *  on error. If length is greater than 0x7FFFFFFFFFFFFFFF, this function will
2980  *  immediately fail. For systems without a 64-bit datatype, you are limited
2981  *  to 31 bits (0x7FFFFFFF, or 2147483647 bytes). We trust most things won't
2982  *  need to do multiple gigabytes of i/o in one call anyhow, but why limit
2983  *  things?
2984  *
2985  *   \param handle retval from PHYSFS_openWrite() or PHYSFS_openAppend().
2986  *   \param buffer buffer of (len) bytes to write to (handle).
2987  *   \param len number of bytes being written to (handle).
2988  *  \return number of bytes written. This may be less than (len); in the case
2989  *          of an error, the system may try to write as many bytes as possible,
2990  *          so an incomplete write might occur. PHYSFS_getLastErrorCode() can
2991  *          shed light on the reason this might be < (len). -1 if complete
2992  *          failure.
2993  */
2994 PHYSFS_DECL PHYSFS_sint64 PHYSFS_writeBytes(PHYSFS_File *handle,
2995                                             const void *buffer,
2996                                             PHYSFS_uint64 len);
2997 
2998 
2999 /**
3000  * \struct PHYSFS_Io
3001  * \brief An abstract i/o interface.
3002  *
3003  * \warning This is advanced, hardcore stuff. You don't need this unless you
3004  *          really know what you're doing. Most apps will not need this.
3005  *
3006  * Historically, PhysicsFS provided access to the physical filesystem and
3007  *  archives within that filesystem. However, sometimes you need more power
3008  *  than this. Perhaps you need to provide an archive that is entirely
3009  *  contained in RAM, or you need to bridge some other file i/o API to
3010  *  PhysicsFS, or you need to translate the bits (perhaps you have a
3011  *  a standard .zip file that's encrypted, and you need to decrypt on the fly
3012  *  for the unsuspecting zip archiver).
3013  *
3014  * A PHYSFS_Io is the interface that Archivers use to get archive data.
3015  *  Historically, this has mapped to file i/o to the physical filesystem, but
3016  *  as of PhysicsFS 2.1, applications can provide their own i/o implementations
3017  *  at runtime.
3018  *
3019  * This interface isn't necessarily a good universal fit for i/o. There are a
3020  *  few requirements of note:
3021  *
3022  *  - They only do blocking i/o (at least, for now).
3023  *  - They need to be able to duplicate. If you have a file handle from
3024  *    fopen(), you need to be able to create a unique clone of it (so we
3025  *    have two handles to the same file that can both seek/read/etc without
3026  *    stepping on each other).
3027  *  - They need to know the size of their entire data set.
3028  *  - They need to be able to seek and rewind on demand.
3029  *
3030  * ...in short, you're probably not going to write an HTTP implementation.
3031  *
3032  * Thread safety: PHYSFS_Io implementations are not guaranteed to be thread
3033  *  safe in themselves. Under the hood where PhysicsFS uses them, the library
3034  *  provides its own locks. If you plan to use them directly from separate
3035  *  threads, you should either use mutexes to protect them, or don't use the
3036  *  same PHYSFS_Io from two threads at the same time.
3037  *
3038  * \sa PHYSFS_mountIo
3039  */
3040 typedef struct PHYSFS_Io
3041 {
3042     /**
3043      * \brief Binary compatibility information.
3044      *
3045      * This must be set to zero at this time. Future versions of this
3046      *  struct will increment this field, so we know what a given
3047      *  implementation supports. We'll presumably keep supporting older
3048      *  versions as we offer new features, though.
3049      */
3050     PHYSFS_uint32 version;
3051 
3052     /**
3053      * \brief Instance data for this struct.
3054      *
3055      * Each instance has a pointer associated with it that can be used to
3056      *  store anything it likes. This pointer is per-instance of the stream,
3057      *  so presumably it will change when calling duplicate(). This can be
3058      *  deallocated during the destroy() method.
3059      */
3060     void *opaque;
3061 
3062     /**
3063      * \brief Read more data.
3064      *
3065      * Read (len) bytes from the interface, at the current i/o position, and
3066      *  store them in (buffer). The current i/o position should move ahead
3067      *  by the number of bytes successfully read.
3068      *
3069      * You don't have to implement this; set it to NULL if not implemented.
3070      *  This will only be used if the file is opened for reading. If set to
3071      *  NULL, a default implementation that immediately reports failure will
3072      *  be used.
3073      *
3074      *   \param io The i/o instance to read from.
3075      *   \param buf The buffer to store data into. It must be at least
3076      *                 (len) bytes long and can't be NULL.
3077      *   \param len The number of bytes to read from the interface.
3078      *  \return number of bytes read from file, 0 on EOF, -1 if complete
3079      *          failure.
3080      */
3081     PHYSFS_sint64 (*read)(struct PHYSFS_Io *io, void *buf, PHYSFS_uint64 len);
3082 
3083     /**
3084      * \brief Write more data.
3085      *
3086      * Write (len) bytes from (buffer) to the interface at the current i/o
3087      *  position. The current i/o position should move ahead by the number of
3088      *  bytes successfully written.
3089      *
3090      * You don't have to implement this; set it to NULL if not implemented.
3091      *  This will only be used if the file is opened for writing. If set to
3092      *  NULL, a default implementation that immediately reports failure will
3093      *  be used.
3094      *
3095      * You are allowed to buffer; a write can succeed here and then later
3096      *  fail when flushing. Note that PHYSFS_setBuffer() may be operating a
3097      *  level above your i/o, so you should usually not implement your
3098      *  own buffering routines.
3099      *
3100      *   \param io The i/o instance to write to.
3101      *   \param buffer The buffer to read data from. It must be at least
3102      *                 (len) bytes long and can't be NULL.
3103      *   \param len The number of bytes to read from (buffer).
3104      *  \return number of bytes written to file, -1 if complete failure.
3105      */
3106     PHYSFS_sint64 (*write)(struct PHYSFS_Io *io, const void *buffer,
3107                            PHYSFS_uint64 len);
3108 
3109     /**
3110      * \brief Move i/o position to a given byte offset from start.
3111      *
3112      * This method moves the i/o position, so the next read/write will
3113      *  be of the byte at (offset) offset. Seeks past the end of file should
3114      *  be treated as an error condition.
3115      *
3116      *   \param io The i/o instance to seek.
3117      *   \param offset The new byte offset for the i/o position.
3118      *  \return non-zero on success, zero on error.
3119      */
3120     int (*seek)(struct PHYSFS_Io *io, PHYSFS_uint64 offset);
3121 
3122     /**
3123      * \brief Report current i/o position.
3124      *
3125      * Return bytes offset, or -1 if you aren't able to determine. A failure
3126      *  will almost certainly be fatal to further use of this stream, so you
3127      *  may not leave this unimplemented.
3128      *
3129      *   \param io The i/o instance to query.
3130      *  \return The current byte offset for the i/o position, -1 if unknown.
3131      */
3132     PHYSFS_sint64 (*tell)(struct PHYSFS_Io *io);
3133 
3134     /**
3135      * \brief Determine size of the i/o instance's dataset.
3136      *
3137      * Return number of bytes available in the file, or -1 if you
3138      *  aren't able to determine. A failure will almost certainly be fatal
3139      *  to further use of this stream, so you may not leave this unimplemented.
3140      *
3141      *   \param io The i/o instance to query.
3142      *  \return Total size, in bytes, of the dataset.
3143      */
3144     PHYSFS_sint64 (*length)(struct PHYSFS_Io *io);
3145 
3146     /**
3147      * \brief Duplicate this i/o instance.
3148      *
3149      * This needs to result in a full copy of this PHYSFS_Io, that can live
3150      *  completely independently. The copy needs to be able to perform all
3151      *  its operations without altering the original, including either object
3152      *  being destroyed separately (so, for example: they can't share a file
3153      *  handle; they each need their own).
3154      *
3155      * If you can't duplicate a handle, it's legal to return NULL, but you
3156      *  almost certainly need this functionality if you want to use this to
3157      *  PHYSFS_Io to back an archive.
3158      *
3159      *   \param io The i/o instance to duplicate.
3160      *  \return A new value for a stream's (opaque) field, or NULL on error.
3161      */
3162     struct PHYSFS_Io *(*duplicate)(struct PHYSFS_Io *io);
3163 
3164     /**
3165      * \brief Flush resources to media, or wherever.
3166      *
3167      * This is the chance to report failure for writes that had claimed
3168      *  success earlier, but still had a chance to actually fail. This method
3169      *  can be NULL if flushing isn't necessary.
3170      *
3171      * This function may be called before destroy(), as it can report failure
3172      *  and destroy() can not. It may be called at other times, too.
3173      *
3174      *   \param io The i/o instance to flush.
3175      *  \return Zero on error, non-zero on success.
3176      */
3177     int (*flush)(struct PHYSFS_Io *io);
3178 
3179     /**
3180      * \brief Cleanup and deallocate i/o instance.
3181      *
3182      * Free associated resources, including (opaque) if applicable.
3183      *
3184      * This function must always succeed: as such, it returns void. The
3185      *  system may call your flush() method before this. You may report
3186      *  failure there if necessary. This method may still be called if
3187      *  flush() fails, in which case you'll have to abandon unflushed data
3188      *  and other failing conditions and clean up.
3189      *
3190      * Once this method is called for a given instance, the system will assume
3191      *  it is unsafe to touch that instance again and will discard any
3192      *  references to it.
3193      *
3194      *   \param s The i/o instance to destroy.
3195      */
3196     void (*destroy)(struct PHYSFS_Io *io);
3197 } PHYSFS_Io;
3198 
3199 
3200 /**
3201  * \fn int PHYSFS_mountIo(PHYSFS_Io *io, const char *newDir, const char *mountPoint, int appendToPath)
3202  * \brief Add an archive, built on a PHYSFS_Io, to the search path.
3203  *
3204  * \warning Unless you have some special, low-level need, you should be using
3205  *          PHYSFS_mount() instead of this.
3206  *
3207  * This function operates just like PHYSFS_mount(), but takes a PHYSFS_Io
3208  *  instead of a pathname. Behind the scenes, PHYSFS_mount() calls this
3209  *  function with a physical-filesystem-based PHYSFS_Io.
3210  *
3211  * (newDir) must be a unique string to identify this archive. It is used
3212  *  to optimize archiver selection (if you name it XXXXX.zip, we might try
3213  *  the ZIP archiver first, for example, or directly choose an archiver that
3214  *  can only trust the data is valid by filename extension). It doesn't
3215  *  need to refer to a real file at all. If the filename extension isn't
3216  *  helpful, the system will try every archiver until one works or none
3217  *  of them do. This filename must be unique, as the system won't allow you
3218  *  to have two archives with the same name.
3219  *
3220  * (io) must remain until the archive is unmounted. When the archive is
3221  *  unmounted, the system will call (io)->destroy(io), which will give you
3222  *  a chance to free your resources.
3223  *
3224  * If this function fails, (io)->destroy(io) is not called.
3225  *
3226  *   \param io i/o instance for archive to add to the path.
3227  *   \param newDir Filename that can represent this stream.
3228  *   \param mountPoint Location in the interpolated tree that this archive
3229  *                     will be "mounted", in platform-independent notation.
3230  *                     NULL or "" is equivalent to "/".
3231  *   \param appendToPath nonzero to append to search path, zero to prepend.
3232  *  \return nonzero if added to path, zero on failure (bogus archive, stream
3233  *                   i/o issue, etc). Use PHYSFS_getLastErrorCode() to obtain
3234  *                   the specific error.
3235  *
3236  * \sa PHYSFS_unmount
3237  * \sa PHYSFS_getSearchPath
3238  * \sa PHYSFS_getMountPoint
3239  */
3240 PHYSFS_DECL int PHYSFS_mountIo(PHYSFS_Io *io, const char *newDir,
3241                                const char *mountPoint, int appendToPath);
3242 
3243 
3244 /**
3245  * \fn int PHYSFS_mountMemory(const void *buf, PHYSFS_uint64 len, void (*del)(void *), const char *newDir, const char *mountPoint, int appendToPath)
3246  * \brief Add an archive, contained in a memory buffer, to the search path.
3247  *
3248  * \warning Unless you have some special, low-level need, you should be using
3249  *          PHYSFS_mount() instead of this.
3250  *
3251  * This function operates just like PHYSFS_mount(), but takes a memory buffer
3252  *  instead of a pathname. This buffer contains all the data of the archive,
3253  *  and is used instead of a real file in the physical filesystem.
3254  *
3255  * (newDir) must be a unique string to identify this archive. It is used
3256  *  to optimize archiver selection (if you name it XXXXX.zip, we might try
3257  *  the ZIP archiver first, for example, or directly choose an archiver that
3258  *  can only trust the data is valid by filename extension). It doesn't
3259  *  need to refer to a real file at all. If the filename extension isn't
3260  *  helpful, the system will try every archiver until one works or none
3261  *  of them do. This filename must be unique, as the system won't allow you
3262  *  to have two archives with the same name.
3263  *
3264  * (ptr) must remain until the archive is unmounted. When the archive is
3265  *  unmounted, the system will call (del)(ptr), which will notify you that
3266  *  the system is done with the buffer, and give you a chance to free your
3267  *  resources. (del) can be NULL, in which case the system will make no
3268  *  attempt to free the buffer.
3269  *
3270  * If this function fails, (del) is not called.
3271  *
3272  *   \param buf Address of the memory buffer containing the archive data.
3273  *   \param len Size of memory buffer, in bytes.
3274  *   \param del A callback that triggers upon unmount. Can be NULL.
3275  *   \param newDir Filename that can represent this stream.
3276  *   \param mountPoint Location in the interpolated tree that this archive
3277  *                     will be "mounted", in platform-independent notation.
3278  *                     NULL or "" is equivalent to "/".
3279  *   \param appendToPath nonzero to append to search path, zero to prepend.
3280  *  \return nonzero if added to path, zero on failure (bogus archive, etc).
3281  *          Use PHYSFS_getLastErrorCode() to obtain the specific error.
3282  *
3283  * \sa PHYSFS_unmount
3284  * \sa PHYSFS_getSearchPath
3285  * \sa PHYSFS_getMountPoint
3286  */
3287 PHYSFS_DECL int PHYSFS_mountMemory(const void *buf, PHYSFS_uint64 len,
3288                                    void (*del)(void *), const char *newDir,
3289                                    const char *mountPoint, int appendToPath);
3290 
3291 
3292 /**
3293  * \fn int PHYSFS_mountHandle(PHYSFS_File *file, const char *newDir, const char *mountPoint, int appendToPath)
3294  * \brief Add an archive, contained in a PHYSFS_File handle, to the search path.
3295  *
3296  * \warning Unless you have some special, low-level need, you should be using
3297  *          PHYSFS_mount() instead of this.
3298  *
3299  * \warning Archives-in-archives may be very slow! While a PHYSFS_File can
3300  *          seek even when the data is compressed, it may do so by rewinding
3301  *          to the start and decompressing everything before the seek point.
3302  *          Normal archive usage may do a lot of seeking behind the scenes.
3303  *          As such, you might find normal archive usage extremely painful
3304  *          if mounted this way. Plan accordingly: if you, say, have a
3305  *          self-extracting .zip file, and want to mount something in it,
3306  *          compress the contents of the inner archive and make sure the outer
3307  *          .zip file doesn't compress the inner archive too.
3308  *
3309  * This function operates just like PHYSFS_mount(), but takes a PHYSFS_File
3310  *  handle instead of a pathname. This handle contains all the data of the
3311  *  archive, and is used instead of a real file in the physical filesystem.
3312  *  The PHYSFS_File may be backed by a real file in the physical filesystem,
3313  *  but isn't necessarily. The most popular use for this is likely to mount
3314  *  archives stored inside other archives.
3315  *
3316  * (newDir) must be a unique string to identify this archive. It is used
3317  *  to optimize archiver selection (if you name it XXXXX.zip, we might try
3318  *  the ZIP archiver first, for example, or directly choose an archiver that
3319  *  can only trust the data is valid by filename extension). It doesn't
3320  *  need to refer to a real file at all. If the filename extension isn't
3321  *  helpful, the system will try every archiver until one works or none
3322  *  of them do. This filename must be unique, as the system won't allow you
3323  *  to have two archives with the same name.
3324  *
3325  * (file) must remain until the archive is unmounted. When the archive is
3326  *  unmounted, the system will call PHYSFS_close(file). If you need this
3327  *  handle to survive, you will have to wrap this in a PHYSFS_Io and use
3328  *  PHYSFS_mountIo() instead.
3329  *
3330  * If this function fails, PHYSFS_close(file) is not called.
3331  *
3332  *   \param file The PHYSFS_File handle containing archive data.
3333  *   \param newDir Filename that can represent this stream.
3334  *   \param mountPoint Location in the interpolated tree that this archive
3335  *                     will be "mounted", in platform-independent notation.
3336  *                     NULL or "" is equivalent to "/".
3337  *   \param appendToPath nonzero to append to search path, zero to prepend.
3338  *  \return nonzero if added to path, zero on failure (bogus archive, etc).
3339  *          Use PHYSFS_getLastErrorCode() to obtain the specific error.
3340  *
3341  * \sa PHYSFS_unmount
3342  * \sa PHYSFS_getSearchPath
3343  * \sa PHYSFS_getMountPoint
3344  */
3345 PHYSFS_DECL int PHYSFS_mountHandle(PHYSFS_File *file, const char *newDir,
3346                                    const char *mountPoint, int appendToPath);
3347 
3348 
3349 /**
3350  * \enum PHYSFS_ErrorCode
3351  * \brief Values that represent specific causes of failure.
3352  *
3353  * Most of the time, you should only concern yourself with whether a given
3354  *  operation failed or not, but there may be occasions where you plan to
3355  *  handle a specific failure case gracefully, so we provide specific error
3356  *  codes.
3357  *
3358  * Most of these errors are a little vague, and most aren't things you can
3359  *  fix...if there's a permission error, for example, all you can really do
3360  *  is pass that information on to the user and let them figure out how to
3361  *  handle it. In most these cases, your program should only care that it
3362  *  failed to accomplish its goals, and not care specifically why.
3363  *
3364  * \sa PHYSFS_getLastErrorCode
3365  * \sa PHYSFS_getErrorByCode
3366  */
3367 typedef enum PHYSFS_ErrorCode
3368 {
3369     PHYSFS_ERR_OK,               /**< Success; no error.                    */
3370     PHYSFS_ERR_OTHER_ERROR,      /**< Error not otherwise covered here.     */
3371     PHYSFS_ERR_OUT_OF_MEMORY,    /**< Memory allocation failed.             */
3372     PHYSFS_ERR_NOT_INITIALIZED,  /**< PhysicsFS is not initialized.         */
3373     PHYSFS_ERR_IS_INITIALIZED,   /**< PhysicsFS is already initialized.     */
3374     PHYSFS_ERR_ARGV0_IS_NULL,    /**< Needed argv[0], but it is NULL.       */
3375     PHYSFS_ERR_UNSUPPORTED,      /**< Operation or feature unsupported.     */
3376     PHYSFS_ERR_PAST_EOF,         /**< Attempted to access past end of file. */
3377     PHYSFS_ERR_FILES_STILL_OPEN, /**< Files still open.                     */
3378     PHYSFS_ERR_INVALID_ARGUMENT, /**< Bad parameter passed to an function.  */
3379     PHYSFS_ERR_NOT_MOUNTED,      /**< Requested archive/dir not mounted.    */
3380     PHYSFS_ERR_NOT_FOUND,        /**< File (or whatever) not found.         */
3381     PHYSFS_ERR_SYMLINK_FORBIDDEN,/**< Symlink seen when not permitted.      */
3382     PHYSFS_ERR_NO_WRITE_DIR,     /**< No write dir has been specified.      */
3383     PHYSFS_ERR_OPEN_FOR_READING, /**< Wrote to a file opened for reading.   */
3384     PHYSFS_ERR_OPEN_FOR_WRITING, /**< Read from a file opened for writing.  */
3385     PHYSFS_ERR_NOT_A_FILE,       /**< Needed a file, got a directory (etc). */
3386     PHYSFS_ERR_READ_ONLY,        /**< Wrote to a read-only filesystem.      */
3387     PHYSFS_ERR_CORRUPT,          /**< Corrupted data encountered.           */
3388     PHYSFS_ERR_SYMLINK_LOOP,     /**< Infinite symbolic link loop.          */
3389     PHYSFS_ERR_IO,               /**< i/o error (hardware failure, etc).    */
3390     PHYSFS_ERR_PERMISSION,       /**< Permission denied.                    */
3391     PHYSFS_ERR_NO_SPACE,         /**< No space (disk full, over quota, etc) */
3392     PHYSFS_ERR_BAD_FILENAME,     /**< Filename is bogus/insecure.           */
3393     PHYSFS_ERR_BUSY,             /**< Tried to modify a file the OS needs.  */
3394     PHYSFS_ERR_DIR_NOT_EMPTY,    /**< Tried to delete dir with files in it. */
3395     PHYSFS_ERR_OS_ERROR,         /**< Unspecified OS-level error.           */
3396     PHYSFS_ERR_DUPLICATE,        /**< Duplicate entry.                      */
3397     PHYSFS_ERR_BAD_PASSWORD,     /**< Bad password.                         */
3398     PHYSFS_ERR_APP_CALLBACK      /**< Application callback reported error.  */
3399 } PHYSFS_ErrorCode;
3400 
3401 
3402 /**
3403  * \fn PHYSFS_ErrorCode PHYSFS_getLastErrorCode(void)
3404  * \brief Get machine-readable error information.
3405  *
3406  * Get the last PhysicsFS error message as an integer value. This will return
3407  *  PHYSFS_ERR_OK if there's been no error since the last call to this
3408  *  function. Each thread has a unique error state associated with it, but
3409  *  each time a new error message is set, it will overwrite the previous one
3410  *  associated with that thread. It is safe to call this function at anytime,
3411  *  even before PHYSFS_init().
3412  *
3413  * PHYSFS_getLastError() and PHYSFS_getLastErrorCode() both reset the same
3414  *  thread-specific error state. Calling one will wipe out the other's
3415  *  data. If you need both, call PHYSFS_getLastErrorCode(), then pass that
3416  *  value to PHYSFS_getErrorByCode().
3417  *
3418  * Generally, applications should only concern themselves with whether a
3419  *  given function failed; however, if you require more specifics, you can
3420  *  try this function to glean information, if there's some specific problem
3421  *  you're expecting and plan to handle. But with most things that involve
3422  *  file systems, the best course of action is usually to give up, report the
3423  *  problem to the user, and let them figure out what should be done about it.
3424  *  For that, you might prefer PHYSFS_getErrorByCode() instead.
3425  *
3426  *   \return Enumeration value that represents last reported error.
3427  *
3428  * \sa PHYSFS_getErrorByCode
3429  */
3430 PHYSFS_DECL PHYSFS_ErrorCode PHYSFS_getLastErrorCode(void);
3431 
3432 
3433 /**
3434  * \fn const char *PHYSFS_getErrorByCode(PHYSFS_ErrorCode code)
3435  * \brief Get human-readable description string for a given error code.
3436  *
3437  * Get a static string, in UTF-8 format, that represents an English
3438  *  description of a given error code.
3439  *
3440  * This string is guaranteed to never change (although we may add new strings
3441  *  for new error codes in later versions of PhysicsFS), so you can use it
3442  *  for keying a localization dictionary.
3443  *
3444  * It is safe to call this function at anytime, even before PHYSFS_init().
3445  *
3446  * These strings are meant to be passed on directly to the user.
3447  *  Generally, applications should only concern themselves with whether a
3448  *  given function failed, but not care about the specifics much.
3449  *
3450  * Do not attempt to free the returned strings; they are read-only and you
3451  *  don't own their memory pages.
3452  *
3453  *   \param code Error code to convert to a string.
3454  *   \return READ ONLY string of requested error message, NULL if this
3455  *           is not a valid PhysicsFS error code. Always check for NULL if
3456  *           you might be looking up an error code that didn't exist in an
3457  *           earlier version of PhysicsFS.
3458  *
3459  * \sa PHYSFS_getLastErrorCode
3460  */
3461 PHYSFS_DECL const char *PHYSFS_getErrorByCode(PHYSFS_ErrorCode code);
3462 
3463 /**
3464  * \fn void PHYSFS_setErrorCode(PHYSFS_ErrorCode code)
3465  * \brief Set the current thread's error code.
3466  *
3467  * This lets you set the value that will be returned by the next call to
3468  *  PHYSFS_getLastErrorCode(). This will replace any existing error code,
3469  *  whether set by your application or internally by PhysicsFS.
3470  *
3471  * Error codes are stored per-thread; what you set here will not be
3472  *  accessible to another thread.
3473  *
3474  * Any call into PhysicsFS may change the current error code, so any code you
3475  *  set here is somewhat fragile, and thus you shouldn't build any serious
3476  *  error reporting framework on this function. The primary goal of this
3477  *  function is to allow PHYSFS_Io implementations to set the error state,
3478  *  which generally will be passed back to your application when PhysicsFS
3479  *  makes a PHYSFS_Io call that fails internally.
3480  *
3481  * This function doesn't care if the error code is a value known to PhysicsFS
3482  *  or not (but PHYSFS_getErrorByCode() will return NULL for unknown values).
3483  *  The value will be reported unmolested by PHYSFS_getLastErrorCode().
3484  *
3485  *   \param code Error code to become the current thread's new error state.
3486  *
3487  * \sa PHYSFS_getLastErrorCode
3488  * \sa PHYSFS_getErrorByCode
3489  */
3490 PHYSFS_DECL void PHYSFS_setErrorCode(PHYSFS_ErrorCode code);
3491 
3492 
3493 /**
3494  * \fn const char *PHYSFS_getPrefDir(const char *org, const char *app)
3495  * \brief Get the user-and-app-specific path where files can be written.
3496  *
3497  * Helper function.
3498  *
3499  * Get the "pref dir". This is meant to be where users can write personal
3500  *  files (preferences and save games, etc) that are specific to your
3501  *  application. This directory is unique per user, per application.
3502  *
3503  * This function will decide the appropriate location in the native filesystem,
3504  *  create the directory if necessary, and return a string in
3505  *  platform-dependent notation, suitable for passing to PHYSFS_setWriteDir().
3506  *
3507  * On Windows, this might look like:
3508  *  "C:\\Users\\bob\\AppData\\Roaming\\My Company\\My Program Name"
3509  *
3510  * On Linux, this might look like:
3511  *  "/home/bob/.local/share/My Program Name"
3512  *
3513  * On Mac OS X, this might look like:
3514  *  "/Users/bob/Library/Application Support/My Program Name"
3515  *
3516  * (etc.)
3517  *
3518  * You should probably use the pref dir for your write dir, and also put it
3519  *  near the beginning of your search path. Older versions of PhysicsFS
3520  *  offered only PHYSFS_getUserDir() and left you to figure out where the
3521  *  files should go under that tree. This finds the correct location
3522  *  for whatever platform, which not only changes between operating systems,
3523  *  but also versions of the same operating system.
3524  *
3525  * You specify the name of your organization (if it's not a real organization,
3526  *  your name or an Internet domain you own might do) and the name of your
3527  *  application. These should be proper names.
3528  *
3529  * Both the (org) and (app) strings may become part of a directory name, so
3530  *  please follow these rules:
3531  *
3532  *    - Try to use the same org string (including case-sensitivity) for
3533  *      all your applications that use this function.
3534  *    - Always use a unique app string for each one, and make sure it never
3535  *      changes for an app once you've decided on it.
3536  *    - Unicode characters are legal, as long as it's UTF-8 encoded, but...
3537  *    - ...only use letters, numbers, and spaces. Avoid punctuation like
3538  *      "Game Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient.
3539  *
3540  * The pointer returned by this function remains valid until you call this
3541  *  function again, or call PHYSFS_deinit(). This is not necessarily a fast
3542  *  call, though, so you should call this once at startup and copy the string
3543  *  if you need it.
3544  *
3545  * You should assume the path returned by this function is the only safe
3546  *  place to write files (and that PHYSFS_getUserDir() and PHYSFS_getBaseDir(),
3547  *  while they might be writable, or even parents of the returned path, aren't
3548  *  where you should be writing things).
3549  *
3550  *   \param org The name of your organization.
3551  *   \param app The name of your application.
3552  *  \return READ ONLY string of user dir in platform-dependent notation. NULL
3553  *          if there's a problem (creating directory failed, etc).
3554  *
3555  * \sa PHYSFS_getBaseDir
3556  * \sa PHYSFS_getUserDir
3557  */
3558 PHYSFS_DECL const char *PHYSFS_getPrefDir(const char *org, const char *app);
3559 
3560 
3561 /**
3562  * \struct PHYSFS_Archiver
3563  * \brief Abstract interface to provide support for user-defined archives.
3564  *
3565  * \warning This is advanced, hardcore stuff. You don't need this unless you
3566  *          really know what you're doing. Most apps will not need this.
3567  *
3568  * Historically, PhysicsFS provided a means to mount various archive file
3569  *  formats, and physical directories in the native filesystem. However,
3570  *  applications have been limited to the file formats provided by the
3571  *  library. This interface allows an application to provide their own
3572  *  archive file types.
3573  *
3574  * Conceptually, a PHYSFS_Archiver provides directory entries, while
3575  *  PHYSFS_Io provides data streams for those directory entries. The most
3576  *  obvious use of PHYSFS_Archiver is to provide support for an archive
3577  *  file type that isn't provided by PhysicsFS directly: perhaps some
3578  *  proprietary format that only your application needs to understand.
3579  *
3580  * Internally, all the built-in archive support uses this interface, so the
3581  *  best examples for building a PHYSFS_Archiver is the source code to
3582  *  PhysicsFS itself.
3583  *
3584  * An archiver is added to the system with PHYSFS_registerArchiver(), and then
3585  *  it will be available for use automatically with PHYSFS_mount(); if a
3586  *  given archive can be handled with your archiver, it will be given control
3587  *  as appropriate.
3588  *
3589  * These methods deal with dir handles. You have one instance of your
3590  *  archiver, and it generates a unique, opaque handle for each opened
3591  *  archive in its openArchive() method. Since the lifetime of an Archiver
3592  *  (not an archive) is generally the entire lifetime of the process, and it's
3593  *  assumed to be a singleton, we do not provide any instance data for the
3594  *  archiver itself; the app can just use some static variables if necessary.
3595  *
3596  * Symlinks should always be followed (except in stat()); PhysicsFS will
3597  *  use the stat() method to check for symlinks and make a judgement on
3598  *  whether to continue to call other methods based on that.
3599  *
3600  * Archivers, when necessary, should set the PhysicsFS error state with
3601  *  PHYSFS_setErrorCode() before returning. PhysicsFS will pass these errors
3602  *  back to the application unmolested in most cases.
3603  *
3604  * Thread safety: PHYSFS_Archiver implementations are not guaranteed to be
3605  *  thread safe in themselves. PhysicsFS provides thread safety when it calls
3606  *  into a given archiver inside the library, but it does not promise that
3607  *  using the same PHYSFS_File from two threads at once is thread-safe; as
3608  *  such, your PHYSFS_Archiver can assume that locking is handled for you
3609  *  so long as the PHYSFS_Io you return from PHYSFS_open* doesn't change any
3610  *  of your Archiver state, as the PHYSFS_Io won't be as aggressively
3611  *  protected.
3612  *
3613  * \sa PHYSFS_registerArchiver
3614  * \sa PHYSFS_deregisterArchiver
3615  * \sa PHYSFS_supportedArchiveTypes
3616  */
3617 typedef struct PHYSFS_Archiver
3618 {
3619     /**
3620      * \brief Binary compatibility information.
3621      *
3622      * This must be set to zero at this time. Future versions of this
3623      *  struct will increment this field, so we know what a given
3624      *  implementation supports. We'll presumably keep supporting older
3625      *  versions as we offer new features, though.
3626      */
3627     PHYSFS_uint32 version;
3628 
3629     /**
3630      * \brief Basic info about this archiver.
3631      *
3632      * This is used to identify your archive, and is returned in
3633      *  PHYSFS_supportedArchiveTypes().
3634      */
3635     PHYSFS_ArchiveInfo info;
3636 
3637     /**
3638      * \brief Open an archive provided by (io).
3639      *
3640      * This is where resources are allocated and data is parsed when mounting
3641      *  an archive.
3642      * (name) is a filename associated with (io), but doesn't necessarily
3643      *  map to anything, let alone a real filename. This possibly-
3644      *  meaningless name is in platform-dependent notation.
3645      * (forWrite) is non-zero if this is to be used for
3646      *  the write directory, and zero if this is to be used for an
3647      *  element of the search path.
3648      * (claimed) should be set to 1 if this is definitely an archive your
3649      *  archiver implementation can handle, even if it fails. We use to
3650      *  decide if we should stop trying other archivers if you fail to open
3651      *  it. For example: the .zip archiver will set this to 1 for something
3652      *  that's got a .zip file signature, even if it failed because the file
3653      *  was also truncated. No sense in trying other archivers here, we
3654      *  already tried to handle it with the appropriate implementation!.
3655      * Return NULL on failure and set (claimed) appropriately. If no archiver
3656      *  opened the archive or set (claimed), PHYSFS_mount() will report
3657      *  PHYSFS_ERR_UNSUPPORTED. Otherwise, it will report the error from the
3658      *  archiver that claimed the data through (claimed).
3659      * Return non-NULL on success. The pointer returned will be
3660      *  passed as the "opaque" parameter for later calls.
3661      */
3662     void *(*openArchive)(PHYSFS_Io *io, const char *name,
3663                          int forWrite, int *claimed);
3664 
3665     /**
3666      * \brief List all files in (dirname).
3667      *
3668      * Each file is passed to (cb), where a copy is made if appropriate, so
3669      *  you can dispose of it upon return from the callback. (dirname) is in
3670      *  platform-independent notation.
3671      * If you have a failure, call PHYSFS_SetErrorCode() with whatever code
3672      *  seem appropriate and return PHYSFS_ENUM_ERROR.
3673      * If the callback returns PHYSFS_ENUM_ERROR, please call
3674      *  PHYSFS_SetErrorCode(PHYSFS_ERR_APP_CALLBACK) and then return
3675      *  PHYSFS_ENUM_ERROR as well. Don't call the callback again in any
3676      *  circumstances.
3677      * If the callback returns PHYSFS_ENUM_STOP, stop enumerating and return
3678      *  PHYSFS_ENUM_STOP as well. Don't call the callback again in any
3679      *  circumstances. Don't set an error code in this case.
3680      * Callbacks are only supposed to return a value from
3681      *  PHYSFS_EnumerateCallbackResult. Any other result has undefined
3682      *  behavior.
3683      * As long as the callback returned PHYSFS_ENUM_OK and you haven't
3684      *  experienced any errors of your own, keep enumerating until you're done
3685      *  and then return PHYSFS_ENUM_OK without setting an error code.
3686      *
3687      * \warning PHYSFS_enumerate returns zero or non-zero (success or failure),
3688      *          so be aware this function pointer returns different values!
3689      */
3690     PHYSFS_EnumerateCallbackResult (*enumerate)(void *opaque,
3691                      const char *dirname, PHYSFS_EnumerateCallback cb,
3692                      const char *origdir, void *callbackdata);
3693 
3694     /**
3695      * \brief Open a file in this archive for reading.
3696      *
3697      * This filename, (fnm), is in platform-independent notation.
3698      * Fail if the file does not exist.
3699      * Returns NULL on failure, and calls PHYSFS_setErrorCode().
3700      *  Returns non-NULL on success. The pointer returned will be
3701      *  passed as the "opaque" parameter for later file calls.
3702      */
3703     PHYSFS_Io *(*openRead)(void *opaque, const char *fnm);
3704 
3705     /**
3706      * \brief Open a file in this archive for writing.
3707      *
3708      * If the file does not exist, it should be created. If it exists,
3709      *  it should be truncated to zero bytes. The writing offset should
3710      *  be the start of the file.
3711      * If the archive is read-only, this operation should fail.
3712      * This filename is in platform-independent notation.
3713      * Returns NULL on failure, and calls PHYSFS_setErrorCode().
3714      *  Returns non-NULL on success. The pointer returned will be
3715      *  passed as the "opaque" parameter for later file calls.
3716      */
3717     PHYSFS_Io *(*openWrite)(void *opaque, const char *filename);
3718 
3719     /**
3720      * \brief Open a file in this archive for appending.
3721      *
3722      * If the file does not exist, it should be created. The writing
3723      *  offset should be the end of the file.
3724      * If the archive is read-only, this operation should fail.
3725      * This filename is in platform-independent notation.
3726      * Returns NULL on failure, and calls PHYSFS_setErrorCode().
3727      *  Returns non-NULL on success. The pointer returned will be
3728      *  passed as the "opaque" parameter for later file calls.
3729      */
3730     PHYSFS_Io *(*openAppend)(void *opaque, const char *filename);
3731 
3732     /**
3733      * \brief Delete a file or directory in the archive.
3734      *
3735      * This same call is used for both files and directories; there is not a
3736      *  separate rmdir() call. Directories are only meant to be removed if
3737      *  they are empty.
3738      * If the archive is read-only, this operation should fail.
3739      *
3740      * Return non-zero on success, zero on failure.
3741      * This filename is in platform-independent notation.
3742      * On failure, call PHYSFS_setErrorCode().
3743      */
3744     int (*remove)(void *opaque, const char *filename);
3745 
3746     /**
3747      * \brief Create a directory in the archive.
3748      *
3749      * If the application is trying to make multiple dirs, PhysicsFS
3750      *  will split them up into multiple calls before passing them to
3751      *  your driver.
3752      * If the archive is read-only, this operation should fail.
3753      * Return non-zero on success, zero on failure.
3754      *  This filename is in platform-independent notation.
3755      * On failure, call PHYSFS_setErrorCode().
3756      */
3757     int (*mkdir)(void *opaque, const char *filename);
3758 
3759     /**
3760      * \brief Obtain basic file metadata.
3761      *
3762      * On success, fill in all the fields in (stat), using
3763      *  reasonable defaults for fields that apply to your archive.
3764      *
3765      * Returns non-zero on success, zero on failure.
3766      * This filename is in platform-independent notation.
3767      * On failure, call PHYSFS_setErrorCode().
3768      */
3769     int (*stat)(void *opaque, const char *fn, PHYSFS_Stat *stat);
3770 
3771     /**
3772      * \brief Destruct a previously-opened archive.
3773      *
3774      * Close this archive, and free any associated memory,
3775      *  including the original PHYSFS_Io and (opaque) itself, if
3776      *  applicable. Implementation can assume that it won't be called if
3777      *  there are still files open from this archive.
3778      */
3779     void (*closeArchive)(void *opaque);
3780 } PHYSFS_Archiver;
3781 
3782 /**
3783  * \fn int PHYSFS_registerArchiver(const PHYSFS_Archiver *archiver)
3784  * \brief Add a new archiver to the system.
3785  *
3786  * \warning This is advanced, hardcore stuff. You don't need this unless you
3787  *          really know what you're doing. Most apps will not need this.
3788  *
3789  * If you want to provide your own archiver (for example, a custom archive
3790  *  file format, or some virtual thing you want to make look like a filesystem
3791  *  that you can access through the usual PhysicsFS APIs), this is where you
3792  *  start. Once an archiver is successfully registered, then you can use
3793  *  PHYSFS_mount() to add archives that your archiver supports to the
3794  *  search path, or perhaps use it as the write dir. Internally, PhysicsFS
3795  *  uses this function to register its own built-in archivers, like .zip
3796  *  support, etc.
3797  *
3798  * You may not have two archivers that handle the same extension. If you are
3799  *  going to have a clash, you can deregister the other archiver (including
3800  *  built-in ones) with PHYSFS_deregisterArchiver().
3801  *
3802  * The data in (archiver) is copied; you may free this pointer when this
3803  *  function returns.
3804  *
3805  * Once this function returns successfully, PhysicsFS will be able to support
3806  *  archives of this type until you deregister the archiver again.
3807  *
3808  *   \param archiver The archiver to register.
3809  *  \return Zero on error, non-zero on success.
3810  *
3811  * \sa PHYSFS_Archiver
3812  * \sa PHYSFS_deregisterArchiver
3813  */
3814 PHYSFS_DECL int PHYSFS_registerArchiver(const PHYSFS_Archiver *archiver);
3815 
3816 /**
3817  * \fn int PHYSFS_deregisterArchiver(const char *ext)
3818  * \brief Remove an archiver from the system.
3819  *
3820  * If for some reason, you only need your previously-registered archiver to
3821  *  live for a portion of your app's lifetime, you can remove it from the
3822  *  system once you're done with it through this function.
3823  *
3824  * This fails if there are any archives still open that use this archiver.
3825  *
3826  * This function can also remove internally-supplied archivers, like .zip
3827  *  support or whatnot. This could be useful in some situations, like
3828  *  disabling support for them outright or overriding them with your own
3829  *  implementation. Once an internal archiver is disabled like this,
3830  *  PhysicsFS provides no mechanism to recover them, short of calling
3831  *  PHYSFS_deinit() and PHYSFS_init() again.
3832  *
3833  * PHYSFS_deinit() will automatically deregister all archivers, so you don't
3834  *  need to explicitly deregister yours if you otherwise shut down cleanly.
3835  *
3836  *   \param ext Filename extension that the archiver handles.
3837  *  \return Zero on error, non-zero on success.
3838  *
3839  * \sa PHYSFS_Archiver
3840  * \sa PHYSFS_registerArchiver
3841  */
3842 PHYSFS_DECL int PHYSFS_deregisterArchiver(const char *ext);
3843 
3844 
3845 /* Everything above this line is part of the PhysicsFS 2.1 API. */
3846 
3847 #ifdef __cplusplus
3848 }
3849 #endif
3850 
3851 #endif  /* !defined _INCLUDE_PHYSFS_H_ */
3852 
3853 /* end of physfs.h ... */
3854 
3855