physfs_internal.h
author Ryan C. Gordon <icculus@icculus.org>
Mon, 01 Apr 2002 18:48:24 +0000
changeset 150 221f15a7cb08
parent 145 d6385584f6c4
child 156 f45e26b5f398
permissions -rw-r--r--
Patched to compile on MacOS Classic, with CodeWarrior 6.
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
 *
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     5
 * Please see the file LICENSE in the source's root directory.
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
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
    19
#ifdef __cplusplus
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
    20
extern "C" {
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
    21
#endif
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
    22
15
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
    23
struct __PHYSFS_DIRHANDLE__;
11
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
    24
struct __PHYSFS_FILEFUNCTIONS__;
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    25
20
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
    26
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
    27
typedef struct __PHYSFS_LINKEDSTRINGLIST__
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
    28
{
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
    29
    char *str;
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
    30
    struct __PHYSFS_LINKEDSTRINGLIST__ *next;
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
    31
} LinkedStringList;
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
    32
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
    33
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    34
typedef struct __PHYSFS_FILEHANDLE__
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    35
{
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    36
        /*
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    37
         * This is reserved for the driver to store information.
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    38
         */
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    39
    void *opaque;
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    40
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    41
        /*
11
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
    42
         * This should be the DirHandle that created this FileHandle.
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
    43
         */
15
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
    44
    const struct __PHYSFS_DIRHANDLE__ *dirHandle;
11
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
    45
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
    46
        /*
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
    47
         * Pointer to the file i/o functions for this filehandle.
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    48
         */
11
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
    49
    const struct __PHYSFS_FILEFUNCTIONS__ *funcs;
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
    50
} FileHandle;
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    51
11
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
    52
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
    53
typedef struct __PHYSFS_FILEFUNCTIONS__
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
    54
{
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    55
        /*
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    56
         * Read more from the file.
15
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
    57
         * Returns number of objects of (objSize) bytes read from file, -1
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
    58
         *  if complete failure.
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
    59
         * On failure, call __PHYSFS_setError().
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    60
         */
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
    61
    PHYSFS_sint64 (*read)(FileHandle *handle, void *buffer,
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
    62
                          PHYSFS_uint32 objSize, PHYSFS_uint32 objCount);
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    63
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    64
        /*
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    65
         * Write more to the file. Archives don't have to implement this.
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    66
         *  (Set it to NULL if not implemented).
15
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
    67
         * Returns number of objects of (objSize) bytes written to file, -1
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
    68
         *  if complete failure.
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
    69
         * On failure, call __PHYSFS_setError().
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    70
         */
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
    71
    PHYSFS_sint64 (*write)(FileHandle *handle, const void *buffer,
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
    72
                 PHYSFS_uint32 objSize, PHYSFS_uint32 objCount);
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    73
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    74
        /*
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    75
         * Returns non-zero if at end of file.
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    76
         */
11
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
    77
    int (*eof)(FileHandle *handle);
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    78
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    79
        /*
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    80
         * Returns byte offset from start of file.
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    81
         */
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
    82
    PHYSFS_sint64 (*tell)(FileHandle *handle);
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    83
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    84
        /*
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    85
         * Move read/write pointer to byte offset from start of file.
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    86
         *  Returns non-zero on success, zero on error.
15
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
    87
         * On failure, call __PHYSFS_setError().
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    88
         */
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
    89
    int (*seek)(FileHandle *handle, PHYSFS_uint64 offset);
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    90
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    91
        /*
28
529214f57d1b Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents: 23
diff changeset
    92
         * Return number of bytes available in the file, or -1 if you
529214f57d1b Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents: 23
diff changeset
    93
         *  aren't able to determine.
529214f57d1b Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents: 23
diff changeset
    94
         * On failure, call __PHYSFS_setError().
529214f57d1b Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents: 23
diff changeset
    95
         */
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
    96
    PHYSFS_sint64 (*fileLength)(FileHandle *handle);
28
529214f57d1b Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents: 23
diff changeset
    97
529214f57d1b Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents: 23
diff changeset
    98
        /*
11
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
    99
         * Close the file, and free the FileHandle structure (including "opaque").
15
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   100
         *  returns non-zero on success, zero if can't close file.
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   101
         * On failure, call __PHYSFS_setError().
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   102
         */
20
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   103
    int (*fileClose)(FileHandle *handle);
11
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   104
} FileFunctions;
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   105
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   106
15
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   107
typedef struct __PHYSFS_DIRHANDLE__
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   108
{
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   109
        /*
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   110
         * This is reserved for the driver to store information.
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   111
         */
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   112
    void *opaque;
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   113
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   114
        /*
15
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   115
         * Pointer to the directory i/o functions for this handle.
11
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   116
         */
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   117
    const struct __PHYSFS_DIRFUNCTIONS__ *funcs;
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   118
} DirHandle;
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   119
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   120
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   121
/*
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   122
 * Symlinks should always be followed; PhysicsFS will use
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   123
 *  DirFunctions->isSymLink() and make a judgement on whether to
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   124
 *  continue to call other methods based on that.
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   125
 */
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   126
typedef struct __PHYSFS_DIRFUNCTIONS__
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   127
{
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   128
        /*
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   129
         * Returns non-zero if (filename) is a valid archive that this
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   130
         *  driver can handle. This filename is in platform-dependent
15
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   131
         *  notation. forWriting is non-zero if this is to be used for
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   132
         *  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
   133
         *  element of the search path.
11
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   134
         */
15
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   135
    int (*isArchive)(const char *filename, int forWriting);
11
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   136
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   137
        /*
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   138
         * Return a DirHandle for dir/archive (name).
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   139
         *  This filename is in platform-dependent notation.
15
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   140
         *  forWriting is non-zero if this is to be used for
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   141
         *  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
   142
         *  element of the search path.
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   143
         * Returns NULL on failure, and calls __PHYSFS_setError().
11
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   144
         */
15
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   145
    DirHandle *(*openArchive)(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
        /*
12
a4041c91d715 Redesign of enumerateFiles code. More efficient and clean, less memory
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   148
         * Returns a list of all files in dirname. Each element of this list
a4041c91d715 Redesign of enumerateFiles code. More efficient and clean, less memory
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   149
         *  (and its "str" field) will be deallocated with the system's free()
a4041c91d715 Redesign of enumerateFiles code. More efficient and clean, less memory
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   150
         *  function by the caller, so be sure to explicitly malloc() each
41
ff60d39d0862 Architecture adjustment for enumerating files with regards to whether
Ryan C. Gordon <icculus@icculus.org>
parents: 39
diff changeset
   151
         *  chunk. Omit symlinks if (omitSymLinks) is non-zero.
12
a4041c91d715 Redesign of enumerateFiles code. More efficient and clean, less memory
Ryan C. Gordon <icculus@icculus.org>
parents: 11
diff changeset
   152
         * If you have a memory failure, return as much as you can.
11
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   153
         *  This dirname is in platform-independent notation.
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   154
         */
41
ff60d39d0862 Architecture adjustment for enumerating files with regards to whether
Ryan C. Gordon <icculus@icculus.org>
parents: 39
diff changeset
   155
    LinkedStringList *(*enumerateFiles)(DirHandle *r,
ff60d39d0862 Architecture adjustment for enumerating files with regards to whether
Ryan C. Gordon <icculus@icculus.org>
parents: 39
diff changeset
   156
                                        const char *dirname,
ff60d39d0862 Architecture adjustment for enumerating files with regards to whether
Ryan C. Gordon <icculus@icculus.org>
parents: 39
diff changeset
   157
                                        int omitSymLinks);
ff60d39d0862 Architecture adjustment for enumerating files with regards to whether
Ryan C. Gordon <icculus@icculus.org>
parents: 39
diff changeset
   158
15
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   159
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   160
        /*
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   161
         * Returns non-zero if filename can be opened for reading.
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   162
         *  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
   163
         */
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   164
    int (*exists)(DirHandle *r, const char *name);
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   165
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   166
        /*
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   167
         * Returns non-zero if filename is really a directory.
11
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   168
         *  This filename is in platform-independent notation.
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   169
         */
11
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   170
    int (*isDirectory)(DirHandle *r, const char *name);
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   171
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   172
        /*
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   173
         * Returns non-zero if filename is really a symlink.
11
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   174
         *  This filename is in platform-independent notation.
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   175
         */
11
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   176
    int (*isSymLink)(DirHandle *r, const char *name);
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   177
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   178
        /*
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   179
         * Open file for reading, and return a FileHandle.
11
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   180
         *  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
   181
         * 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
   182
         *  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
   183
         * 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
   184
         * Returns NULL on failure, and calls __PHYSFS_setError().
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   185
         */
11
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   186
    FileHandle *(*openRead)(DirHandle *r, const char *filename);
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   187
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   188
        /*
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   189
         * Open file for writing, and return a FileHandle.
20
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   190
         * 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
   191
         *  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
   192
         *  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
   193
         * This filename is in platform-independent notation.
11
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   194
         *  This method may be NULL.
15
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   195
         * 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
   196
         *  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
   197
         * Returns NULL on failure, and calls __PHYSFS_setError().
11
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   198
         */
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   199
    FileHandle *(*openWrite)(DirHandle *r, const char *filename);
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   200
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   201
        /*
11
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   202
         * Open file for appending, and return a FileHandle.
20
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   203
         * 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
   204
         *  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
   205
         * This filename is in platform-independent notation.
11
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   206
         *  This method may be NULL.
15
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   207
         * 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
   208
         *  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
   209
         * Returns NULL on failure, and calls __PHYSFS_setError().
11
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   210
         */
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   211
    FileHandle *(*openAppend)(DirHandle *r, const char *filename);
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   212
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   213
        /*
15
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   214
         * 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
   215
         *  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
   216
         *  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
   217
         *  This method may be NULL.
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   218
         * On failure, call __PHYSFS_setError().
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   219
         */
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   220
    int (*remove)(DirHandle *r, const char *filename);
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   221
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   222
        /*
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   223
         * 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
   224
         *  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
   225
         *  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
   226
         *  your driver.
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   227
         *  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
   228
         *  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
   229
         *  This method may be NULL.
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   230
         * On failure, call __PHYSFS_setError().
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   231
         */
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   232
    int (*mkdir)(DirHandle *r, const char *filename);
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   233
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   234
        /*
11
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   235
         * Close directories/archives, and free the handle, including
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   236
         *  the "opaque" entry. This should assume that it won't be called if
11
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   237
         *  there are still files open from this DirHandle.
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   238
         */
20
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   239
    void (*dirClose)(DirHandle *r);
11
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   240
} DirFunctions;
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
/* error messages... */
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   244
#define ERR_IS_INITIALIZED       "Already initialized"
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   245
#define ERR_NOT_INITIALIZED      "Not initialized"
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   246
#define ERR_INVALID_ARGUMENT     "Invalid argument"
15
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   247
#define ERR_FILES_STILL_OPEN     "Files still open"
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   248
#define ERR_NO_DIR_CREATE        "Failed to create directories"
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   249
#define ERR_OUT_OF_MEMORY        "Out of memory"
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   250
#define ERR_NOT_IN_SEARCH_PATH   "No such entry in search path"
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   251
#define ERR_NOT_SUPPORTED        "Operation not supported"
11
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   252
#define ERR_UNSUPPORTED_ARCHIVE  "Archive type unsupported"
15
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   253
#define ERR_NOT_A_HANDLE         "Not a file handle"
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   254
#define ERR_INSECURE_FNAME       "Insecure filename"
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   255
#define ERR_SYMLINK_DISALLOWED   "Symbolic links are disabled"
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   256
#define ERR_NO_WRITE_DIR         "Write directory is not set"
19
a0279b57398c Base implementation is now complete. Now to fill in archive/platform drivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 15
diff changeset
   257
#define ERR_NO_SUCH_FILE         "No such file"
21
b1ea58d70a56 Archive implementation (Build Groupfiles), other tweaks.
Ryan C. Gordon <icculus@icculus.org>
parents: 20
diff changeset
   258
#define ERR_PAST_EOF             "Past end of file"
22
49f6101707b4 More tweaks; GRP completely implemented. Everything builds clean.
Ryan C. Gordon <icculus@icculus.org>
parents: 21
diff changeset
   259
#define ERR_ARC_IS_READ_ONLY     "Archive is read-only"
30
c9cc9b79112e "I/O error" error string, and updated comment.
Ryan C. Gordon <icculus@icculus.org>
parents: 28
diff changeset
   260
#define ERR_IO_ERROR             "I/O error"
45
a489d28872ba New error message.
Ryan C. Gordon <icculus@icculus.org>
parents: 41
diff changeset
   261
#define ERR_CANT_SET_WRITE_DIR   "Can't set write directory"
a489d28872ba New error message.
Ryan C. Gordon <icculus@icculus.org>
parents: 41
diff changeset
   262
#define ERR_TOO_MANY_SYMLINKS    "Too many symbolic links"
49
5e6d33615d30 Added ERR_COMPRESSION
Ryan C. Gordon <icculus@icculus.org>
parents: 45
diff changeset
   263
#define ERR_COMPRESSION          "(De)compression error"
150
221f15a7cb08 Patched to compile on MacOS Classic, with CodeWarrior 6.
Ryan C. Gordon <icculus@icculus.org>
parents: 145
diff changeset
   264
#define ERR_NOT_IMPLEMENTED      "Not implemented"
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   265
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   266
/*
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   267
 * 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
   268
 *  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
   269
 *  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
   270
 *
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   271
 * 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
   272
 */
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   273
void __PHYSFS_setError(const char *err);
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   274
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   275
15
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   276
/*
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   277
 * Convert (dirName) to platform-dependent notation, then prepend (prepend)
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   278
 *  and append (append) to the converted string.
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   279
 *
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   280
 *  So, on Win32, calling:
20
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   281
 *     __PHYSFS_convertToDependent("C:\", "my/files", NULL);
15
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   282
 *  ...will return the string "C:\my\files".
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   283
 *
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   284
 * This is a convenience function; you might want to hack something out that
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   285
 *  is less generic (and therefore more efficient).
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   286
 *
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   287
 * Be sure to free() the return value when done with it.
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   288
 */
20
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   289
char *__PHYSFS_convertToDependent(const char *prepend,
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   290
                                  const char *dirName,
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   291
                                  const char *append);
15
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   292
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   293
/*
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   294
 * Verify that (fname) (in platform-independent notation), in relation
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   295
 *  to (h) is secure. That means that each element of fname is checked
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   296
 *  for symlinks (if they aren't permitted). Also, elements such as
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   297
 *  ".", "..", or ":" are flagged.
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   298
 *
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   299
 * Returns non-zero if string is safe, zero if there's a security issue.
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   300
 *  PHYSFS_getLastError() will specify what was wrong.
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   301
 */
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   302
int __PHYSFS_verifySecurity(DirHandle *h, const char *fname);
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   303
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   304
69
546a95cc5591 Updates, corrections and enhancements to get this ported to win32.
Ryan C. Gordon <icculus@icculus.org>
parents: 49
diff changeset
   305
/* These get used all over for lessening code clutter. */
546a95cc5591 Updates, corrections and enhancements to get this ported to win32.
Ryan C. Gordon <icculus@icculus.org>
parents: 49
diff changeset
   306
#define BAIL_MACRO(e, r) { __PHYSFS_setError(e); return r; }
15
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   307
#define BAIL_IF_MACRO(c, e, r) if (c) { __PHYSFS_setError(e); return r; }
145
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   308
#define BAIL_MACRO_MUTEX(e, m, r) { __PHYSFS_setError(e); __PHYSFS_platformReleaseMutex(m); return r; }
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   309
#define BAIL_IF_MACRO_MUTEX(c, e, m, r) if (c) { __PHYSFS_setError(e); __PHYSFS_platformReleaseMutex(m); return r; }
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   310
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   311
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   312
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   313
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   314
/*--------------------------------------------------------------------------*/
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   315
/*--------------------------------------------------------------------------*/
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   316
/*------------                                              ----------------*/
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   317
/*------------  You MUST implement the following functions  ----------------*/
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   318
/*------------        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
   319
/*------------     (see platform/unix.c for an example)     ----------------*/
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   320
/*------------                                              ----------------*/
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   321
/*--------------------------------------------------------------------------*/
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   322
/*--------------------------------------------------------------------------*/
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   323
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   324
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   325
/*
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   326
 * The dir separator; "/" on unix, "\\" on win32, ":" on MacOS, etc...
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   327
 *  Obviously, this isn't a function, but it IS a null-terminated string.
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   328
 */
15
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   329
extern const char *__PHYSFS_platformDirSeparator;
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   330
130
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   331
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   332
/*
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   333
 * Initialize the platform. This is called when PHYSFS_init() is called from
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   334
 *  the application. You can use this to (for example) determine what version
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   335
 *  of Windows you're running.
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   336
 *
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   337
 * 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
   338
 *  functioning at all), and non-zero otherwise.
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   339
 */
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   340
int __PHYSFS_platformInit(void);
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   341
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   342
/*
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   343
 * 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
   344
 *  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
   345
 *  allocated in your platform driver.
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   346
 *
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   347
 * 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
   348
 *  functioning at all), and non-zero otherwise.
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   349
 */
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   350
int __PHYSFS_platformDeinit(void);
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   351
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   352
/*
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   353
 * 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
   354
 *  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
   355
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   356
 * 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
   357
 *  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
   358
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   359
 * 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
   360
 *  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
   361
 *  conditions in the archivers.
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   362
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   363
 * 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
   364
 */
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   365
void *__PHYSFS_platformOpenRead(const char *filename);
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   366
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   367
/*
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   368
 * 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
   369
 *  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
   370
 *  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
   371
 *  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
   372
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   373
 * 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
   374
 *  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
   375
 *  etc.
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   376
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   377
 * 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
   378
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   379
 * 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
   380
 */
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   381
void *__PHYSFS_platformOpenWrite(const char *filename);
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   382
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   383
/*
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   384
 * 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
   385
 *  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
   386
 *  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
   387
 *  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
   388
 *  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
   389
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   390
 * 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
   391
 *  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
   392
 *  etc.
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   393
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   394
 * 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
   395
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   396
 * 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
   397
 */
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   398
void *__PHYSFS_platformOpenAppend(const char *filename);
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   399
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   400
/*
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   401
 * Read more data from a platform-specific file handle. (opaque) should be
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   402
 *  cast to whatever data type your platform uses. Read a maximum of (count)
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   403
 *  objects of (size) 8-bit bytes to the area pointed to by (buffer). If there
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   404
 *  isn't enough data available, return the number of full objects read, and
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   405
 *  position the file pointer at the start of the first incomplete object.
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   406
 *  On success, return (count) and position the file pointer one byte past
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   407
 *  the end of the last read object. Return (-1) if there is a catastrophic
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   408
 *  error, and call __PHYSFS_setError() to describe the problem; the file
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   409
 *  pointer should not move in such a case.
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   410
 */
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   411
PHYSFS_sint64 __PHYSFS_platformRead(void *opaque, void *buffer,
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   412
                                    PHYSFS_uint32 size, PHYSFS_uint32 count);
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   413
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   414
/*
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   415
 * Write more data to a platform-specific file handle. (opaque) should be
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   416
 *  cast to whatever data type your platform uses. Write a maximum of (count)
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   417
 *  objects of (size) 8-bit bytes from the area pointed to by (buffer). If
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   418
 *  there isn't enough data available, return the number of full objects
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   419
 *  written, and position the file pointer at the start of the first
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   420
 *  incomplete object. Return (-1) if there is a catastrophic error, and call
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   421
 *  __PHYSFS_setError() to describe the problem; the file pointer should not
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   422
 *  move in such a case.
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   423
 */
134
eb030f2e342a Fixed a const thing.
Ryan C. Gordon <icculus@icculus.org>
parents: 132
diff changeset
   424
PHYSFS_sint64 __PHYSFS_platformWrite(void *opaque, const void *buffer,
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   425
                                     PHYSFS_uint32 size, PHYSFS_uint32 count);
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   426
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   427
/*
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   428
 * 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
   429
 *  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
   430
 *  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
   431
 *  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
   432
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   433
 * 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
   434
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   435
 * 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
   436
 *  a non-zero value.
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   437
 */
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   438
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
   439
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   440
/*
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   441
 * 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
   442
 *  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
   443
 *  uses.
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   444
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   445
 * 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
   446
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   447
 * 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
   448
 *  a non-zero value.
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   449
 */
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   450
PHYSFS_sint64 __PHYSFS_platformTell(void *opaque);
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   451
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   452
/*
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   453
 * 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
   454
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   455
 * 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
   456
 *  file types on all platforms.
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   457
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   458
 * 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
   459
 *  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
   460
 */
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   461
PHYSFS_sint64 __PHYSFS_platformFileLength(void *handle);
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   462
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   463
/*
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   464
 * Determine if a file is at EOF. (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
   465
 *  type your platform uses.
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   466
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   467
 * The caller expects that there was a short read before calling this.
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   468
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   469
 * Return non-zero if EOF, zero if it is _not_ EOF.
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   470
 */
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   471
int __PHYSFS_platformEOF(void *opaque);
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   472
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   473
/*
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   474
 * 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
   475
 *  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
   476
 *  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
   477
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   478
 *  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
   479
 */
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   480
int __PHYSFS_platformFlush(void *opaque);
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
/*
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   483
 * Flush and close a file. (opaque) should be cast to whatever data type
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   484
 *  your platform uses. Be sure to check for errors when closing; the
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   485
 *  caller expects that this function can fail if there was a flushing
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   486
 *  error, etc.
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
 * You should clean up all resources associated with (opaque).
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   489
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   490
 *  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
   491
 */
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   492
int __PHYSFS_platformClose(void *opaque);
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   493
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   494
/*
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   495
 * Platform implementation of PHYSFS_getCdRomDirs()...
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   496
 *  See physfs.h. The retval should be freeable via PHYSFS_freeList().
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   497
 */
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   498
char **__PHYSFS_platformDetectAvailableCDs(void);
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   499
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   500
/*
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   501
 * 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
   502
 *  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
   503
 *  calculateBaseDir() in physfs.c ...)
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   504
 *  Caller will free() the retval if it's not NULL.
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   505
 */
23
bd6ba9c8717c Initial debugging: dropped PhysicsFS routines into the Build engine,
Ryan C. Gordon <icculus@icculus.org>
parents: 22
diff changeset
   506
char *__PHYSFS_platformCalcBaseDir(const char *argv0);
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   507
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   508
/*
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   509
 * Get the platform-specific user name.
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   510
 *  Caller will free() the retval if it's not NULL. If it's NULL, the username
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   511
 *  will default to "default".
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   512
 */
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   513
char *__PHYSFS_platformGetUserName(void);
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   514
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   515
/*
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   516
 * Get the platform-specific user dir.
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   517
 *  Caller will free() the retval if it's not NULL. If it's NULL, the userdir
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   518
 *  will default to basedir/username.
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   519
 */
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   520
char *__PHYSFS_platformGetUserDir(void);
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   521
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   522
/*
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   523
 * Return a number that uniquely identifies the current thread.
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   524
 *  On a platform without threading, (1) will suffice. These numbers are
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   525
 *  arbitrary; the only requirement is that no two threads have the same
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   526
 *  number.
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   527
 */
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   528
PHYSFS_uint64 __PHYSFS_platformGetThreadID(void);
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   529
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   530
/*
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   531
 * This is a pass-through to whatever stricmp() is called on your platform.
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   532
 */
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   533
int __PHYSFS_platformStricmp(const char *str1, const char *str2);
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   534
11
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   535
/*
20
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   536
 * Return non-zero if filename (in platform-dependent notation) exists.
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   537
 *  Symlinks should be followed; if what the symlink points to is missing,
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   538
 *  then the retval is false.
11
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   539
 */
20
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   540
int __PHYSFS_platformExists(const char *fname);
11
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   541
15
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   542
/*
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   543
 * Return non-zero if filename (in platform-dependent notation) is a symlink.
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   544
 */
20
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   545
int __PHYSFS_platformIsSymLink(const char *fname);
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   546
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   547
/*
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   548
 * Return non-zero if filename (in platform-dependent notation) is a symlink.
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   549
 *  Symlinks should be followed; if what the symlink points to is missing,
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   550
 *  or isn't a directory, then the retval is false.
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   551
 */
15
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   552
int __PHYSFS_platformIsDirectory(const char *fname);
418eacc97ac8 Tons of updates. Mostly implemented. Mostly compiling.
Ryan C. Gordon <icculus@icculus.org>
parents: 12
diff changeset
   553
20
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   554
/*
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   555
 * Convert (dirName) to platform-dependent notation, then prepend (prepend)
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   556
 *  and append (append) to the converted string.
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   557
 *
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   558
 *  So, on Win32, calling:
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   559
 *     __PHYSFS_platformCvtToDependent("C:\", "my/files", NULL);
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   560
 *  ...will return the string "C:\my\files".
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   561
 *
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   562
 * This can be implemented in a platform-specific manner, so you can get
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   563
 *  get a speed boost that the default implementation can't, since
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   564
 *  you can make assumptions about the size of strings, etc..
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   565
 *
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   566
 * Platforms that choose not to implement this may just call
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   567
 *  __PHYSFS_convertToDependent() as a passthrough, which may fit the bill
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   568
 *  already.
20
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   569
 *
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   570
 * Be sure to free() the return value when done with it.
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   571
 */
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   572
char *__PHYSFS_platformCvtToDependent(const char *prepend,
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   573
                                      const char *dirName,
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   574
                                      const char *append);
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   575
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   576
/*
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   577
 * Make the current thread give up a timeslice. This is called in a loop
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   578
 *  while waiting for various external forces to get back to us.
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   579
 */
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   580
void __PHYSFS_platformTimeslice(void);
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   581
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   582
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   583
/*
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   584
 * Enumerate a directory of files. This follows the rules for the
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   585
 *  DirFunctions->enumerateFiles() method (see above), except that the
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   586
 *  (dirName) that is passed to this function is converted to
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   587
 *  platform-DEPENDENT notation by the caller. The DirFunctions version
41
ff60d39d0862 Architecture adjustment for enumerating files with regards to whether
Ryan C. Gordon <icculus@icculus.org>
parents: 39
diff changeset
   588
 *  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
   589
 *  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
   590
 */
41
ff60d39d0862 Architecture adjustment for enumerating files with regards to whether
Ryan C. Gordon <icculus@icculus.org>
parents: 39
diff changeset
   591
LinkedStringList *__PHYSFS_platformEnumerateFiles(const char *dirname,
ff60d39d0862 Architecture adjustment for enumerating files with regards to whether
Ryan C. Gordon <icculus@icculus.org>
parents: 39
diff changeset
   592
                                                  int omitSymLinks);
20
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   593
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   594
28
529214f57d1b Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents: 23
diff changeset
   595
/*
39
bc29e1ee7ef6 Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents: 30
diff changeset
   596
 * Get the current working directory. The return value should be an
bc29e1ee7ef6 Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents: 30
diff changeset
   597
 *  absolute path in platform-dependent notation. The caller will deallocate
bc29e1ee7ef6 Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents: 30
diff changeset
   598
 *  the return value with the standard C runtime free() function when it
bc29e1ee7ef6 Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents: 30
diff changeset
   599
 *  is done with it.
bc29e1ee7ef6 Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents: 30
diff changeset
   600
 * On error, return NULL and set the error message.
bc29e1ee7ef6 Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents: 30
diff changeset
   601
 */
bc29e1ee7ef6 Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents: 30
diff changeset
   602
char *__PHYSFS_platformCurrentDir(void);
bc29e1ee7ef6 Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents: 30
diff changeset
   603
bc29e1ee7ef6 Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents: 30
diff changeset
   604
bc29e1ee7ef6 Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents: 30
diff changeset
   605
/*
bc29e1ee7ef6 Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents: 30
diff changeset
   606
 * Get the real physical path to a file. (path) is specified in
bc29e1ee7ef6 Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents: 30
diff changeset
   607
 *  platform-dependent notation, as should your return value be.
bc29e1ee7ef6 Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents: 30
diff changeset
   608
 *  All relative paths should be removed, leaving you with an absolute
bc29e1ee7ef6 Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents: 30
diff changeset
   609
 *  path. Symlinks should be resolved, too, so that the returned value is
bc29e1ee7ef6 Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents: 30
diff changeset
   610
 *  the most direct path to a file.
bc29e1ee7ef6 Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents: 30
diff changeset
   611
 * The return value will be deallocated with the standard C runtime free()
bc29e1ee7ef6 Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents: 30
diff changeset
   612
 *  function when the caller is done with it.
bc29e1ee7ef6 Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents: 30
diff changeset
   613
 * On error, return NULL and set the error message.
bc29e1ee7ef6 Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents: 30
diff changeset
   614
 */
bc29e1ee7ef6 Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents: 30
diff changeset
   615
char *__PHYSFS_platformRealPath(const char *path);
bc29e1ee7ef6 Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents: 30
diff changeset
   616
bc29e1ee7ef6 Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents: 30
diff changeset
   617
69
546a95cc5591 Updates, corrections and enhancements to get this ported to win32.
Ryan C. Gordon <icculus@icculus.org>
parents: 49
diff changeset
   618
/*
546a95cc5591 Updates, corrections and enhancements to get this ported to win32.
Ryan C. Gordon <icculus@icculus.org>
parents: 49
diff changeset
   619
 * 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
   620
 *  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
   621
 *  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
   622
 */
546a95cc5591 Updates, corrections and enhancements to get this ported to win32.
Ryan C. Gordon <icculus@icculus.org>
parents: 49
diff changeset
   623
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
   624
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
   625
/*
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
   626
 * 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
   627
 *  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
   628
 *  _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
   629
 *  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
   630
 *  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
   631
 *
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
   632
 * 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
   633
 *
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
   634
 * 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
   635
 */
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
   636
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
   637
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
   638
145
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   639
/*
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   640
 * 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
   641
 *  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
   642
 *
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   643
 * 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
   644
 *  return any arbitrary non-NULL value.
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   645
 */
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   646
void *__PHYSFS_platformCreateMutex(void);
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   647
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   648
/*
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   649
 * 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
   650
 *  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
   651
 *  __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
   652
 *  platforms.
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   653
 */
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   654
void __PHYSFS_platformDestroyMutex(void *mutex);
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   655
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   656
/*
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   657
 * 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
   658
 *  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
   659
 *  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
   660
 *  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
   661
 *
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   662
 * 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
   663
 *  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
   664
 *  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
   665
 *  is available otherwise.)
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   666
 */
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   667
int __PHYSFS_platformGrabMutex(void *mutex);
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   668
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   669
/*
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   670
 * 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
   671
 *  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
   672
 *  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
   673
 *  proceed.
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   674
 */
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   675
void __PHYSFS_platformReleaseMutex(void *mutex);
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   676
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   677
#ifdef __cplusplus
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   678
}
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   679
#endif
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   680
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   681
#endif
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   682
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   683
/* end of physfs_internal.h ... */
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   684