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