src/physfs_internal.h
author Martin Ahrnbom <m.ahrnbom@outlook.com>
Sun, 29 Mar 2015 07:03:30 +0200
changeset 1356 8de68968fcd0
parent 1337 3b2e649c044c
child 1370 75ac8ab59394
permissions -rw-r--r--
Added support for WinRT 8.1 Universal Apps. Hopefully this will work on Win10 as well... Only time will tell! Here's what's changed: 1. Added a platform_winrt.cpp file. It's based on platform_windows.c but has some WinRT-specific changes. 2. Changed physfs_platforms.h to define PHYSFS_PLATFORM_WINRT when running on WinRT. PHYSFS_PLATFORM_WINDOWS should also be defined, as WinRT behaves a lot like "normal" Windows and this flag is tested against in multiple parts of the PhysFS source code. 3. Changed platform_windows.c to not be used when PHYSFS_PLATFORM_WINRT is defined. 4. In order to work on Windows ARM devices, I had to change in physfs_internal.h, to include _M_ARM as a flag for running on ARM as "ARM" and "__arm__" aren't defined when running on a Windows ARM device. What I've tested: * Setting up a "sane folder configuration" * Reading and writing files * Mounting zip files * Using seek & tell * Checking file length All of these work fine. I couldn't get the actual test software to run on WinRT, but it seems like eveyrthing's working. I've tested these things on my Windows 8.1 computer, as well as my Lumia 920 which is currently running Windows 8.1.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     1
/*
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     2
 * Internal function/structure declaration. Do NOT include in your
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     3
 *  application.
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     4
 *
809
116b8fe30371 Renamed LICENSE to LICENSE.txt
Ryan C. Gordon <icculus@icculus.org>
parents: 775
diff changeset
     5
 * Please see the file LICENSE.txt in the source's root directory.
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     6
 *
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     7
 *  This file written by Ryan C. Gordon.
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     8
 */
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    10
#ifndef _INCLUDE_PHYSFS_INTERNAL_H_
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    11
#define _INCLUDE_PHYSFS_INTERNAL_H_
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    12
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    13
#ifndef __PHYSICSFS_INTERNAL__
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    14
#error Do not include this header from your applications.
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    15
#endif
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    16
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
    17
#include "physfs.h"
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
    18
1129
d81afe4b0a97 Cleaned up some #includes.
Ryan C. Gordon <icculus@icculus.org>
parents: 1128
diff changeset
    19
/* The holy trinity. */
d81afe4b0a97 Cleaned up some #includes.
Ryan C. Gordon <icculus@icculus.org>
parents: 1128
diff changeset
    20
#include <stdio.h>
d81afe4b0a97 Cleaned up some #includes.
Ryan C. Gordon <icculus@icculus.org>
parents: 1128
diff changeset
    21
#include <stdlib.h>
d81afe4b0a97 Cleaned up some #includes.
Ryan C. Gordon <icculus@icculus.org>
parents: 1128
diff changeset
    22
#include <string.h>
828
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
    23
1229
a6b73703c4f9 Use physfs_platforms.h in physfs_internal.h, to avoid repeated macro tests.
Ryan C. Gordon <icculus@icculus.org>
parents: 1228
diff changeset
    24
#include "physfs_platforms.h"
a6b73703c4f9 Use physfs_platforms.h in physfs_internal.h, to avoid repeated macro tests.
Ryan C. Gordon <icculus@icculus.org>
parents: 1228
diff changeset
    25
504
3420d82f9b01 Some cleanups for PocketPC port.
Ryan C. Gordon <icculus@icculus.org>
parents: 467
diff changeset
    26
#include <assert.h>
3420d82f9b01 Some cleanups for PocketPC port.
Ryan C. Gordon <icculus@icculus.org>
parents: 467
diff changeset
    27
836
6514fba91816 Patched to compile with latest Platform SDK.
Ryan C. Gordon <icculus@icculus.org>
parents: 828
diff changeset
    28
/* !!! FIXME: remove this when revamping stack allocation code... */
905
8006327f5797 Whoops, it's malloc.h, not alloca.h ...
Ryan C. Gordon <icculus@icculus.org>
parents: 903
diff changeset
    29
#if defined(_MSC_VER) || defined(__MINGW32__)
836
6514fba91816 Patched to compile with latest Platform SDK.
Ryan C. Gordon <icculus@icculus.org>
parents: 828
diff changeset
    30
#include <malloc.h>
6514fba91816 Patched to compile with latest Platform SDK.
Ryan C. Gordon <icculus@icculus.org>
parents: 828
diff changeset
    31
#endif
6514fba91816 Patched to compile with latest Platform SDK.
Ryan C. Gordon <icculus@icculus.org>
parents: 828
diff changeset
    32
1234
86e94cbbffca Use our platform test macro for Solaris.
Ryan C. Gordon <icculus@icculus.org>
parents: 1232
diff changeset
    33
#if PHYSFS_PLATFORM_SOLARIS
1089
5491e6c69162 Patched to compile on Solaris.
Ryan C. Gordon <icculus@icculus.org>
parents: 1054
diff changeset
    34
#include <alloca.h>
5491e6c69162 Patched to compile on Solaris.
Ryan C. Gordon <icculus@icculus.org>
parents: 1054
diff changeset
    35
#endif
5491e6c69162 Patched to compile on Solaris.
Ryan C. Gordon <icculus@icculus.org>
parents: 1054
diff changeset
    36
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
    37
#ifdef __cplusplus
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
    38
extern "C" {
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
    39
#endif
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
    40
936
3b4b6c107a59 Fixed aliasing bug in Windows platform layer (thanks, Dennis!).
Ryan C. Gordon <icculus@icculus.org>
parents: 933
diff changeset
    41
#ifdef __GNUC__
938
ecbae90ae88d Yet another attempt to patch to compile.
Ryan C. Gordon <icculus@icculus.org>
parents: 936
diff changeset
    42
#define PHYSFS_MINIMUM_GCC_VERSION(major, minor) \
936
3b4b6c107a59 Fixed aliasing bug in Windows platform layer (thanks, Dennis!).
Ryan C. Gordon <icculus@icculus.org>
parents: 933
diff changeset
    43
    ( ((__GNUC__ << 16) + __GNUC_MINOR__) >= (((major) << 16) + (minor)) )
3b4b6c107a59 Fixed aliasing bug in Windows platform layer (thanks, Dennis!).
Ryan C. Gordon <icculus@icculus.org>
parents: 933
diff changeset
    44
#else
938
ecbae90ae88d Yet another attempt to patch to compile.
Ryan C. Gordon <icculus@icculus.org>
parents: 936
diff changeset
    45
#define PHYSFS_MINIMUM_GCC_VERSION(major, minor) (0)
936
3b4b6c107a59 Fixed aliasing bug in Windows platform layer (thanks, Dennis!).
Ryan C. Gordon <icculus@icculus.org>
parents: 933
diff changeset
    46
#endif
3b4b6c107a59 Fixed aliasing bug in Windows platform layer (thanks, Dennis!).
Ryan C. Gordon <icculus@icculus.org>
parents: 933
diff changeset
    47
1100
f90724e3b4c6 Get rid of __inline__, just make sure "inline" is defined sanely instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1098
diff changeset
    48
#ifdef __cplusplus
f90724e3b4c6 Get rid of __inline__, just make sure "inline" is defined sanely instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1098
diff changeset
    49
    /* C++ always has a real inline keyword. */
f90724e3b4c6 Get rid of __inline__, just make sure "inline" is defined sanely instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1098
diff changeset
    50
#elif (defined macintosh) && !(defined __MWERKS__)
f90724e3b4c6 Get rid of __inline__, just make sure "inline" is defined sanely instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1098
diff changeset
    51
#   define inline
f90724e3b4c6 Get rid of __inline__, just make sure "inline" is defined sanely instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1098
diff changeset
    52
#elif (defined _MSC_VER)
f90724e3b4c6 Get rid of __inline__, just make sure "inline" is defined sanely instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1098
diff changeset
    53
#   define inline __inline
f90724e3b4c6 Get rid of __inline__, just make sure "inline" is defined sanely instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1098
diff changeset
    54
#endif
f90724e3b4c6 Get rid of __inline__, just make sure "inline" is defined sanely instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1098
diff changeset
    55
1229
a6b73703c4f9 Use physfs_platforms.h in physfs_internal.h, to avoid repeated macro tests.
Ryan C. Gordon <icculus@icculus.org>
parents: 1228
diff changeset
    56
#if PHYSFS_PLATFORM_LINUX && !defined(_FILE_OFFSET_BITS)
1228
7c0e9de2ba33 Removed llseek().
Ryan C. Gordon <icculus@icculus.org>
parents: 1227
diff changeset
    57
#define _FILE_OFFSET_BITS 64
7c0e9de2ba33 Removed llseek().
Ryan C. Gordon <icculus@icculus.org>
parents: 1227
diff changeset
    58
#endif
7c0e9de2ba33 Removed llseek().
Ryan C. Gordon <icculus@icculus.org>
parents: 1227
diff changeset
    59
852
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
    60
/*
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
    61
 * Interface for small allocations. If you need a little scratch space for
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
    62
 *  a throwaway buffer or string, use this. It will make small allocations
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
    63
 *  on the stack if possible, and use allocator.Malloc() if they are too
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
    64
 *  large. This helps reduce malloc pressure.
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
    65
 * There are some rules, though:
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
    66
 * NEVER return a pointer from this, as stack-allocated buffers go away
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
    67
 *  when your function returns.
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
    68
 * NEVER allocate in a loop, as stack-allocated pointers will pile up. Call
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
    69
 *  a function that uses smallAlloc from your loop, so the allocation can
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
    70
 *  free each time.
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
    71
 * NEVER call smallAlloc with any complex expression (it's a macro that WILL
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
    72
 *  have side effects...it references the argument multiple times). Use a
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
    73
 *  variable or a literal.
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
    74
 * NEVER free a pointer from this with anything but smallFree. It will not
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
    75
 *  be a valid pointer to the allocator, regardless of where the memory came
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
    76
 *  from.
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
    77
 * NEVER realloc a pointer from this.
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
    78
 * NEVER forget to use smallFree: it may not be a pointer from the stack.
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
    79
 * NEVER forget to check for NULL...allocation can fail here, of course!
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
    80
 */
1205
af22fe211dde Bump the smallAlloc threshold up to 256 bytes.
Ryan C. Gordon <icculus@icculus.org>
parents: 1203
diff changeset
    81
#define __PHYSFS_SMALLALLOCTHRESHOLD 256
852
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
    82
void *__PHYSFS_initSmallAlloc(void *ptr, PHYSFS_uint64 len);
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
    83
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
    84
#define __PHYSFS_smallAlloc(bytes) ( \
1215
0a8369723de7 Fixed stack smashing in newly-aligned __PHYSFS_smallAlloc().
Ryan C. Gordon <icculus@icculus.org>
parents: 1214
diff changeset
    85
    __PHYSFS_initSmallAlloc( \
0a8369723de7 Fixed stack smashing in newly-aligned __PHYSFS_smallAlloc().
Ryan C. Gordon <icculus@icculus.org>
parents: 1214
diff changeset
    86
        (((bytes) < __PHYSFS_SMALLALLOCTHRESHOLD) ? \
0a8369723de7 Fixed stack smashing in newly-aligned __PHYSFS_smallAlloc().
Ryan C. Gordon <icculus@icculus.org>
parents: 1214
diff changeset
    87
            alloca((size_t)((bytes)+sizeof(void*))) : NULL), (bytes)) \
852
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
    88
)
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
    89
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
    90
void __PHYSFS_smallFree(void *ptr);
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
    91
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
    92
691
71d9affe0d8a All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents: 676
diff changeset
    93
/* Use the allocation hooks. */
71d9affe0d8a All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents: 676
diff changeset
    94
#define malloc(x) Do not use malloc() directly.
71d9affe0d8a All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents: 676
diff changeset
    95
#define realloc(x, y) Do not use realloc() directly.
71d9affe0d8a All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents: 676
diff changeset
    96
#define free(x) Do not use free() directly.
836
6514fba91816 Patched to compile with latest Platform SDK.
Ryan C. Gordon <icculus@icculus.org>
parents: 828
diff changeset
    97
/* !!! FIXME: add alloca check here. */
427
c38ace41039f Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents: 422
diff changeset
    98
1258
074d08049aa7 Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents: 1255
diff changeset
    99
#ifndef PHYSFS_SUPPORTS_ZIP
074d08049aa7 Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents: 1255
diff changeset
   100
#define PHYSFS_SUPPORTS_ZIP 1
074d08049aa7 Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents: 1255
diff changeset
   101
#endif
074d08049aa7 Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents: 1255
diff changeset
   102
#ifndef PHYSFS_SUPPORTS_7Z
074d08049aa7 Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents: 1255
diff changeset
   103
#define PHYSFS_SUPPORTS_7Z 0
074d08049aa7 Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents: 1255
diff changeset
   104
#endif
074d08049aa7 Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents: 1255
diff changeset
   105
#ifndef PHYSFS_SUPPORTS_GRP
074d08049aa7 Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents: 1255
diff changeset
   106
#define PHYSFS_SUPPORTS_GRP 0
074d08049aa7 Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents: 1255
diff changeset
   107
#endif
074d08049aa7 Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents: 1255
diff changeset
   108
#ifndef PHYSFS_SUPPORTS_HOG
074d08049aa7 Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents: 1255
diff changeset
   109
#define PHYSFS_SUPPORTS_HOG 0
074d08049aa7 Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents: 1255
diff changeset
   110
#endif
074d08049aa7 Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents: 1255
diff changeset
   111
#ifndef PHYSFS_SUPPORTS_MVL
074d08049aa7 Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents: 1255
diff changeset
   112
#define PHYSFS_SUPPORTS_MVL 0
074d08049aa7 Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents: 1255
diff changeset
   113
#endif
074d08049aa7 Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents: 1255
diff changeset
   114
#ifndef PHYSFS_SUPPORTS_WAD
074d08049aa7 Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents: 1255
diff changeset
   115
#define PHYSFS_SUPPORTS_WAD 0
074d08049aa7 Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents: 1255
diff changeset
   116
#endif
1315
c686e4f84ab5 SLB archiver
Aleksi Nurmi <aleksi.nurmi@gmail.com>
parents: 1283
diff changeset
   117
#ifndef PHYSFS_SUPPORTS_SLB
c686e4f84ab5 SLB archiver
Aleksi Nurmi <aleksi.nurmi@gmail.com>
parents: 1283
diff changeset
   118
#define PHYSFS_SUPPORTS_SLB 0
c686e4f84ab5 SLB archiver
Aleksi Nurmi <aleksi.nurmi@gmail.com>
parents: 1283
diff changeset
   119
#endif
1258
074d08049aa7 Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents: 1255
diff changeset
   120
#ifndef PHYSFS_SUPPORTS_ISO9660
074d08049aa7 Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents: 1255
diff changeset
   121
#define PHYSFS_SUPPORTS_ISO9660 0
074d08049aa7 Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents: 1255
diff changeset
   122
#endif
074d08049aa7 Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents: 1255
diff changeset
   123
1280
bd174b99fa5b Add binary compatibility to PHYSFS_Io.
Ryan C. Gordon <icculus@icculus.org>
parents: 1276
diff changeset
   124
/* The latest supported PHYSFS_Io::version value. */
bd174b99fa5b Add binary compatibility to PHYSFS_Io.
Ryan C. Gordon <icculus@icculus.org>
parents: 1276
diff changeset
   125
#define CURRENT_PHYSFS_IO_API_VERSION 0
20
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   126
1322
5476917b8ddf Allow application-supplied archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 1315
diff changeset
   127
/* The latest supported PHYSFS_Archiver::version value. */
5476917b8ddf Allow application-supplied archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 1315
diff changeset
   128
#define CURRENT_PHYSFS_ARCHIVER_API_VERSION 0
11
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   129
629
b01a59827192 Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents: 627
diff changeset
   130
/* This byteorder stuff was lifted from SDL. http://www.libsdl.org/ */
b01a59827192 Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents: 627
diff changeset
   131
#define PHYSFS_LIL_ENDIAN  1234
b01a59827192 Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents: 627
diff changeset
   132
#define PHYSFS_BIG_ENDIAN  4321
b01a59827192 Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents: 627
diff changeset
   133
1185
43aea6bc12d7 Check _M_X64 (Visual Studio, Windows/x86-64) in littleendian test.
Ryan C. Gordon <icculus@icculus.org>
parents: 1180
diff changeset
   134
#if  defined(__i386__) || defined(__ia64__) || \
1188
17bcf6924240 Patched to compile.
Ryan C. Gordon <icculus@icculus.org>
parents: 1185
diff changeset
   135
     defined(_M_IX86) || defined(_M_IA64) || defined(_M_X64) || \
629
b01a59827192 Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents: 627
diff changeset
   136
    (defined(__alpha__) || defined(__alpha)) || \
1356
8de68968fcd0 Added support for WinRT 8.1 Universal Apps.
Martin Ahrnbom <m.ahrnbom@outlook.com>
parents: 1337
diff changeset
   137
     defined(__arm__) || defined(ARM) || defined(_M_ARM) || \
629
b01a59827192 Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents: 627
diff changeset
   138
    (defined(__mips__) && defined(__MIPSEL__)) || \
b01a59827192 Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents: 627
diff changeset
   139
     defined(__SYMBIAN32__) || \
b01a59827192 Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents: 627
diff changeset
   140
     defined(__x86_64__) || \
b01a59827192 Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents: 627
diff changeset
   141
     defined(__LITTLE_ENDIAN__)
b01a59827192 Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents: 627
diff changeset
   142
#define PHYSFS_BYTEORDER    PHYSFS_LIL_ENDIAN
b01a59827192 Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents: 627
diff changeset
   143
#else
b01a59827192 Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents: 627
diff changeset
   144
#define PHYSFS_BYTEORDER    PHYSFS_BIG_ENDIAN
b01a59827192 Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents: 627
diff changeset
   145
#endif
b01a59827192 Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents: 627
diff changeset
   146
b01a59827192 Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents: 627
diff changeset
   147
464
21c8e0d1578c Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents: 444
diff changeset
   148
/*
21c8e0d1578c Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents: 444
diff changeset
   149
 * When sorting the entries in an archive, we use a modified QuickSort.
21c8e0d1578c Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents: 444
diff changeset
   150
 *  When there are less then PHYSFS_QUICKSORT_THRESHOLD entries left to sort,
21c8e0d1578c Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents: 444
diff changeset
   151
 *  we switch over to a BubbleSort for the remainder. Tweak to taste.
21c8e0d1578c Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents: 444
diff changeset
   152
 *
21c8e0d1578c Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents: 444
diff changeset
   153
 * You can override this setting by defining PHYSFS_QUICKSORT_THRESHOLD
21c8e0d1578c Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents: 444
diff changeset
   154
 *  before #including "physfs_internal.h".
21c8e0d1578c Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents: 444
diff changeset
   155
 */
21c8e0d1578c Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents: 444
diff changeset
   156
#ifndef PHYSFS_QUICKSORT_THRESHOLD
21c8e0d1578c Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents: 444
diff changeset
   157
#define PHYSFS_QUICKSORT_THRESHOLD 4
21c8e0d1578c Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents: 444
diff changeset
   158
#endif
21c8e0d1578c Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents: 444
diff changeset
   159
21c8e0d1578c Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents: 444
diff changeset
   160
/*
21c8e0d1578c Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents: 444
diff changeset
   161
 * Sort an array (or whatever) of (max) elements. This uses a mixture of
21c8e0d1578c Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents: 444
diff changeset
   162
 *  a QuickSort and BubbleSort internally.
21c8e0d1578c Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents: 444
diff changeset
   163
 * (cmpfn) is used to determine ordering, and (swapfn) does the actual
21c8e0d1578c Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents: 444
diff changeset
   164
 *  swapping of elements in the list.
21c8e0d1578c Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents: 444
diff changeset
   165
 *
21c8e0d1578c Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents: 444
diff changeset
   166
 *  See zip.c for an example.
21c8e0d1578c Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents: 444
diff changeset
   167
 */
1283
8bcc48d243df Added Zip64 support to the .zip archiver.
Ryan C. Gordon <icculus@icculus.org>
parents: 1281
diff changeset
   168
void __PHYSFS_sort(void *entries, size_t max,
8bcc48d243df Added Zip64 support to the .zip archiver.
Ryan C. Gordon <icculus@icculus.org>
parents: 1281
diff changeset
   169
                   int (*cmpfn)(void *, size_t, size_t),
8bcc48d243df Added Zip64 support to the .zip archiver.
Ryan C. Gordon <icculus@icculus.org>
parents: 1281
diff changeset
   170
                   void (*swapfn)(void *, size_t, size_t));
464
21c8e0d1578c Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents: 444
diff changeset
   171
1240
22d4d1bd4e21 Reworked the error reporting API. Now we use error codes instead of strings.
Ryan C. Gordon <icculus@icculus.org>
parents: 1234
diff changeset
   172
/*
22d4d1bd4e21 Reworked the error reporting API. Now we use error codes instead of strings.
Ryan C. Gordon <icculus@icculus.org>
parents: 1234
diff changeset
   173
 * This isn't a formal error code, it's just for BAIL_MACRO.
22d4d1bd4e21 Reworked the error reporting API. Now we use error codes instead of strings.
Ryan C. Gordon <icculus@icculus.org>
parents: 1234
diff changeset
   174
 *  It means: there was an error, but someone else already set it for us.
22d4d1bd4e21 Reworked the error reporting API. Now we use error codes instead of strings.
Ryan C. Gordon <icculus@icculus.org>
parents: 1234
diff changeset
   175
 */
22d4d1bd4e21 Reworked the error reporting API. Now we use error codes instead of strings.
Ryan C. Gordon <icculus@icculus.org>
parents: 1234
diff changeset
   176
#define ERRPASS PHYSFS_ERR_OK
363
79f155a51527 Added __PHYSFS_addToLinkedStringList().
Ryan C. Gordon <icculus@icculus.org>
parents: 344
diff changeset
   177
69
546a95cc5591 Updates, corrections and enhancements to get this ported to win32.
Ryan C. Gordon <icculus@icculus.org>
parents: 49
diff changeset
   178
/* These get used all over for lessening code clutter. */
1328
a5314f07614a Remove __PHYSFS_setError(), use the new public API instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1327
diff changeset
   179
#define BAIL_MACRO(e, r) do { if (e) PHYSFS_setErrorCode(e); return r; } while (0)
a5314f07614a Remove __PHYSFS_setError(), use the new public API instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1327
diff changeset
   180
#define BAIL_IF_MACRO(c, e, r) do { if (c) { if (e) PHYSFS_setErrorCode(e); return r; } } while (0)
a5314f07614a Remove __PHYSFS_setError(), use the new public API instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1327
diff changeset
   181
#define BAIL_MACRO_MUTEX(e, m, r) do { if (e) PHYSFS_setErrorCode(e); __PHYSFS_platformReleaseMutex(m); return r; } while (0)
a5314f07614a Remove __PHYSFS_setError(), use the new public API instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1327
diff changeset
   182
#define BAIL_IF_MACRO_MUTEX(c, e, m, r) do { if (c) { if (e) PHYSFS_setErrorCode(e); __PHYSFS_platformReleaseMutex(m); return r; } } while (0)
a5314f07614a Remove __PHYSFS_setError(), use the new public API instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1327
diff changeset
   183
#define GOTO_MACRO(e, g) do { if (e) PHYSFS_setErrorCode(e); goto g; } while (0)
a5314f07614a Remove __PHYSFS_setError(), use the new public API instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1327
diff changeset
   184
#define GOTO_IF_MACRO(c, e, g) do { if (c) { if (e) PHYSFS_setErrorCode(e); goto g; } } while (0)
a5314f07614a Remove __PHYSFS_setError(), use the new public API instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1327
diff changeset
   185
#define GOTO_MACRO_MUTEX(e, m, g) do { if (e) PHYSFS_setErrorCode(e); __PHYSFS_platformReleaseMutex(m); goto g; } while (0)
a5314f07614a Remove __PHYSFS_setError(), use the new public API instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1327
diff changeset
   186
#define GOTO_IF_MACRO_MUTEX(c, e, m, g) do { if (c) { if (e) PHYSFS_setErrorCode(e); __PHYSFS_platformReleaseMutex(m); goto g; } } while (0)
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   187
828
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   188
#define __PHYSFS_ARRAYLEN(x) ( (sizeof (x)) / (sizeof (x[0])) )
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   189
1098
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1097
diff changeset
   190
#ifdef PHYSFS_NO_64BIT_SUPPORT
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1097
diff changeset
   191
#define __PHYSFS_SI64(x) ((PHYSFS_sint64) (x))
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1097
diff changeset
   192
#define __PHYSFS_UI64(x) ((PHYSFS_uint64) (x))
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1097
diff changeset
   193
#elif (defined __GNUC__)
850
2bc230284fed Replaced LONGLONGLITERAL with __PHYSFS_UI64/__PHYSFS_SI64.
Ryan C. Gordon <icculus@icculus.org>
parents: 845
diff changeset
   194
#define __PHYSFS_SI64(x) x##LL
2bc230284fed Replaced LONGLONGLITERAL with __PHYSFS_UI64/__PHYSFS_SI64.
Ryan C. Gordon <icculus@icculus.org>
parents: 845
diff changeset
   195
#define __PHYSFS_UI64(x) x##ULL
851
dcfbb779ff40 Apparently this is how you do 64-bit literals in MSVC...untested.
Ryan C. Gordon <icculus@icculus.org>
parents: 850
diff changeset
   196
#elif (defined _MSC_VER)
dcfbb779ff40 Apparently this is how you do 64-bit literals in MSVC...untested.
Ryan C. Gordon <icculus@icculus.org>
parents: 850
diff changeset
   197
#define __PHYSFS_SI64(x) x##i64
dcfbb779ff40 Apparently this is how you do 64-bit literals in MSVC...untested.
Ryan C. Gordon <icculus@icculus.org>
parents: 850
diff changeset
   198
#define __PHYSFS_UI64(x) x##ui64
763
efadd9cdb6a4 Cleaned up overflow checks in platform memory allocators (thanks to Nicolas
Ryan C. Gordon <icculus@icculus.org>
parents: 754
diff changeset
   199
#else
1098
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1097
diff changeset
   200
#define __PHYSFS_SI64(x) ((PHYSFS_sint64) (x))
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1097
diff changeset
   201
#define __PHYSFS_UI64(x) ((PHYSFS_uint64) (x))
763
efadd9cdb6a4 Cleaned up overflow checks in platform memory allocators (thanks to Nicolas
Ryan C. Gordon <icculus@icculus.org>
parents: 754
diff changeset
   202
#endif
efadd9cdb6a4 Cleaned up overflow checks in platform memory allocators (thanks to Nicolas
Ryan C. Gordon <icculus@icculus.org>
parents: 754
diff changeset
   203
936
3b4b6c107a59 Fixed aliasing bug in Windows platform layer (thanks, Dennis!).
Ryan C. Gordon <icculus@icculus.org>
parents: 933
diff changeset
   204
763
efadd9cdb6a4 Cleaned up overflow checks in platform memory allocators (thanks to Nicolas
Ryan C. Gordon <icculus@icculus.org>
parents: 754
diff changeset
   205
/*
efadd9cdb6a4 Cleaned up overflow checks in platform memory allocators (thanks to Nicolas
Ryan C. Gordon <icculus@icculus.org>
parents: 754
diff changeset
   206
 * Check if a ui64 will fit in the platform's address space.
efadd9cdb6a4 Cleaned up overflow checks in platform memory allocators (thanks to Nicolas
Ryan C. Gordon <icculus@icculus.org>
parents: 754
diff changeset
   207
 *  The initial sizeof check will optimize this macro out entirely on
efadd9cdb6a4 Cleaned up overflow checks in platform memory allocators (thanks to Nicolas
Ryan C. Gordon <icculus@icculus.org>
parents: 754
diff changeset
   208
 *  64-bit (and larger?!) platforms, and the other condition will
efadd9cdb6a4 Cleaned up overflow checks in platform memory allocators (thanks to Nicolas
Ryan C. Gordon <icculus@icculus.org>
parents: 754
diff changeset
   209
 *  return zero or non-zero if the variable will fit in the platform's
efadd9cdb6a4 Cleaned up overflow checks in platform memory allocators (thanks to Nicolas
Ryan C. Gordon <icculus@icculus.org>
parents: 754
diff changeset
   210
 *  size_t, suitable to pass to malloc. This is kinda messy, but effective.
efadd9cdb6a4 Cleaned up overflow checks in platform memory allocators (thanks to Nicolas
Ryan C. Gordon <icculus@icculus.org>
parents: 754
diff changeset
   211
 */
efadd9cdb6a4 Cleaned up overflow checks in platform memory allocators (thanks to Nicolas
Ryan C. Gordon <icculus@icculus.org>
parents: 754
diff changeset
   212
#define __PHYSFS_ui64FitsAddressSpace(s) ( \
1112
12e187aa051c Made __PHYSFS_ui64FitsAddressSpace's behaviour match its name.
Ryan C. Gordon <icculus@icculus.org>
parents: 1111
diff changeset
   213
    (sizeof (PHYSFS_uint64) <= sizeof (size_t)) || \
12e187aa051c Made __PHYSFS_ui64FitsAddressSpace's behaviour match its name.
Ryan C. Gordon <icculus@icculus.org>
parents: 1111
diff changeset
   214
    ((s) < (__PHYSFS_UI64(0xFFFFFFFFFFFFFFFF) >> (64-(sizeof(size_t)*8)))) \
763
efadd9cdb6a4 Cleaned up overflow checks in platform memory allocators (thanks to Nicolas
Ryan C. Gordon <icculus@icculus.org>
parents: 754
diff changeset
   215
)
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   216
936
3b4b6c107a59 Fixed aliasing bug in Windows platform layer (thanks, Dennis!).
Ryan C. Gordon <icculus@icculus.org>
parents: 933
diff changeset
   217
644
1cb5533d369c Initial structure for replacable allocator work.
Ryan C. Gordon <icculus@icculus.org>
parents: 641
diff changeset
   218
/*
828
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   219
 * This is a strcasecmp() or stricmp() replacement that expects both strings
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   220
 *  to be in UTF-8 encoding. It will do "case folding" to decide if the
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   221
 *  Unicode codepoints in the strings match.
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   222
 *
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   223
 * It will report which string is "greater than" the other, but be aware that
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   224
 *  this doesn't necessarily mean anything: 'a' may be "less than" 'b', but
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   225
 *  a random Kanji codepoint has no meaningful alphabetically relationship to
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   226
 *  a Greek Lambda, but being able to assign a reliable "value" makes sorting
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   227
 *  algorithms possible, if not entirely sane. Most cases should treat the
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   228
 *  return value as "equal" or "not equal".
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   229
 */
1255
f15ec4962d08 Renamed __PHYSFS_utf8strcasecmp() to __PHYSFS_utf8stricmp().
Ryan C. Gordon <icculus@icculus.org>
parents: 1249
diff changeset
   230
int __PHYSFS_utf8stricmp(const char *s1, const char *s2);
828
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   231
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   232
/*
1255
f15ec4962d08 Renamed __PHYSFS_utf8strcasecmp() to __PHYSFS_utf8stricmp().
Ryan C. Gordon <icculus@icculus.org>
parents: 1249
diff changeset
   233
 * This works like __PHYSFS_utf8stricmp(), but takes a character (NOT BYTE
828
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   234
 *  COUNT) argument, like strcasencmp().
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   235
 */
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   236
int __PHYSFS_utf8strnicmp(const char *s1, const char *s2, PHYSFS_uint32 l);
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   237
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   238
/*
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   239
 * stricmp() that guarantees to only work with low ASCII. The C runtime
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   240
 *  stricmp() might try to apply a locale/codepage/etc, which we don't want.
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   241
 */
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   242
int __PHYSFS_stricmpASCII(const char *s1, const char *s2);
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   243
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   244
/*
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   245
 * strnicmp() that guarantees to only work with low ASCII. The C runtime
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   246
 *  strnicmp() might try to apply a locale/codepage/etc, which we don't want.
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   247
 */
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   248
int __PHYSFS_strnicmpASCII(const char *s1, const char *s2, PHYSFS_uint32 l);
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   249
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   250
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   251
/*
691
71d9affe0d8a All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents: 676
diff changeset
   252
 * The current allocator. Not valid before PHYSFS_init is called!
644
1cb5533d369c Initial structure for replacable allocator work.
Ryan C. Gordon <icculus@icculus.org>
parents: 641
diff changeset
   253
 */
691
71d9affe0d8a All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents: 676
diff changeset
   254
extern PHYSFS_Allocator __PHYSFS_AllocatorHooks;
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   255
691
71d9affe0d8a All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents: 676
diff changeset
   256
/* convenience macro to make this less cumbersome internally... */
71d9affe0d8a All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents: 676
diff changeset
   257
#define allocator __PHYSFS_AllocatorHooks
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   258
1118
2e09fc635fdd Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1115
diff changeset
   259
/*
2e09fc635fdd Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1115
diff changeset
   260
 * Create a PHYSFS_Io for a file in the physical filesystem.
2e09fc635fdd Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1115
diff changeset
   261
 *  This path is in platform-dependent notation. (mode) must be 'r', 'w', or
2e09fc635fdd Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1115
diff changeset
   262
 *  'a' for Read, Write, or Append.
2e09fc635fdd Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1115
diff changeset
   263
 */
2e09fc635fdd Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1115
diff changeset
   264
PHYSFS_Io *__PHYSFS_createNativeIo(const char *path, const int mode);
2e09fc635fdd Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1115
diff changeset
   265
1120
67e5e23425a0 Added PHYSFS_mountMemory().
Ryan C. Gordon <icculus@icculus.org>
parents: 1118
diff changeset
   266
/*
67e5e23425a0 Added PHYSFS_mountMemory().
Ryan C. Gordon <icculus@icculus.org>
parents: 1118
diff changeset
   267
 * Create a PHYSFS_Io for a buffer of memory (READ-ONLY). If you already
67e5e23425a0 Added PHYSFS_mountMemory().
Ryan C. Gordon <icculus@icculus.org>
parents: 1118
diff changeset
   268
 *  have one of these, just use its duplicate() method, and it'll increment
67e5e23425a0 Added PHYSFS_mountMemory().
Ryan C. Gordon <icculus@icculus.org>
parents: 1118
diff changeset
   269
 *  its refcount without allocating a copy of the buffer.
67e5e23425a0 Added PHYSFS_mountMemory().
Ryan C. Gordon <icculus@icculus.org>
parents: 1118
diff changeset
   270
 */
67e5e23425a0 Added PHYSFS_mountMemory().
Ryan C. Gordon <icculus@icculus.org>
parents: 1118
diff changeset
   271
PHYSFS_Io *__PHYSFS_createMemoryIo(const void *buf, PHYSFS_uint64 len,
67e5e23425a0 Added PHYSFS_mountMemory().
Ryan C. Gordon <icculus@icculus.org>
parents: 1118
diff changeset
   272
                                   void (*destruct)(void *));
67e5e23425a0 Added PHYSFS_mountMemory().
Ryan C. Gordon <icculus@icculus.org>
parents: 1118
diff changeset
   273
1118
2e09fc635fdd Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1115
diff changeset
   274
1203
55f147714ce2 Cleaned up all the readAll() cut and paste.
Ryan C. Gordon <icculus@icculus.org>
parents: 1197
diff changeset
   275
/*
55f147714ce2 Cleaned up all the readAll() cut and paste.
Ryan C. Gordon <icculus@icculus.org>
parents: 1197
diff changeset
   276
 * Read (len) bytes from (io) into (buf). Returns non-zero on success,
55f147714ce2 Cleaned up all the readAll() cut and paste.
Ryan C. Gordon <icculus@icculus.org>
parents: 1197
diff changeset
   277
 *  zero on i/o error. Literally: "return (io->read(io, buf, len) == len);"
55f147714ce2 Cleaned up all the readAll() cut and paste.
Ryan C. Gordon <icculus@icculus.org>
parents: 1197
diff changeset
   278
 */
55f147714ce2 Cleaned up all the readAll() cut and paste.
Ryan C. Gordon <icculus@icculus.org>
parents: 1197
diff changeset
   279
int __PHYSFS_readAll(PHYSFS_Io *io, void *buf, const PHYSFS_uint64 len);
1128
067d8e76261e Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents: 1127
diff changeset
   280
067d8e76261e Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents: 1127
diff changeset
   281
067d8e76261e Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents: 1127
diff changeset
   282
/* These are shared between some archivers. */
067d8e76261e Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents: 1127
diff changeset
   283
067d8e76261e Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents: 1127
diff changeset
   284
typedef struct
067d8e76261e Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents: 1127
diff changeset
   285
{
1315
c686e4f84ab5 SLB archiver
Aleksi Nurmi <aleksi.nurmi@gmail.com>
parents: 1283
diff changeset
   286
    char name[64];
1128
067d8e76261e Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents: 1127
diff changeset
   287
    PHYSFS_uint32 startPos;
067d8e76261e Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents: 1127
diff changeset
   288
    PHYSFS_uint32 size;
067d8e76261e Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents: 1127
diff changeset
   289
} UNPKentry;
067d8e76261e Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents: 1127
diff changeset
   290
1322
5476917b8ddf Allow application-supplied archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 1315
diff changeset
   291
void UNPK_closeArchive(void *opaque);
5476917b8ddf Allow application-supplied archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 1315
diff changeset
   292
void *UNPK_openArchive(PHYSFS_Io *io,UNPKentry *e,const PHYSFS_uint32 n);
5476917b8ddf Allow application-supplied archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 1315
diff changeset
   293
void UNPK_enumerateFiles(void *opaque, const char *dname,
1324
d12c1c033a7d Centralize responsibility for filtering symlinks during enumeration.
Ryan C. Gordon <icculus@icculus.org>
parents: 1322
diff changeset
   294
                         PHYSFS_EnumFilesCallback cb,
1128
067d8e76261e Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents: 1127
diff changeset
   295
                         const char *origdir, void *callbackdata);
1329
919f885155d8 Cleaned out "exists" nonsense in openRead() API.
Ryan C. Gordon <icculus@icculus.org>
parents: 1328
diff changeset
   296
PHYSFS_Io *UNPK_openRead(void *opaque, const char *name);
1322
5476917b8ddf Allow application-supplied archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 1315
diff changeset
   297
PHYSFS_Io *UNPK_openWrite(void *opaque, const char *name);
5476917b8ddf Allow application-supplied archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 1315
diff changeset
   298
PHYSFS_Io *UNPK_openAppend(void *opaque, const char *name);
5476917b8ddf Allow application-supplied archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 1315
diff changeset
   299
int UNPK_remove(void *opaque, const char *name);
5476917b8ddf Allow application-supplied archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 1315
diff changeset
   300
int UNPK_mkdir(void *opaque, const char *name);
1327
998351d485d9 Cleaned out the "exists" nonsense in the stat() API.
Ryan C. Gordon <icculus@icculus.org>
parents: 1325
diff changeset
   301
int UNPK_stat(void *opaque, const char *fn, PHYSFS_Stat *st);
1128
067d8e76261e Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents: 1127
diff changeset
   302
067d8e76261e Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents: 1127
diff changeset
   303
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   304
/*--------------------------------------------------------------------------*/
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   305
/*--------------------------------------------------------------------------*/
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   306
/*------------                                              ----------------*/
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   307
/*------------  You MUST implement the following functions  ----------------*/
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   308
/*------------        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
   309
/*------------     (see platform/unix.c for an example)     ----------------*/
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
/*
1225
671d4ea47c13 Make __PHYSFS_platformDirSeparator into a single char.
Ryan C. Gordon <icculus@icculus.org>
parents: 1224
diff changeset
   316
 * The dir separator; '/' on unix, '\\' on win32, ":" on MacOS, etc...
671d4ea47c13 Make __PHYSFS_platformDirSeparator into a single char.
Ryan C. Gordon <icculus@icculus.org>
parents: 1224
diff changeset
   317
 *  Obviously, this isn't a function. If you need more than one char for this,
671d4ea47c13 Make __PHYSFS_platformDirSeparator into a single char.
Ryan C. Gordon <icculus@icculus.org>
parents: 1224
diff changeset
   318
 *  you'll need to pull some old pieces of PhysicsFS out of revision control.
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   319
 */
1229
a6b73703c4f9 Use physfs_platforms.h in physfs_internal.h, to avoid repeated macro tests.
Ryan C. Gordon <icculus@icculus.org>
parents: 1228
diff changeset
   320
#if PHYSFS_PLATFORM_WINDOWS
1225
671d4ea47c13 Make __PHYSFS_platformDirSeparator into a single char.
Ryan C. Gordon <icculus@icculus.org>
parents: 1224
diff changeset
   321
#define __PHYSFS_platformDirSeparator '\\'
671d4ea47c13 Make __PHYSFS_platformDirSeparator into a single char.
Ryan C. Gordon <icculus@icculus.org>
parents: 1224
diff changeset
   322
#else
671d4ea47c13 Make __PHYSFS_platformDirSeparator into a single char.
Ryan C. Gordon <icculus@icculus.org>
parents: 1224
diff changeset
   323
#define __PHYSFS_platformDirSeparator '/'
671d4ea47c13 Make __PHYSFS_platformDirSeparator into a single char.
Ryan C. Gordon <icculus@icculus.org>
parents: 1224
diff changeset
   324
#endif
130
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   325
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   326
/*
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   327
 * Initialize the platform. This is called when PHYSFS_init() is called from
1227
b5c017759a1f Fixed a comment. Cut and paste error, I guess?
Ryan C. Gordon <icculus@icculus.org>
parents: 1226
diff changeset
   328
 *  the application.
130
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   329
 *
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   330
 * 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
   331
 *  functioning at all), and non-zero otherwise.
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
int __PHYSFS_platformInit(void);
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   334
240
052041af9001 Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents: 172
diff changeset
   335
130
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
 * 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
   338
 *  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
   339
 *  allocated in your platform driver.
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   340
 *
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   341
 * 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
   342
 *  functioning at all), and non-zero otherwise.
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   343
 */
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   344
int __PHYSFS_platformDeinit(void);
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   345
240
052041af9001 Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents: 172
diff changeset
   346
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   347
/*
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   348
 * 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
   349
 *  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
   350
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   351
 * 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
   352
 *  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
   353
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   354
 * 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
   355
 *  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
   356
 *  conditions in the archivers.
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   357
 *
1328
a5314f07614a Remove __PHYSFS_setError(), use the new public API instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1327
diff changeset
   358
 * Call PHYSFS_setErrorCode() and return (NULL) if the file can't be opened.
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   359
 */
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   360
void *__PHYSFS_platformOpenRead(const char *filename);
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   361
240
052041af9001 Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents: 172
diff changeset
   362
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   363
/*
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   364
 * 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
   365
 *  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
   366
 *  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
   367
 *  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
   368
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   369
 * 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
   370
 *  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
   371
 *  etc.
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
 * 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
   374
 *
1328
a5314f07614a Remove __PHYSFS_setError(), use the new public API instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1327
diff changeset
   375
 * Call PHYSFS_setErrorCode() and return (NULL) if the file can't be opened.
132
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
void *__PHYSFS_platformOpenWrite(const char *filename);
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   378
240
052041af9001 Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents: 172
diff changeset
   379
132
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
 * 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
   382
 *  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
   383
 *  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
   384
 *  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
   385
 *  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
   386
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   387
 * 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
   388
 *  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
   389
 *  etc.
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   390
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   391
 * 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
   392
 *
1328
a5314f07614a Remove __PHYSFS_setError(), use the new public API instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1327
diff changeset
   393
 * Call PHYSFS_setErrorCode() and return (NULL) if the file can't be opened.
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   394
 */
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   395
void *__PHYSFS_platformOpenAppend(const char *filename);
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   396
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
 * Read more data from a platform-specific file handle. (opaque) should be
1098
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1097
diff changeset
   399
 *  cast to whatever data type your platform uses. Read a maximum of (len)
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1097
diff changeset
   400
 *  8-bit bytes to the area pointed to by (buf). If there isn't enough data
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1097
diff changeset
   401
 *  available, return the number of bytes read, and position the file pointer
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1097
diff changeset
   402
 *  immediately after those bytes.
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1097
diff changeset
   403
 *  On success, return (len) and position the file pointer immediately past
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1097
diff changeset
   404
 *  the end of the last read byte. Return (-1) if there is a catastrophic
1328
a5314f07614a Remove __PHYSFS_setError(), use the new public API instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1327
diff changeset
   405
 *  error, and call PHYSFS_setErrorCode() to describe the problem; the file
1098
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1097
diff changeset
   406
 *  pointer should not move in such a case. A partial read is success; only
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1097
diff changeset
   407
 *  return (-1) on total failure; presumably, the next read call after a
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1097
diff changeset
   408
 *  partial read will fail as such.
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   409
 */
1098
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1097
diff changeset
   410
PHYSFS_sint64 __PHYSFS_platformRead(void *opaque, void *buf, PHYSFS_uint64 len);
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   411
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   412
/*
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   413
 * Write more data to a platform-specific file handle. (opaque) should be
1098
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1097
diff changeset
   414
 *  cast to whatever data type your platform uses. Write a maximum of (len)
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1097
diff changeset
   415
 *  8-bit bytes from the area pointed to by (buffer). If there is a problem,
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1097
diff changeset
   416
 *  return the number of bytes written, and position the file pointer
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1097
diff changeset
   417
 *  immediately after those bytes. Return (-1) if there is a catastrophic
1328
a5314f07614a Remove __PHYSFS_setError(), use the new public API instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1327
diff changeset
   418
 *  error, and call PHYSFS_setErrorCode() to describe the problem; the file
1098
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1097
diff changeset
   419
 *  pointer should not move in such a case. A partial write is success; only
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1097
diff changeset
   420
 *  return (-1) on total failure; presumably, the next write call after a
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1097
diff changeset
   421
 *  partial write will fail as such.
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   422
 */
134
eb030f2e342a Fixed a const thing.
Ryan C. Gordon <icculus@icculus.org>
parents: 132
diff changeset
   423
PHYSFS_sint64 __PHYSFS_platformWrite(void *opaque, const void *buffer,
1098
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1097
diff changeset
   424
                                     PHYSFS_uint64 len);
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   425
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
 * 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
   428
 *  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
   429
 *  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
   430
 *  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
   431
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   432
 * 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
   433
 *
1328
a5314f07614a Remove __PHYSFS_setError(), use the new public API instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1327
diff changeset
   434
 * On error, call PHYSFS_setErrorCode() and return zero. On success, return
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   435
 *  a non-zero value.
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   436
 */
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   437
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
   438
240
052041af9001 Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents: 172
diff changeset
   439
132
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
 *
1328
a5314f07614a Remove __PHYSFS_setError(), use the new public API instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1327
diff changeset
   447
 * On error, call PHYSFS_setErrorCode() and return -1. On success, return >= 0.
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   448
 */
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   449
PHYSFS_sint64 __PHYSFS_platformTell(void *opaque);
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   450
240
052041af9001 Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents: 172
diff changeset
   451
132
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
 *
1328
a5314f07614a Remove __PHYSFS_setError(), use the new public API instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1327
diff changeset
   458
 * Return -1 if you can't do it, and call PHYSFS_setErrorCode(). Otherwise,
132
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
1054
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   463
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   464
/*
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   465
 * !!! FIXME: comment me.
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   466
 */
1327
998351d485d9 Cleaned out the "exists" nonsense in the stat() API.
Ryan C. Gordon <icculus@icculus.org>
parents: 1325
diff changeset
   467
int __PHYSFS_platformStat(const char *fn, PHYSFS_Stat *stat);
1054
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   468
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   469
/*
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   470
 * 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
   471
 *  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
   472
 *  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
   473
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   474
 *  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
   475
 */
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   476
int __PHYSFS_platformFlush(void *opaque);
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
/*
1118
2e09fc635fdd Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1115
diff changeset
   479
 * Close file and deallocate resources. (opaque) should be cast to whatever
2e09fc635fdd Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1115
diff changeset
   480
 *  data type your platform uses. This should close the file in any scenario:
2e09fc635fdd Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1115
diff changeset
   481
 *  flushing is a separate function call, and this function should never fail.
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   482
 *
1118
2e09fc635fdd Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1115
diff changeset
   483
 * You should clean up all resources associated with (opaque); the pointer
2e09fc635fdd Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1115
diff changeset
   484
 *  will be considered invalid after this call.
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   485
 */
1118
2e09fc635fdd Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1115
diff changeset
   486
void __PHYSFS_platformClose(void *opaque);
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   487
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   488
/*
657
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   489
 * Platform implementation of PHYSFS_getCdRomDirsCallback()...
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   490
 *  CD directories are discovered and reported to the callback one at a time.
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   491
 *  Pointers passed to the callback are assumed to be invalid to the
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   492
 *  application after the callback returns, so you can free them or whatever.
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   493
 *  Callback does not assume results will be sorted in any meaningful way.
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   494
 */
657
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   495
void __PHYSFS_platformDetectAvailableCDs(PHYSFS_StringCallback cb, void *data);
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   496
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
 * 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
   499
 *  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
   500
 *  calculateBaseDir() in physfs.c ...)
1264
03715ba4603d Make sure base dir always has a dirsep at the end of it.
Ryan C. Gordon <icculus@icculus.org>
parents: 1261
diff changeset
   501
 * Your string must end with a dir separator if you don't return NULL.
1214
374be12cf9c8 More doc tweaks.
Ryan C. Gordon <icculus@icculus.org>
parents: 1213
diff changeset
   502
 *  Caller will allocator.Free() the retval if it's not NULL.
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   503
 */
23
bd6ba9c8717c Initial debugging: dropped PhysicsFS routines into the Build engine,
Ryan C. Gordon <icculus@icculus.org>
parents: 22
diff changeset
   504
char *__PHYSFS_platformCalcBaseDir(const char *argv0);
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   505
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   506
/*
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   507
 * Get the platform-specific user dir.
1266
135cb99a06a0 More FIXME cleanup.
Ryan C. Gordon <icculus@icculus.org>
parents: 1264
diff changeset
   508
 * As of PhysicsFS 2.1, returning NULL means fatal error.
135cb99a06a0 More FIXME cleanup.
Ryan C. Gordon <icculus@icculus.org>
parents: 1264
diff changeset
   509
 * Your string must end with a dir separator if you don't return NULL.
135cb99a06a0 More FIXME cleanup.
Ryan C. Gordon <icculus@icculus.org>
parents: 1264
diff changeset
   510
 *  Caller will allocator.Free() the retval if it's not NULL.
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   511
 */
1248
632895970ed6 Cleaned up some FIXMEs.
Ryan C. Gordon <icculus@icculus.org>
parents: 1246
diff changeset
   512
char *__PHYSFS_platformCalcUserDir(void);
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   513
1242
1e6db80d2393 Added PHYSFS_getPrefDir().
Ryan C. Gordon <icculus@icculus.org>
parents: 1240
diff changeset
   514
1e6db80d2393 Added PHYSFS_getPrefDir().
Ryan C. Gordon <icculus@icculus.org>
parents: 1240
diff changeset
   515
/* This is the cached version from PHYSFS_init(). This is a fast call. */
1e6db80d2393 Added PHYSFS_getPrefDir().
Ryan C. Gordon <icculus@icculus.org>
parents: 1240
diff changeset
   516
const char *__PHYSFS_getUserDir(void);  /* not deprecated internal version. */
1e6db80d2393 Added PHYSFS_getPrefDir().
Ryan C. Gordon <icculus@icculus.org>
parents: 1240
diff changeset
   517
1266
135cb99a06a0 More FIXME cleanup.
Ryan C. Gordon <icculus@icculus.org>
parents: 1264
diff changeset
   518
1242
1e6db80d2393 Added PHYSFS_getPrefDir().
Ryan C. Gordon <icculus@icculus.org>
parents: 1240
diff changeset
   519
/*
1266
135cb99a06a0 More FIXME cleanup.
Ryan C. Gordon <icculus@icculus.org>
parents: 1264
diff changeset
   520
 * Get the platform-specific pref dir.
135cb99a06a0 More FIXME cleanup.
Ryan C. Gordon <icculus@icculus.org>
parents: 1264
diff changeset
   521
 * Returning NULL means fatal error.
135cb99a06a0 More FIXME cleanup.
Ryan C. Gordon <icculus@icculus.org>
parents: 1264
diff changeset
   522
 * Your string must end with a dir separator if you don't return NULL.
135cb99a06a0 More FIXME cleanup.
Ryan C. Gordon <icculus@icculus.org>
parents: 1264
diff changeset
   523
 *  Caller will allocator.Free() the retval if it's not NULL.
135cb99a06a0 More FIXME cleanup.
Ryan C. Gordon <icculus@icculus.org>
parents: 1264
diff changeset
   524
 *  Caller will make missing directories if necessary; this just reports
135cb99a06a0 More FIXME cleanup.
Ryan C. Gordon <icculus@icculus.org>
parents: 1264
diff changeset
   525
 *   the final path.
1242
1e6db80d2393 Added PHYSFS_getPrefDir().
Ryan C. Gordon <icculus@icculus.org>
parents: 1240
diff changeset
   526
 */
1e6db80d2393 Added PHYSFS_getPrefDir().
Ryan C. Gordon <icculus@icculus.org>
parents: 1240
diff changeset
   527
char *__PHYSFS_platformCalcPrefDir(const char *org, const char *app);
1e6db80d2393 Added PHYSFS_getPrefDir().
Ryan C. Gordon <icculus@icculus.org>
parents: 1240
diff changeset
   528
1e6db80d2393 Added PHYSFS_getPrefDir().
Ryan C. Gordon <icculus@icculus.org>
parents: 1240
diff changeset
   529
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   530
/*
1012
f254870dd7dd Attempt to clean up the thread ID mess in platform_unix ...
Ryan C. Gordon <icculus@icculus.org>
parents: 984
diff changeset
   531
 * Return a pointer that uniquely identifies the current thread.
f254870dd7dd Attempt to clean up the thread ID mess in platform_unix ...
Ryan C. Gordon <icculus@icculus.org>
parents: 984
diff changeset
   532
 *  On a platform without threading, (0x1) will suffice. These numbers are
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   533
 *  arbitrary; the only requirement is that no two threads have the same
1012
f254870dd7dd Attempt to clean up the thread ID mess in platform_unix ...
Ryan C. Gordon <icculus@icculus.org>
parents: 984
diff changeset
   534
 *  pointer.
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   535
 */
1012
f254870dd7dd Attempt to clean up the thread ID mess in platform_unix ...
Ryan C. Gordon <icculus@icculus.org>
parents: 984
diff changeset
   536
void *__PHYSFS_platformGetThreadID(void);
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   537
240
052041af9001 Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents: 172
diff changeset
   538
20
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   539
/*
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   540
 * Enumerate a directory of files. This follows the rules for the
1325
4fa1518513c4 Comment tweaks (FIXME additions, typo corrections, etc).
Ryan C. Gordon <icculus@icculus.org>
parents: 1324
diff changeset
   541
 *  PHYSFS_Archiver::enumerateFiles() method (see above), except that the
20
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   542
 *  (dirName) that is passed to this function is converted to
650
298b8bb26775 Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents: 648
diff changeset
   543
 *  platform-DEPENDENT notation by the caller. The PHYSFS_Archiver version
41
ff60d39d0862 Architecture adjustment for enumerating files with regards to whether
Ryan C. Gordon <icculus@icculus.org>
parents: 39
diff changeset
   544
 *  uses platform-independent notation. Note that ".", "..", and other
1325
4fa1518513c4 Comment tweaks (FIXME additions, typo corrections, etc).
Ryan C. Gordon <icculus@icculus.org>
parents: 1324
diff changeset
   545
 *  meta-entries 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
   546
 */
657
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   547
void __PHYSFS_platformEnumerateFiles(const char *dirname,
754
e7cd7411eadf API BREAKAGE: Changed PHYSFS_enumerateFilesCallback() to pass the originally
Ryan C. Gordon <icculus@icculus.org>
parents: 747
diff changeset
   548
                                     PHYSFS_EnumFilesCallback callback,
e7cd7411eadf API BREAKAGE: Changed PHYSFS_enumerateFilesCallback() to pass the originally
Ryan C. Gordon <icculus@icculus.org>
parents: 747
diff changeset
   549
                                     const char *origdir,
657
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   550
                                     void *callbackdata);
20
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   551
39
bc29e1ee7ef6 Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents: 30
diff changeset
   552
/*
69
546a95cc5591 Updates, corrections and enhancements to get this ported to win32.
Ryan C. Gordon <icculus@icculus.org>
parents: 49
diff changeset
   553
 * 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
   554
 *  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
   555
 *  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
   556
 */
546a95cc5591 Updates, corrections and enhancements to get this ported to win32.
Ryan C. Gordon <icculus@icculus.org>
parents: 49
diff changeset
   557
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
   558
240
052041af9001 Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents: 172
diff changeset
   559
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
   560
/*
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
   561
 * 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
   562
 *  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
   563
 *  _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
   564
 *  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
   565
 *  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
   566
 *
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
   567
 * 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
   568
 *
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
   569
 * 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
   570
 */
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
   571
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
   572
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
   573
145
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   574
/*
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   575
 * 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
   576
 *  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
   577
 *
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   578
 * 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
   579
 *  return any arbitrary non-NULL value.
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   580
 */
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   581
void *__PHYSFS_platformCreateMutex(void);
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   582
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   583
/*
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   584
 * 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
   585
 *  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
   586
 *  __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
   587
 *  platforms.
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   588
 */
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   589
void __PHYSFS_platformDestroyMutex(void *mutex);
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   590
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   591
/*
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   592
 * 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
   593
 *  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
   594
 *  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
   595
 *  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
   596
 *
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   597
 * 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
   598
 *  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
   599
 *  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
   600
 *  is available otherwise.)
156
f45e26b5f398 Added warning about potential infinite recursion between setError and grabMutex.
Ryan C. Gordon <icculus@icculus.org>
parents: 150
diff changeset
   601
 *
1328
a5314f07614a Remove __PHYSFS_setError(), use the new public API instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1327
diff changeset
   602
 * _DO NOT_ call PHYSFS_setErrorCode() in here! Since setErrorCode calls this
156
f45e26b5f398 Added warning about potential infinite recursion between setError and grabMutex.
Ryan C. Gordon <icculus@icculus.org>
parents: 150
diff changeset
   603
 *  function, you'll cause an infinite recursion. This means you can't
f45e26b5f398 Added warning about potential infinite recursion between setError and grabMutex.
Ryan C. Gordon <icculus@icculus.org>
parents: 150
diff changeset
   604
 *  use the BAIL_*MACRO* macros, either.
145
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   605
 */
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   606
int __PHYSFS_platformGrabMutex(void *mutex);
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   607
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   608
/*
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   609
 * 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
   610
 *  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
   611
 *  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
   612
 *  proceed.
156
f45e26b5f398 Added warning about potential infinite recursion between setError and grabMutex.
Ryan C. Gordon <icculus@icculus.org>
parents: 150
diff changeset
   613
 *
1328
a5314f07614a Remove __PHYSFS_setError(), use the new public API instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1327
diff changeset
   614
 * _DO NOT_ call PHYSFS_setErrorCode() in here! Since setErrorCode calls this
156
f45e26b5f398 Added warning about potential infinite recursion between setError and grabMutex.
Ryan C. Gordon <icculus@icculus.org>
parents: 150
diff changeset
   615
 *  function, you'll cause an infinite recursion. This means you can't
f45e26b5f398 Added warning about potential infinite recursion between setError and grabMutex.
Ryan C. Gordon <icculus@icculus.org>
parents: 150
diff changeset
   616
 *  use the BAIL_*MACRO* macros, either.
145
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   617
 */
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   618
void __PHYSFS_platformReleaseMutex(void *mutex);
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   619
644
1cb5533d369c Initial structure for replacable allocator work.
Ryan C. Gordon <icculus@icculus.org>
parents: 641
diff changeset
   620
/*
845
3f150ffcf50c Since all the platform layers were using the same cut-and-paste of the
Ryan C. Gordon <icculus@icculus.org>
parents: 844
diff changeset
   621
 * Called at the start of PHYSFS_init() to prepare the allocator, if the user
648
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 644
diff changeset
   622
 *  hasn't selected their own allocator via PHYSFS_setAllocator().
845
3f150ffcf50c Since all the platform layers were using the same cut-and-paste of the
Ryan C. Gordon <icculus@icculus.org>
parents: 844
diff changeset
   623
 *  If the platform has a custom allocator, it should fill in the fields of
3f150ffcf50c Since all the platform layers were using the same cut-and-paste of the
Ryan C. Gordon <icculus@icculus.org>
parents: 844
diff changeset
   624
 *  (a) with the proper function pointers and return non-zero.
3f150ffcf50c Since all the platform layers were using the same cut-and-paste of the
Ryan C. Gordon <icculus@icculus.org>
parents: 844
diff changeset
   625
 * If the platform just wants to use malloc()/free()/etc, return zero
3f150ffcf50c Since all the platform layers were using the same cut-and-paste of the
Ryan C. Gordon <icculus@icculus.org>
parents: 844
diff changeset
   626
 *  immediately and the higher level will handle it. The Init and Deinit
3f150ffcf50c Since all the platform layers were using the same cut-and-paste of the
Ryan C. Gordon <icculus@icculus.org>
parents: 844
diff changeset
   627
 *  fields of (a) are optional...set them to NULL if you don't need them.
3f150ffcf50c Since all the platform layers were using the same cut-and-paste of the
Ryan C. Gordon <icculus@icculus.org>
parents: 844
diff changeset
   628
 *  Everything else must be implemented. All rules follow those for
3f150ffcf50c Since all the platform layers were using the same cut-and-paste of the
Ryan C. Gordon <icculus@icculus.org>
parents: 844
diff changeset
   629
 *  PHYSFS_setAllocator(). If Init isn't NULL, it will be called shortly
3f150ffcf50c Since all the platform layers were using the same cut-and-paste of the
Ryan C. Gordon <icculus@icculus.org>
parents: 844
diff changeset
   630
 *  after this function returns non-zero.
648
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 644
diff changeset
   631
 */
845
3f150ffcf50c Since all the platform layers were using the same cut-and-paste of the
Ryan C. Gordon <icculus@icculus.org>
parents: 844
diff changeset
   632
int __PHYSFS_platformSetDefaultAllocator(PHYSFS_Allocator *a);
644
1cb5533d369c Initial structure for replacable allocator work.
Ryan C. Gordon <icculus@icculus.org>
parents: 641
diff changeset
   633
1337
3b2e649c044c Better basedir detection for various Unix platforms.
Ryan C. Gordon <icculus@icculus.org>
parents: 1329
diff changeset
   634
/*
3b2e649c044c Better basedir detection for various Unix platforms.
Ryan C. Gordon <icculus@icculus.org>
parents: 1329
diff changeset
   635
 * Like strdup(), but uses the current PhysicsFS allocator.
3b2e649c044c Better basedir detection for various Unix platforms.
Ryan C. Gordon <icculus@icculus.org>
parents: 1329
diff changeset
   636
 */
3b2e649c044c Better basedir detection for various Unix platforms.
Ryan C. Gordon <icculus@icculus.org>
parents: 1329
diff changeset
   637
char *__PHYSFS_strdup(const char *str);
3b2e649c044c Better basedir detection for various Unix platforms.
Ryan C. Gordon <icculus@icculus.org>
parents: 1329
diff changeset
   638
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   639
#ifdef __cplusplus
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   640
}
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   641
#endif
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   642
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   643
#endif
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   644
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   645
/* end of physfs_internal.h ... */
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   646