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