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