src/physfs_internal.h
author Ryan C. Gordon <icculus@icculus.org>
Sun, 17 May 2020 01:41:52 -0400
changeset 1691 c66c9326b05d
parent 1653 ff8f4c2a60d8
permissions -rw-r--r--
7z: Make error handling a little more robust.
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
1440
874043e29d55 Simplify CMakeLists.txt, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 1428
diff changeset
    17
/* Turn off MSVC warnings that are aggressively anti-portability. */
1590
5aa450209e6a windows: Disable _CRT_SECURE_NO_WARNINGS again.
Ryan C. Gordon <icculus@icculus.org>
parents: 1583
diff changeset
    18
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
1440
874043e29d55 Simplify CMakeLists.txt, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 1428
diff changeset
    19
#define _CRT_SECURE_NO_WARNINGS 1
874043e29d55 Simplify CMakeLists.txt, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 1428
diff changeset
    20
#endif
874043e29d55 Simplify CMakeLists.txt, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 1428
diff changeset
    21
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
    22
#include "physfs.h"
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
    23
1129
d81afe4b0a97 Cleaned up some #includes.
Ryan C. Gordon <icculus@icculus.org>
parents: 1128
diff changeset
    24
/* The holy trinity. */
d81afe4b0a97 Cleaned up some #includes.
Ryan C. Gordon <icculus@icculus.org>
parents: 1128
diff changeset
    25
#include <stdio.h>
d81afe4b0a97 Cleaned up some #includes.
Ryan C. Gordon <icculus@icculus.org>
parents: 1128
diff changeset
    26
#include <stdlib.h>
d81afe4b0a97 Cleaned up some #includes.
Ryan C. Gordon <icculus@icculus.org>
parents: 1128
diff changeset
    27
#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
    28
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
    29
#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
    30
504
3420d82f9b01 Some cleanups for PocketPC port.
Ryan C. Gordon <icculus@icculus.org>
parents: 467
diff changeset
    31
#include <assert.h>
3420d82f9b01 Some cleanups for PocketPC port.
Ryan C. Gordon <icculus@icculus.org>
parents: 467
diff changeset
    32
1542
1027fe6accf1 windows: Patched to compile! (...?)
Ryan C. Gordon <icculus@icculus.org>
parents: 1541
diff changeset
    33
#define __PHYSFS_COMPILE_TIME_ASSERT(name, x) \
1027fe6accf1 windows: Patched to compile! (...?)
Ryan C. Gordon <icculus@icculus.org>
parents: 1541
diff changeset
    34
       typedef int __PHYSFS_compile_time_assert_##name[(x) * 2 - 1]
1027fe6accf1 windows: Patched to compile! (...?)
Ryan C. Gordon <icculus@icculus.org>
parents: 1541
diff changeset
    35
836
6514fba91816 Patched to compile with latest Platform SDK.
Ryan C. Gordon <icculus@icculus.org>
parents: 828
diff changeset
    36
/* !!! FIXME: remove this when revamping stack allocation code... */
1396
422e9773320d Watcom C should include malloc.h to make the alloca macro available.
Ryan C. Gordon <icculus@icculus.org>
parents: 1395
diff changeset
    37
#if defined(_MSC_VER) || defined(__MINGW32__) || defined(__WATCOMC__)
836
6514fba91816 Patched to compile with latest Platform SDK.
Ryan C. Gordon <icculus@icculus.org>
parents: 828
diff changeset
    38
#include <malloc.h>
6514fba91816 Patched to compile with latest Platform SDK.
Ryan C. Gordon <icculus@icculus.org>
parents: 828
diff changeset
    39
#endif
6514fba91816 Patched to compile with latest Platform SDK.
Ryan C. Gordon <icculus@icculus.org>
parents: 828
diff changeset
    40
1516
ec5acd7392a2 Some minor preprocessor nitpicks.
Ryan C. Gordon <icculus@icculus.org>
parents: 1512
diff changeset
    41
#ifdef PHYSFS_PLATFORM_SOLARIS
1089
5491e6c69162 Patched to compile on Solaris.
Ryan C. Gordon <icculus@icculus.org>
parents: 1054
diff changeset
    42
#include <alloca.h>
5491e6c69162 Patched to compile on Solaris.
Ryan C. Gordon <icculus@icculus.org>
parents: 1054
diff changeset
    43
#endif
5491e6c69162 Patched to compile on Solaris.
Ryan C. Gordon <icculus@icculus.org>
parents: 1054
diff changeset
    44
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
    45
#ifdef __cplusplus
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
    46
extern "C" {
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
    47
#endif
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
    48
936
3b4b6c107a59 Fixed aliasing bug in Windows platform layer (thanks, Dennis!).
Ryan C. Gordon <icculus@icculus.org>
parents: 933
diff changeset
    49
#ifdef __GNUC__
938
ecbae90ae88d Yet another attempt to patch to compile.
Ryan C. Gordon <icculus@icculus.org>
parents: 936
diff changeset
    50
#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
    51
    ( ((__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
    52
#else
938
ecbae90ae88d Yet another attempt to patch to compile.
Ryan C. Gordon <icculus@icculus.org>
parents: 936
diff changeset
    53
#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
    54
#endif
3b4b6c107a59 Fixed aliasing bug in Windows platform layer (thanks, Dennis!).
Ryan C. Gordon <icculus@icculus.org>
parents: 933
diff changeset
    55
1100
f90724e3b4c6 Get rid of __inline__, just make sure "inline" is defined sanely instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1098
diff changeset
    56
#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
    57
    /* 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
    58
#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
    59
#   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
    60
#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
    61
#   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
    62
#endif
f90724e3b4c6 Get rid of __inline__, just make sure "inline" is defined sanely instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1098
diff changeset
    63
1516
ec5acd7392a2 Some minor preprocessor nitpicks.
Ryan C. Gordon <icculus@icculus.org>
parents: 1512
diff changeset
    64
#if defined(PHYSFS_PLATFORM_LINUX) && !defined(_FILE_OFFSET_BITS)
1228
7c0e9de2ba33 Removed llseek().
Ryan C. Gordon <icculus@icculus.org>
parents: 1227
diff changeset
    65
#define _FILE_OFFSET_BITS 64
7c0e9de2ba33 Removed llseek().
Ryan C. Gordon <icculus@icculus.org>
parents: 1227
diff changeset
    66
#endif
7c0e9de2ba33 Removed llseek().
Ryan C. Gordon <icculus@icculus.org>
parents: 1227
diff changeset
    67
1449
6df9e1a43f7c Cleaned up what symbols are exported from the library.
Ryan C. Gordon <icculus@icculus.org>
parents: 1442
diff changeset
    68
/* All public APIs need to be in physfs.h with a PHYSFS_DECL.
6df9e1a43f7c Cleaned up what symbols are exported from the library.
Ryan C. Gordon <icculus@icculus.org>
parents: 1442
diff changeset
    69
   All file-private symbols need to be marked "static".
6df9e1a43f7c Cleaned up what symbols are exported from the library.
Ryan C. Gordon <icculus@icculus.org>
parents: 1442
diff changeset
    70
   Everything shared between PhysicsFS sources needs to be in this
6df9e1a43f7c Cleaned up what symbols are exported from the library.
Ryan C. Gordon <icculus@icculus.org>
parents: 1442
diff changeset
    71
   file between the visibility pragma blocks. */
6df9e1a43f7c Cleaned up what symbols are exported from the library.
Ryan C. Gordon <icculus@icculus.org>
parents: 1442
diff changeset
    72
#if PHYSFS_MINIMUM_GCC_VERSION(4,0) || defined(__clang__)
6df9e1a43f7c Cleaned up what symbols are exported from the library.
Ryan C. Gordon <icculus@icculus.org>
parents: 1442
diff changeset
    73
#define PHYSFS_HAVE_PRAGMA_VISIBILITY 1
6df9e1a43f7c Cleaned up what symbols are exported from the library.
Ryan C. Gordon <icculus@icculus.org>
parents: 1442
diff changeset
    74
#endif
6df9e1a43f7c Cleaned up what symbols are exported from the library.
Ryan C. Gordon <icculus@icculus.org>
parents: 1442
diff changeset
    75
6df9e1a43f7c Cleaned up what symbols are exported from the library.
Ryan C. Gordon <icculus@icculus.org>
parents: 1442
diff changeset
    76
#if PHYSFS_HAVE_PRAGMA_VISIBILITY
6df9e1a43f7c Cleaned up what symbols are exported from the library.
Ryan C. Gordon <icculus@icculus.org>
parents: 1442
diff changeset
    77
#pragma GCC visibility push(hidden)
6df9e1a43f7c Cleaned up what symbols are exported from the library.
Ryan C. Gordon <icculus@icculus.org>
parents: 1442
diff changeset
    78
#endif
6df9e1a43f7c Cleaned up what symbols are exported from the library.
Ryan C. Gordon <icculus@icculus.org>
parents: 1442
diff changeset
    79
6df9e1a43f7c Cleaned up what symbols are exported from the library.
Ryan C. Gordon <icculus@icculus.org>
parents: 1442
diff changeset
    80
/* These are the build-in archivers. We list them all as "extern" here without
6df9e1a43f7c Cleaned up what symbols are exported from the library.
Ryan C. Gordon <icculus@icculus.org>
parents: 1442
diff changeset
    81
   #ifdefs to keep it tidy, but obviously you need to make sure these are
6df9e1a43f7c Cleaned up what symbols are exported from the library.
Ryan C. Gordon <icculus@icculus.org>
parents: 1442
diff changeset
    82
   wrapped in PHYSFS_SUPPORTS_* checks before actually referencing them. */
6df9e1a43f7c Cleaned up what symbols are exported from the library.
Ryan C. Gordon <icculus@icculus.org>
parents: 1442
diff changeset
    83
extern const PHYSFS_Archiver __PHYSFS_Archiver_DIR;
6df9e1a43f7c Cleaned up what symbols are exported from the library.
Ryan C. Gordon <icculus@icculus.org>
parents: 1442
diff changeset
    84
extern const PHYSFS_Archiver __PHYSFS_Archiver_ZIP;
1512
fe20ac238ce4 Rename __PHYSFS_Archiver_SZIP to __PHYSFS_Archiver_7Z.
Ryan C. Gordon <icculus@icculus.org>
parents: 1498
diff changeset
    85
extern const PHYSFS_Archiver __PHYSFS_Archiver_7Z;
1449
6df9e1a43f7c Cleaned up what symbols are exported from the library.
Ryan C. Gordon <icculus@icculus.org>
parents: 1442
diff changeset
    86
extern const PHYSFS_Archiver __PHYSFS_Archiver_GRP;
6df9e1a43f7c Cleaned up what symbols are exported from the library.
Ryan C. Gordon <icculus@icculus.org>
parents: 1442
diff changeset
    87
extern const PHYSFS_Archiver __PHYSFS_Archiver_QPAK;
6df9e1a43f7c Cleaned up what symbols are exported from the library.
Ryan C. Gordon <icculus@icculus.org>
parents: 1442
diff changeset
    88
extern const PHYSFS_Archiver __PHYSFS_Archiver_HOG;
6df9e1a43f7c Cleaned up what symbols are exported from the library.
Ryan C. Gordon <icculus@icculus.org>
parents: 1442
diff changeset
    89
extern const PHYSFS_Archiver __PHYSFS_Archiver_MVL;
6df9e1a43f7c Cleaned up what symbols are exported from the library.
Ryan C. Gordon <icculus@icculus.org>
parents: 1442
diff changeset
    90
extern const PHYSFS_Archiver __PHYSFS_Archiver_WAD;
6df9e1a43f7c Cleaned up what symbols are exported from the library.
Ryan C. Gordon <icculus@icculus.org>
parents: 1442
diff changeset
    91
extern const PHYSFS_Archiver __PHYSFS_Archiver_SLB;
6df9e1a43f7c Cleaned up what symbols are exported from the library.
Ryan C. Gordon <icculus@icculus.org>
parents: 1442
diff changeset
    92
extern const PHYSFS_Archiver __PHYSFS_Archiver_ISO9660;
6df9e1a43f7c Cleaned up what symbols are exported from the library.
Ryan C. Gordon <icculus@icculus.org>
parents: 1442
diff changeset
    93
extern const PHYSFS_Archiver __PHYSFS_Archiver_VDF;
6df9e1a43f7c Cleaned up what symbols are exported from the library.
Ryan C. Gordon <icculus@icculus.org>
parents: 1442
diff changeset
    94
1428
23d57a69cf1f Workaround snprintf() deficiencies on Visual Studio.
Ryan C. Gordon <icculus@icculus.org>
parents: 1409
diff changeset
    95
/* a real C99-compliant snprintf() is in Visual Studio 2015,
23d57a69cf1f Workaround snprintf() deficiencies on Visual Studio.
Ryan C. Gordon <icculus@icculus.org>
parents: 1409
diff changeset
    96
   but just use this everywhere for binary compatibility. */
23d57a69cf1f Workaround snprintf() deficiencies on Visual Studio.
Ryan C. Gordon <icculus@icculus.org>
parents: 1409
diff changeset
    97
#if defined(_MSC_VER)
23d57a69cf1f Workaround snprintf() deficiencies on Visual Studio.
Ryan C. Gordon <icculus@icculus.org>
parents: 1409
diff changeset
    98
int __PHYSFS_msvc_vsnprintf(char *outBuf, size_t size, const char *format, va_list ap);
23d57a69cf1f Workaround snprintf() deficiencies on Visual Studio.
Ryan C. Gordon <icculus@icculus.org>
parents: 1409
diff changeset
    99
int __PHYSFS_msvc_snprintf(char *outBuf, size_t size, const char *format, ...);
23d57a69cf1f Workaround snprintf() deficiencies on Visual Studio.
Ryan C. Gordon <icculus@icculus.org>
parents: 1409
diff changeset
   100
#define vsnprintf __PHYSFS_msvc_vsnprintf
23d57a69cf1f Workaround snprintf() deficiencies on Visual Studio.
Ryan C. Gordon <icculus@icculus.org>
parents: 1409
diff changeset
   101
#define snprintf __PHYSFS_msvc_snprintf
23d57a69cf1f Workaround snprintf() deficiencies on Visual Studio.
Ryan C. Gordon <icculus@icculus.org>
parents: 1409
diff changeset
   102
#endif
23d57a69cf1f Workaround snprintf() deficiencies on Visual Studio.
Ryan C. Gordon <icculus@icculus.org>
parents: 1409
diff changeset
   103
1518
a6ac19814d53 Serious cleanup and update of Windows RT support.
Ryan C. Gordon <icculus@icculus.org>
parents: 1516
diff changeset
   104
/* Some simple wrappers around WinRT C++ interfaces we can call from C. */
a6ac19814d53 Serious cleanup and update of Windows RT support.
Ryan C. Gordon <icculus@icculus.org>
parents: 1516
diff changeset
   105
#ifdef PHYSFS_PLATFORM_WINRT
a6ac19814d53 Serious cleanup and update of Windows RT support.
Ryan C. Gordon <icculus@icculus.org>
parents: 1516
diff changeset
   106
const void *__PHYSFS_winrtCalcBaseDir(void);
a6ac19814d53 Serious cleanup and update of Windows RT support.
Ryan C. Gordon <icculus@icculus.org>
parents: 1516
diff changeset
   107
const void *__PHYSFS_winrtCalcPrefDir(void);
a6ac19814d53 Serious cleanup and update of Windows RT support.
Ryan C. Gordon <icculus@icculus.org>
parents: 1516
diff changeset
   108
#endif
a6ac19814d53 Serious cleanup and update of Windows RT support.
Ryan C. Gordon <icculus@icculus.org>
parents: 1516
diff changeset
   109
1538
81c73124d651 Add basic atomic operations for refcounting, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 1536
diff changeset
   110
/* atomic operations. */
81c73124d651 Add basic atomic operations for refcounting, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 1536
diff changeset
   111
#if defined(_MSC_VER) && (_MSC_VER >= 1500)
81c73124d651 Add basic atomic operations for refcounting, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 1536
diff changeset
   112
#include <intrin.h>
1542
1027fe6accf1 windows: Patched to compile! (...?)
Ryan C. Gordon <icculus@icculus.org>
parents: 1541
diff changeset
   113
__PHYSFS_COMPILE_TIME_ASSERT(LongEqualsInt, sizeof (int) == sizeof (long));
1541
600636c452ac windows: (maybe) patched to compile on Visual Studio.
Ryan C. Gordon <icculus@icculus.org>
parents: 1538
diff changeset
   114
#define __PHYSFS_ATOMIC_INCR(ptrval) _InterlockedIncrement((long*)(ptrval))
1542
1027fe6accf1 windows: Patched to compile! (...?)
Ryan C. Gordon <icculus@icculus.org>
parents: 1541
diff changeset
   115
#define __PHYSFS_ATOMIC_DECR(ptrval) _InterlockedDecrement((long*)(ptrval))
1538
81c73124d651 Add basic atomic operations for refcounting, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 1536
diff changeset
   116
#elif defined(__clang__) || (defined(__GNUC__) && (((__GNUC__ * 10000) + (__GNUC_MINOR__ * 100)) >= 40100))
81c73124d651 Add basic atomic operations for refcounting, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 1536
diff changeset
   117
#define __PHYSFS_ATOMIC_INCR(ptrval) __sync_fetch_and_add(ptrval, 1)
81c73124d651 Add basic atomic operations for refcounting, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 1536
diff changeset
   118
#define __PHYSFS_ATOMIC_DECR(ptrval) __sync_fetch_and_add(ptrval, -1)
81c73124d651 Add basic atomic operations for refcounting, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 1536
diff changeset
   119
#else
81c73124d651 Add basic atomic operations for refcounting, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 1536
diff changeset
   120
#define PHYSFS_NEED_ATOMIC_OP_FALLBACK 1
81c73124d651 Add basic atomic operations for refcounting, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 1536
diff changeset
   121
int __PHYSFS_ATOMIC_INCR(int *ptrval);
81c73124d651 Add basic atomic operations for refcounting, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 1536
diff changeset
   122
int __PHYSFS_ATOMIC_DECR(int *ptrval);
81c73124d651 Add basic atomic operations for refcounting, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 1536
diff changeset
   123
#endif
81c73124d651 Add basic atomic operations for refcounting, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 1536
diff changeset
   124
81c73124d651 Add basic atomic operations for refcounting, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 1536
diff changeset
   125
852
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
   126
/*
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
   127
 * 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
   128
 *  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
   129
 *  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
   130
 *  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
   131
 * 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
   132
 * 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
   133
 *  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
   134
 * 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
   135
 *  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
   136
 *  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
   137
 * 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
   138
 *  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
   139
 *  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
   140
 * 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
   141
 *  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
   142
 *  from.
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
   143
 * 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
   144
 * 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
   145
 * 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
   146
 */
1205
af22fe211dde Bump the smallAlloc threshold up to 256 bytes.
Ryan C. Gordon <icculus@icculus.org>
parents: 1203
diff changeset
   147
#define __PHYSFS_SMALLALLOCTHRESHOLD 256
1576
b25da658b8ee Little tweaks to __PHYSFS_initSmallAlloc().
Ryan C. Gordon <icculus@icculus.org>
parents: 1568
diff changeset
   148
void *__PHYSFS_initSmallAlloc(void *ptr, const size_t len);
852
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
   149
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
   150
#define __PHYSFS_smallAlloc(bytes) ( \
1215
0a8369723de7 Fixed stack smashing in newly-aligned __PHYSFS_smallAlloc().
Ryan C. Gordon <icculus@icculus.org>
parents: 1214
diff changeset
   151
    __PHYSFS_initSmallAlloc( \
0a8369723de7 Fixed stack smashing in newly-aligned __PHYSFS_smallAlloc().
Ryan C. Gordon <icculus@icculus.org>
parents: 1214
diff changeset
   152
        (((bytes) < __PHYSFS_SMALLALLOCTHRESHOLD) ? \
0a8369723de7 Fixed stack smashing in newly-aligned __PHYSFS_smallAlloc().
Ryan C. Gordon <icculus@icculus.org>
parents: 1214
diff changeset
   153
            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
   154
)
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
   155
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
   156
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
   157
9467e96abdf1 Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents: 851
diff changeset
   158
691
71d9affe0d8a All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents: 676
diff changeset
   159
/* 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
   160
#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
   161
#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
   162
#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
   163
/* !!! FIXME: add alloca check here. */
427
c38ace41039f Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents: 422
diff changeset
   164
1653
ff8f4c2a60d8 Allow builds to opt-out or opt-in to specific archivers, whichever's easier.
Ryan C. Gordon <icculus@icculus.org>
parents: 1620
diff changeset
   165
ff8f4c2a60d8 Allow builds to opt-out or opt-in to specific archivers, whichever's easier.
Ryan C. Gordon <icculus@icculus.org>
parents: 1620
diff changeset
   166
/* by default, enable things, so builds can opt out of a few things they
ff8f4c2a60d8 Allow builds to opt-out or opt-in to specific archivers, whichever's easier.
Ryan C. Gordon <icculus@icculus.org>
parents: 1620
diff changeset
   167
   want to avoid. But you can build with this #defined to 0 if you would
ff8f4c2a60d8 Allow builds to opt-out or opt-in to specific archivers, whichever's easier.
Ryan C. Gordon <icculus@icculus.org>
parents: 1620
diff changeset
   168
   like to turn off everything except a handful of things you opt into. */
ff8f4c2a60d8 Allow builds to opt-out or opt-in to specific archivers, whichever's easier.
Ryan C. Gordon <icculus@icculus.org>
parents: 1620
diff changeset
   169
#ifndef PHYSFS_SUPPORTS_DEFAULT
ff8f4c2a60d8 Allow builds to opt-out or opt-in to specific archivers, whichever's easier.
Ryan C. Gordon <icculus@icculus.org>
parents: 1620
diff changeset
   170
#define PHYSFS_SUPPORTS_DEFAULT 1
ff8f4c2a60d8 Allow builds to opt-out or opt-in to specific archivers, whichever's easier.
Ryan C. Gordon <icculus@icculus.org>
parents: 1620
diff changeset
   171
#endif
ff8f4c2a60d8 Allow builds to opt-out or opt-in to specific archivers, whichever's easier.
Ryan C. Gordon <icculus@icculus.org>
parents: 1620
diff changeset
   172
ff8f4c2a60d8 Allow builds to opt-out or opt-in to specific archivers, whichever's easier.
Ryan C. Gordon <icculus@icculus.org>
parents: 1620
diff changeset
   173
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
   174
#ifndef PHYSFS_SUPPORTS_ZIP
1653
ff8f4c2a60d8 Allow builds to opt-out or opt-in to specific archivers, whichever's easier.
Ryan C. Gordon <icculus@icculus.org>
parents: 1620
diff changeset
   175
#define PHYSFS_SUPPORTS_ZIP PHYSFS_SUPPORTS_DEFAULT
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
   176
#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
   177
#ifndef PHYSFS_SUPPORTS_7Z
1653
ff8f4c2a60d8 Allow builds to opt-out or opt-in to specific archivers, whichever's easier.
Ryan C. Gordon <icculus@icculus.org>
parents: 1620
diff changeset
   178
#define PHYSFS_SUPPORTS_7Z PHYSFS_SUPPORTS_DEFAULT
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
   179
#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
   180
#ifndef PHYSFS_SUPPORTS_GRP
1653
ff8f4c2a60d8 Allow builds to opt-out or opt-in to specific archivers, whichever's easier.
Ryan C. Gordon <icculus@icculus.org>
parents: 1620
diff changeset
   181
#define PHYSFS_SUPPORTS_GRP PHYSFS_SUPPORTS_DEFAULT
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
   182
#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
   183
#ifndef PHYSFS_SUPPORTS_HOG
1653
ff8f4c2a60d8 Allow builds to opt-out or opt-in to specific archivers, whichever's easier.
Ryan C. Gordon <icculus@icculus.org>
parents: 1620
diff changeset
   184
#define PHYSFS_SUPPORTS_HOG PHYSFS_SUPPORTS_DEFAULT
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
   185
#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
   186
#ifndef PHYSFS_SUPPORTS_MVL
1653
ff8f4c2a60d8 Allow builds to opt-out or opt-in to specific archivers, whichever's easier.
Ryan C. Gordon <icculus@icculus.org>
parents: 1620
diff changeset
   187
#define PHYSFS_SUPPORTS_MVL PHYSFS_SUPPORTS_DEFAULT
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
   188
#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
   189
#ifndef PHYSFS_SUPPORTS_WAD
1653
ff8f4c2a60d8 Allow builds to opt-out or opt-in to specific archivers, whichever's easier.
Ryan C. Gordon <icculus@icculus.org>
parents: 1620
diff changeset
   190
#define PHYSFS_SUPPORTS_WAD PHYSFS_SUPPORTS_DEFAULT
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
   191
#endif
1460
d4bee156a625 Reenable QPAK support by default.
Ryan C. Gordon <icculus@icculus.org>
parents: 1449
diff changeset
   192
#ifndef PHYSFS_SUPPORTS_QPAK
1653
ff8f4c2a60d8 Allow builds to opt-out or opt-in to specific archivers, whichever's easier.
Ryan C. Gordon <icculus@icculus.org>
parents: 1620
diff changeset
   193
#define PHYSFS_SUPPORTS_QPAK PHYSFS_SUPPORTS_DEFAULT
1460
d4bee156a625 Reenable QPAK support by default.
Ryan C. Gordon <icculus@icculus.org>
parents: 1449
diff changeset
   194
#endif
1315
c686e4f84ab5 SLB archiver
Aleksi Nurmi <aleksi.nurmi@gmail.com>
parents: 1283
diff changeset
   195
#ifndef PHYSFS_SUPPORTS_SLB
1653
ff8f4c2a60d8 Allow builds to opt-out or opt-in to specific archivers, whichever's easier.
Ryan C. Gordon <icculus@icculus.org>
parents: 1620
diff changeset
   196
#define PHYSFS_SUPPORTS_SLB PHYSFS_SUPPORTS_DEFAULT
1315
c686e4f84ab5 SLB archiver
Aleksi Nurmi <aleksi.nurmi@gmail.com>
parents: 1283
diff changeset
   197
#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
   198
#ifndef PHYSFS_SUPPORTS_ISO9660
1653
ff8f4c2a60d8 Allow builds to opt-out or opt-in to specific archivers, whichever's easier.
Ryan C. Gordon <icculus@icculus.org>
parents: 1620
diff changeset
   199
#define PHYSFS_SUPPORTS_ISO9660 PHYSFS_SUPPORTS_DEFAULT
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
   200
#endif
1391
06aa5aca8518 Add support for VDF
Francesco Bertolaccini <bertolaccinifrancesco@gmail.com>
parents: 1374
diff changeset
   201
#ifndef PHYSFS_SUPPORTS_VDF
1653
ff8f4c2a60d8 Allow builds to opt-out or opt-in to specific archivers, whichever's easier.
Ryan C. Gordon <icculus@icculus.org>
parents: 1620
diff changeset
   202
#define PHYSFS_SUPPORTS_VDF PHYSFS_SUPPORTS_DEFAULT
1391
06aa5aca8518 Add support for VDF
Francesco Bertolaccini <bertolaccinifrancesco@gmail.com>
parents: 1374
diff changeset
   203
#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
   204
1567
539b68269e9f 7z: do global initialization once without risking a race condition.
Ryan C. Gordon <icculus@icculus.org>
parents: 1559
diff changeset
   205
#if PHYSFS_SUPPORTS_7Z
539b68269e9f 7z: do global initialization once without risking a race condition.
Ryan C. Gordon <icculus@icculus.org>
parents: 1559
diff changeset
   206
/* 7zip support needs a global init function called at startup (no deinit). */
539b68269e9f 7z: do global initialization once without risking a race condition.
Ryan C. Gordon <icculus@icculus.org>
parents: 1559
diff changeset
   207
extern void SZIP_global_init(void);
539b68269e9f 7z: do global initialization once without risking a race condition.
Ryan C. Gordon <icculus@icculus.org>
parents: 1559
diff changeset
   208
#endif
539b68269e9f 7z: do global initialization once without risking a race condition.
Ryan C. Gordon <icculus@icculus.org>
parents: 1559
diff changeset
   209
1280
bd174b99fa5b Add binary compatibility to PHYSFS_Io.
Ryan C. Gordon <icculus@icculus.org>
parents: 1276
diff changeset
   210
/* The latest supported PHYSFS_Io::version value. */
bd174b99fa5b Add binary compatibility to PHYSFS_Io.
Ryan C. Gordon <icculus@icculus.org>
parents: 1276
diff changeset
   211
#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
   212
1322
5476917b8ddf Allow application-supplied archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 1315
diff changeset
   213
/* The latest supported PHYSFS_Archiver::version value. */
5476917b8ddf Allow application-supplied archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 1315
diff changeset
   214
#define CURRENT_PHYSFS_ARCHIVER_API_VERSION 0
11
677e01f5109e Progress toward complete implementation continues...
Ryan C. Gordon <icculus@icculus.org>
parents: 9
diff changeset
   215
1373
527ef3c6a2d6 HTTPS all the things.
Ryan C. Gordon <icculus@icculus.org>
parents: 1372
diff changeset
   216
/* This byteorder stuff was lifted from SDL. https://www.libsdl.org/ */
629
b01a59827192 Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents: 627
diff changeset
   217
#define PHYSFS_LIL_ENDIAN  1234
b01a59827192 Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents: 627
diff changeset
   218
#define PHYSFS_BIG_ENDIAN  4321
b01a59827192 Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents: 627
diff changeset
   219
1374
c49f2eedba94 Updated byte order tests to match what SDL does now.
Ryan C. Gordon <icculus@icculus.org>
parents: 1373
diff changeset
   220
#ifdef __linux__
c49f2eedba94 Updated byte order tests to match what SDL does now.
Ryan C. Gordon <icculus@icculus.org>
parents: 1373
diff changeset
   221
#include <endian.h>
c49f2eedba94 Updated byte order tests to match what SDL does now.
Ryan C. Gordon <icculus@icculus.org>
parents: 1373
diff changeset
   222
#define PHYSFS_BYTEORDER  __BYTE_ORDER
c49f2eedba94 Updated byte order tests to match what SDL does now.
Ryan C. Gordon <icculus@icculus.org>
parents: 1373
diff changeset
   223
#else /* __linux__ */
c49f2eedba94 Updated byte order tests to match what SDL does now.
Ryan C. Gordon <icculus@icculus.org>
parents: 1373
diff changeset
   224
#if defined(__hppa__) || \
c49f2eedba94 Updated byte order tests to match what SDL does now.
Ryan C. Gordon <icculus@icculus.org>
parents: 1373
diff changeset
   225
    defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \
c49f2eedba94 Updated byte order tests to match what SDL does now.
Ryan C. Gordon <icculus@icculus.org>
parents: 1373
diff changeset
   226
    (defined(__MIPS__) && defined(__MISPEB__)) || \
c49f2eedba94 Updated byte order tests to match what SDL does now.
Ryan C. Gordon <icculus@icculus.org>
parents: 1373
diff changeset
   227
    defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \
c49f2eedba94 Updated byte order tests to match what SDL does now.
Ryan C. Gordon <icculus@icculus.org>
parents: 1373
diff changeset
   228
    defined(__sparc__)
c49f2eedba94 Updated byte order tests to match what SDL does now.
Ryan C. Gordon <icculus@icculus.org>
parents: 1373
diff changeset
   229
#define PHYSFS_BYTEORDER   PHYSFS_BIG_ENDIAN
629
b01a59827192 Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents: 627
diff changeset
   230
#else
1374
c49f2eedba94 Updated byte order tests to match what SDL does now.
Ryan C. Gordon <icculus@icculus.org>
parents: 1373
diff changeset
   231
#define PHYSFS_BYTEORDER   PHYSFS_LIL_ENDIAN
629
b01a59827192 Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents: 627
diff changeset
   232
#endif
1374
c49f2eedba94 Updated byte order tests to match what SDL does now.
Ryan C. Gordon <icculus@icculus.org>
parents: 1373
diff changeset
   233
#endif /* __linux__ */
629
b01a59827192 Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents: 627
diff changeset
   234
b01a59827192 Moved byte order defines into internal header.
Ryan C. Gordon <icculus@icculus.org>
parents: 627
diff changeset
   235
464
21c8e0d1578c Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents: 444
diff changeset
   236
/*
21c8e0d1578c Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents: 444
diff changeset
   237
 * 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
   238
 *  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
   239
 *  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
   240
 *
21c8e0d1578c Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents: 444
diff changeset
   241
 * 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
   242
 *  before #including "physfs_internal.h".
21c8e0d1578c Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents: 444
diff changeset
   243
 */
21c8e0d1578c Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents: 444
diff changeset
   244
#ifndef PHYSFS_QUICKSORT_THRESHOLD
21c8e0d1578c Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents: 444
diff changeset
   245
#define PHYSFS_QUICKSORT_THRESHOLD 4
21c8e0d1578c Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents: 444
diff changeset
   246
#endif
21c8e0d1578c Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents: 444
diff changeset
   247
21c8e0d1578c Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents: 444
diff changeset
   248
/*
21c8e0d1578c Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents: 444
diff changeset
   249
 * 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
   250
 *  a QuickSort and BubbleSort internally.
21c8e0d1578c Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents: 444
diff changeset
   251
 * (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
   252
 *  swapping of elements in the list.
21c8e0d1578c Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents: 444
diff changeset
   253
 */
1283
8bcc48d243df Added Zip64 support to the .zip archiver.
Ryan C. Gordon <icculus@icculus.org>
parents: 1281
diff changeset
   254
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
   255
                   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
   256
                   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
   257
69
546a95cc5591 Updates, corrections and enhancements to get this ported to win32.
Ryan C. Gordon <icculus@icculus.org>
parents: 49
diff changeset
   258
/* These get used all over for lessening code clutter. */
1402
c5a5dadb901d Cleanup BAIL_* and GOTO_* macros to be less cluttered.
Ryan C. Gordon <icculus@icculus.org>
parents: 1396
diff changeset
   259
/* "ERRPASS" means "something else just set the error state for us" and is
c5a5dadb901d Cleanup BAIL_* and GOTO_* macros to be less cluttered.
Ryan C. Gordon <icculus@icculus.org>
parents: 1396
diff changeset
   260
    just to make it clear where the responsibility for the error state lays. */
c5a5dadb901d Cleanup BAIL_* and GOTO_* macros to be less cluttered.
Ryan C. Gordon <icculus@icculus.org>
parents: 1396
diff changeset
   261
#define BAIL(e, r) do { if (e) PHYSFS_setErrorCode(e); return r; } while (0)
c5a5dadb901d Cleanup BAIL_* and GOTO_* macros to be less cluttered.
Ryan C. Gordon <icculus@icculus.org>
parents: 1396
diff changeset
   262
#define BAIL_ERRPASS(r) do { return r; } while (0)
c5a5dadb901d Cleanup BAIL_* and GOTO_* macros to be less cluttered.
Ryan C. Gordon <icculus@icculus.org>
parents: 1396
diff changeset
   263
#define BAIL_IF(c, e, r) do { if (c) { if (e) PHYSFS_setErrorCode(e); return r; } } while (0)
c5a5dadb901d Cleanup BAIL_* and GOTO_* macros to be less cluttered.
Ryan C. Gordon <icculus@icculus.org>
parents: 1396
diff changeset
   264
#define BAIL_IF_ERRPASS(c, r) do { if (c) { return r; } } while (0)
c5a5dadb901d Cleanup BAIL_* and GOTO_* macros to be less cluttered.
Ryan C. Gordon <icculus@icculus.org>
parents: 1396
diff changeset
   265
#define BAIL_MUTEX(e, m, r) do { if (e) PHYSFS_setErrorCode(e); __PHYSFS_platformReleaseMutex(m); return r; } while (0)
c5a5dadb901d Cleanup BAIL_* and GOTO_* macros to be less cluttered.
Ryan C. Gordon <icculus@icculus.org>
parents: 1396
diff changeset
   266
#define BAIL_MUTEX_ERRPASS(m, r) do { __PHYSFS_platformReleaseMutex(m); return r; } while (0)
c5a5dadb901d Cleanup BAIL_* and GOTO_* macros to be less cluttered.
Ryan C. Gordon <icculus@icculus.org>
parents: 1396
diff changeset
   267
#define BAIL_IF_MUTEX(c, e, m, r) do { if (c) { if (e) PHYSFS_setErrorCode(e); __PHYSFS_platformReleaseMutex(m); return r; } } while (0)
c5a5dadb901d Cleanup BAIL_* and GOTO_* macros to be less cluttered.
Ryan C. Gordon <icculus@icculus.org>
parents: 1396
diff changeset
   268
#define BAIL_IF_MUTEX_ERRPASS(c, m, r) do { if (c) { __PHYSFS_platformReleaseMutex(m); return r; } } while (0)
c5a5dadb901d Cleanup BAIL_* and GOTO_* macros to be less cluttered.
Ryan C. Gordon <icculus@icculus.org>
parents: 1396
diff changeset
   269
#define GOTO(e, g) do { if (e) PHYSFS_setErrorCode(e); goto g; } while (0)
c5a5dadb901d Cleanup BAIL_* and GOTO_* macros to be less cluttered.
Ryan C. Gordon <icculus@icculus.org>
parents: 1396
diff changeset
   270
#define GOTO_ERRPASS(g) do { goto g; } while (0)
c5a5dadb901d Cleanup BAIL_* and GOTO_* macros to be less cluttered.
Ryan C. Gordon <icculus@icculus.org>
parents: 1396
diff changeset
   271
#define GOTO_IF(c, e, g) do { if (c) { if (e) PHYSFS_setErrorCode(e); goto g; } } while (0)
c5a5dadb901d Cleanup BAIL_* and GOTO_* macros to be less cluttered.
Ryan C. Gordon <icculus@icculus.org>
parents: 1396
diff changeset
   272
#define GOTO_IF_ERRPASS(c, g) do { if (c) { goto g; } } while (0)
c5a5dadb901d Cleanup BAIL_* and GOTO_* macros to be less cluttered.
Ryan C. Gordon <icculus@icculus.org>
parents: 1396
diff changeset
   273
#define GOTO_MUTEX(e, m, g) do { if (e) PHYSFS_setErrorCode(e); __PHYSFS_platformReleaseMutex(m); goto g; } while (0)
c5a5dadb901d Cleanup BAIL_* and GOTO_* macros to be less cluttered.
Ryan C. Gordon <icculus@icculus.org>
parents: 1396
diff changeset
   274
#define GOTO_MUTEX_ERRPASS(m, g) do { __PHYSFS_platformReleaseMutex(m); goto g; } while (0)
c5a5dadb901d Cleanup BAIL_* and GOTO_* macros to be less cluttered.
Ryan C. Gordon <icculus@icculus.org>
parents: 1396
diff changeset
   275
#define GOTO_IF_MUTEX(c, e, m, g) do { if (c) { if (e) PHYSFS_setErrorCode(e); __PHYSFS_platformReleaseMutex(m); goto g; } } while (0)
c5a5dadb901d Cleanup BAIL_* and GOTO_* macros to be less cluttered.
Ryan C. Gordon <icculus@icculus.org>
parents: 1396
diff changeset
   276
#define GOTO_IF_MUTEX_ERRPASS(c, m, g) do { if (c) { __PHYSFS_platformReleaseMutex(m); goto g; } } while (0)
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   277
828
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   278
#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
   279
1098
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1097
diff changeset
   280
#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
   281
#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
   282
#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
   283
#elif (defined __GNUC__)
850
2bc230284fed Replaced LONGLONGLITERAL with __PHYSFS_UI64/__PHYSFS_SI64.
Ryan C. Gordon <icculus@icculus.org>
parents: 845
diff changeset
   284
#define __PHYSFS_SI64(x) x##LL
2bc230284fed Replaced LONGLONGLITERAL with __PHYSFS_UI64/__PHYSFS_SI64.
Ryan C. Gordon <icculus@icculus.org>
parents: 845
diff changeset
   285
#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
   286
#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
   287
#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
   288
#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
   289
#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
   290
#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
   291
#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
   292
#endif
efadd9cdb6a4 Cleaned up overflow checks in platform memory allocators (thanks to Nicolas
Ryan C. Gordon <icculus@icculus.org>
parents: 754
diff changeset
   293
936
3b4b6c107a59 Fixed aliasing bug in Windows platform layer (thanks, Dennis!).
Ryan C. Gordon <icculus@icculus.org>
parents: 933
diff changeset
   294
763
efadd9cdb6a4 Cleaned up overflow checks in platform memory allocators (thanks to Nicolas
Ryan C. Gordon <icculus@icculus.org>
parents: 754
diff changeset
   295
/*
efadd9cdb6a4 Cleaned up overflow checks in platform memory allocators (thanks to Nicolas
Ryan C. Gordon <icculus@icculus.org>
parents: 754
diff changeset
   296
 * 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
   297
 *  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
   298
 *  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
   299
 *  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
   300
 *  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
   301
 */
efadd9cdb6a4 Cleaned up overflow checks in platform memory allocators (thanks to Nicolas
Ryan C. Gordon <icculus@icculus.org>
parents: 754
diff changeset
   302
#define __PHYSFS_ui64FitsAddressSpace(s) ( \
1112
12e187aa051c Made __PHYSFS_ui64FitsAddressSpace's behaviour match its name.
Ryan C. Gordon <icculus@icculus.org>
parents: 1111
diff changeset
   303
    (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
   304
    ((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
   305
)
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   306
828
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   307
/*
1370
75ac8ab59394 Move __PHYSFS_strdup() declaration up with other string helpers.
Ryan C. Gordon <icculus@icculus.org>
parents: 1356
diff changeset
   308
 * Like strdup(), but uses the current PhysicsFS allocator.
75ac8ab59394 Move __PHYSFS_strdup() declaration up with other string helpers.
Ryan C. Gordon <icculus@icculus.org>
parents: 1356
diff changeset
   309
 */
75ac8ab59394 Move __PHYSFS_strdup() declaration up with other string helpers.
Ryan C. Gordon <icculus@icculus.org>
parents: 1356
diff changeset
   310
char *__PHYSFS_strdup(const char *str);
75ac8ab59394 Move __PHYSFS_strdup() declaration up with other string helpers.
Ryan C. Gordon <icculus@icculus.org>
parents: 1356
diff changeset
   311
1372
1a64a2857a0c zip: Reworked how we organize ZIP entries.
Ryan C. Gordon <icculus@icculus.org>
parents: 1371
diff changeset
   312
/*
1a64a2857a0c zip: Reworked how we organize ZIP entries.
Ryan C. Gordon <icculus@icculus.org>
parents: 1371
diff changeset
   313
 * Give a hash value for a C string (uses djb's xor hashing algorithm).
1a64a2857a0c zip: Reworked how we organize ZIP entries.
Ryan C. Gordon <icculus@icculus.org>
parents: 1371
diff changeset
   314
 */
1a64a2857a0c zip: Reworked how we organize ZIP entries.
Ryan C. Gordon <icculus@icculus.org>
parents: 1371
diff changeset
   315
PHYSFS_uint32 __PHYSFS_hashString(const char *str, size_t len);
1a64a2857a0c zip: Reworked how we organize ZIP entries.
Ryan C. Gordon <icculus@icculus.org>
parents: 1371
diff changeset
   316
828
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   317
ee871d51510d Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents: 809
diff changeset
   318
/*
691
71d9affe0d8a All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents: 676
diff changeset
   319
 * 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
   320
 */
691
71d9affe0d8a All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents: 676
diff changeset
   321
extern PHYSFS_Allocator __PHYSFS_AllocatorHooks;
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   322
691
71d9affe0d8a All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents: 676
diff changeset
   323
/* 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
   324
#define allocator __PHYSFS_AllocatorHooks
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   325
1118
2e09fc635fdd Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1115
diff changeset
   326
/*
2e09fc635fdd Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1115
diff changeset
   327
 * 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
   328
 *  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
   329
 *  '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
   330
 */
2e09fc635fdd Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1115
diff changeset
   331
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
   332
1120
67e5e23425a0 Added PHYSFS_mountMemory().
Ryan C. Gordon <icculus@icculus.org>
parents: 1118
diff changeset
   333
/*
67e5e23425a0 Added PHYSFS_mountMemory().
Ryan C. Gordon <icculus@icculus.org>
parents: 1118
diff changeset
   334
 * 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
   335
 *  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
   336
 *  its refcount without allocating a copy of the buffer.
67e5e23425a0 Added PHYSFS_mountMemory().
Ryan C. Gordon <icculus@icculus.org>
parents: 1118
diff changeset
   337
 */
67e5e23425a0 Added PHYSFS_mountMemory().
Ryan C. Gordon <icculus@icculus.org>
parents: 1118
diff changeset
   338
PHYSFS_Io *__PHYSFS_createMemoryIo(const void *buf, PHYSFS_uint64 len,
67e5e23425a0 Added PHYSFS_mountMemory().
Ryan C. Gordon <icculus@icculus.org>
parents: 1118
diff changeset
   339
                                   void (*destruct)(void *));
67e5e23425a0 Added PHYSFS_mountMemory().
Ryan C. Gordon <icculus@icculus.org>
parents: 1118
diff changeset
   340
1118
2e09fc635fdd Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1115
diff changeset
   341
1203
55f147714ce2 Cleaned up all the readAll() cut and paste.
Ryan C. Gordon <icculus@icculus.org>
parents: 1197
diff changeset
   342
/*
55f147714ce2 Cleaned up all the readAll() cut and paste.
Ryan C. Gordon <icculus@icculus.org>
parents: 1197
diff changeset
   343
 * 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
   344
 *  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
   345
 */
1583
66ed1e1d525b Whoops, patched to compile.
Ryan C. Gordon <icculus@icculus.org>
parents: 1581
diff changeset
   346
int __PHYSFS_readAll(PHYSFS_Io *io, void *buf, const size_t 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
   347
067d8e76261e Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents: 1127
diff changeset
   348
067d8e76261e Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents: 1127
diff changeset
   349
/* 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
   350
1497
b9d771d6805f unpacked: let archivers "abandon" the archive instead of closing it.
Ryan C. Gordon <icculus@icculus.org>
parents: 1494
diff changeset
   351
void UNPK_abandonArchive(void *opaque);
1322
5476917b8ddf Allow application-supplied archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 1315
diff changeset
   352
void UNPK_closeArchive(void *opaque);
1494
4e2c7ce9bf11 DirTrees and unpacked archives shouldn't demand a count of entries for init.
Ryan C. Gordon <icculus@icculus.org>
parents: 1467
diff changeset
   353
void *UNPK_openArchive(PHYSFS_Io *io);
1463
c23e55bad32d Reworked the "unpacked" archivers to use DirTree.
Ryan C. Gordon <icculus@icculus.org>
parents: 1462
diff changeset
   354
void *UNPK_addEntry(void *opaque, char *name, const int isdir,
1498
5977294d8e4b unpacked: let archivers specify create and modified times, hook up to iso9660.
Ryan C. Gordon <icculus@icculus.org>
parents: 1497
diff changeset
   355
                    const PHYSFS_sint64 ctime, const PHYSFS_sint64 mtime,
1463
c23e55bad32d Reworked the "unpacked" archivers to use DirTree.
Ryan C. Gordon <icculus@icculus.org>
parents: 1462
diff changeset
   356
                    const PHYSFS_uint64 pos, const PHYSFS_uint64 len);
1329
919f885155d8 Cleaned out "exists" nonsense in openRead() API.
Ryan C. Gordon <icculus@icculus.org>
parents: 1328
diff changeset
   357
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
   358
PHYSFS_Io *UNPK_openWrite(void *opaque, const char *name);
5476917b8ddf Allow application-supplied archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 1315
diff changeset
   359
PHYSFS_Io *UNPK_openAppend(void *opaque, const char *name);
5476917b8ddf Allow application-supplied archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 1315
diff changeset
   360
int UNPK_remove(void *opaque, const char *name);
5476917b8ddf Allow application-supplied archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 1315
diff changeset
   361
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
   362
int UNPK_stat(void *opaque, const char *fn, PHYSFS_Stat *st);
1559
aaee2b83291f Reworked enumeration to be more powerful.
Ryan C. Gordon <icculus@icculus.org>
parents: 1558
diff changeset
   363
#define UNPK_enumerate __PHYSFS_DirTreeEnumerate
1128
067d8e76261e Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents: 1127
diff changeset
   364
067d8e76261e Moved most the cut-and-paste between simple archivers to one file.
Ryan C. Gordon <icculus@icculus.org>
parents: 1127
diff changeset
   365
1462
e4995ae256a7 Moved ZIP tree management up to a higher level, to be reused elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents: 1460
diff changeset
   366
e4995ae256a7 Moved ZIP tree management up to a higher level, to be reused elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents: 1460
diff changeset
   367
/* Optional API many archivers use this to manage their directory tree. */
1568
9e0c6ceefd41 Filled in more documentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 1567
diff changeset
   368
/* !!! FIXME: document this better. */
1462
e4995ae256a7 Moved ZIP tree management up to a higher level, to be reused elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents: 1460
diff changeset
   369
e4995ae256a7 Moved ZIP tree management up to a higher level, to be reused elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents: 1460
diff changeset
   370
typedef struct __PHYSFS_DirTreeEntry
e4995ae256a7 Moved ZIP tree management up to a higher level, to be reused elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents: 1460
diff changeset
   371
{
e4995ae256a7 Moved ZIP tree management up to a higher level, to be reused elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents: 1460
diff changeset
   372
    char *name;                              /* Full path in archive.        */
e4995ae256a7 Moved ZIP tree management up to a higher level, to be reused elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents: 1460
diff changeset
   373
    struct __PHYSFS_DirTreeEntry *hashnext;  /* next item in hash bucket.    */
e4995ae256a7 Moved ZIP tree management up to a higher level, to be reused elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents: 1460
diff changeset
   374
    struct __PHYSFS_DirTreeEntry *children;  /* linked list of kids, if dir. */
e4995ae256a7 Moved ZIP tree management up to a higher level, to be reused elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents: 1460
diff changeset
   375
    struct __PHYSFS_DirTreeEntry *sibling;   /* next item in same dir.       */
e4995ae256a7 Moved ZIP tree management up to a higher level, to be reused elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents: 1460
diff changeset
   376
    int isdir;
e4995ae256a7 Moved ZIP tree management up to a higher level, to be reused elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents: 1460
diff changeset
   377
} __PHYSFS_DirTreeEntry;
e4995ae256a7 Moved ZIP tree management up to a higher level, to be reused elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents: 1460
diff changeset
   378
e4995ae256a7 Moved ZIP tree management up to a higher level, to be reused elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents: 1460
diff changeset
   379
typedef struct __PHYSFS_DirTree
e4995ae256a7 Moved ZIP tree management up to a higher level, to be reused elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents: 1460
diff changeset
   380
{
e4995ae256a7 Moved ZIP tree management up to a higher level, to be reused elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents: 1460
diff changeset
   381
    __PHYSFS_DirTreeEntry *root;    /* root of directory tree.             */
e4995ae256a7 Moved ZIP tree management up to a higher level, to be reused elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents: 1460
diff changeset
   382
    __PHYSFS_DirTreeEntry **hash;  /* all entries hashed for fast lookup. */
e4995ae256a7 Moved ZIP tree management up to a higher level, to be reused elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents: 1460
diff changeset
   383
    size_t hashBuckets;            /* number of buckets in hash.          */
e4995ae256a7 Moved ZIP tree management up to a higher level, to be reused elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents: 1460
diff changeset
   384
    size_t entrylen;    /* size in bytes of entries (including subclass). */
e4995ae256a7 Moved ZIP tree management up to a higher level, to be reused elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents: 1460
diff changeset
   385
} __PHYSFS_DirTree;
e4995ae256a7 Moved ZIP tree management up to a higher level, to be reused elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents: 1460
diff changeset
   386
e4995ae256a7 Moved ZIP tree management up to a higher level, to be reused elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents: 1460
diff changeset
   387
1494
4e2c7ce9bf11 DirTrees and unpacked archives shouldn't demand a count of entries for init.
Ryan C. Gordon <icculus@icculus.org>
parents: 1467
diff changeset
   388
int __PHYSFS_DirTreeInit(__PHYSFS_DirTree *dt, const size_t entrylen);
1462
e4995ae256a7 Moved ZIP tree management up to a higher level, to be reused elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents: 1460
diff changeset
   389
void *__PHYSFS_DirTreeAdd(__PHYSFS_DirTree *dt, char *name, const int isdir);
e4995ae256a7 Moved ZIP tree management up to a higher level, to be reused elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents: 1460
diff changeset
   390
void *__PHYSFS_DirTreeFind(__PHYSFS_DirTree *dt, const char *path);
1591
97d3641bfba3 Make PHYSFS_EnumerateCallback return an enum instead of an int.
Ryan C. Gordon <icculus@icculus.org>
parents: 1590
diff changeset
   391
PHYSFS_EnumerateCallbackResult __PHYSFS_DirTreeEnumerate(void *opaque,
97d3641bfba3 Make PHYSFS_EnumerateCallback return an enum instead of an int.
Ryan C. Gordon <icculus@icculus.org>
parents: 1590
diff changeset
   392
                              const char *dname, PHYSFS_EnumerateCallback cb,
1559
aaee2b83291f Reworked enumeration to be more powerful.
Ryan C. Gordon <icculus@icculus.org>
parents: 1558
diff changeset
   393
                              const char *origdir, void *callbackdata);
1462
e4995ae256a7 Moved ZIP tree management up to a higher level, to be reused elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents: 1460
diff changeset
   394
void __PHYSFS_DirTreeDeinit(__PHYSFS_DirTree *dt);
e4995ae256a7 Moved ZIP tree management up to a higher level, to be reused elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents: 1460
diff changeset
   395
e4995ae256a7 Moved ZIP tree management up to a higher level, to be reused elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents: 1460
diff changeset
   396
e4995ae256a7 Moved ZIP tree management up to a higher level, to be reused elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents: 1460
diff changeset
   397
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   398
/*--------------------------------------------------------------------------*/
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   399
/*--------------------------------------------------------------------------*/
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   400
/*------------                                              ----------------*/
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   401
/*------------  You MUST implement the following functions  ----------------*/
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   402
/*------------        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
   403
/*------------     (see platform/unix.c for an example)     ----------------*/
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   404
/*------------                                              ----------------*/
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   405
/*--------------------------------------------------------------------------*/
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   406
/*--------------------------------------------------------------------------*/
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   407
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   408
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   409
/*
1225
671d4ea47c13 Make __PHYSFS_platformDirSeparator into a single char.
Ryan C. Gordon <icculus@icculus.org>
parents: 1224
diff changeset
   410
 * 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
   411
 *  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
   412
 *  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
   413
 */
1516
ec5acd7392a2 Some minor preprocessor nitpicks.
Ryan C. Gordon <icculus@icculus.org>
parents: 1512
diff changeset
   414
#if defined(PHYSFS_PLATFORM_WINDOWS) || defined(PHYSFS_PLATFORM_OS2)
1225
671d4ea47c13 Make __PHYSFS_platformDirSeparator into a single char.
Ryan C. Gordon <icculus@icculus.org>
parents: 1224
diff changeset
   415
#define __PHYSFS_platformDirSeparator '\\'
671d4ea47c13 Make __PHYSFS_platformDirSeparator into a single char.
Ryan C. Gordon <icculus@icculus.org>
parents: 1224
diff changeset
   416
#else
1581
ad04b99afb88 Fixed some warnings that Xcode brought up.
Ryan C. Gordon <icculus@icculus.org>
parents: 1576
diff changeset
   417
#define __PHYSFS_STANDARD_DIRSEP 1
1225
671d4ea47c13 Make __PHYSFS_platformDirSeparator into a single char.
Ryan C. Gordon <icculus@icculus.org>
parents: 1224
diff changeset
   418
#define __PHYSFS_platformDirSeparator '/'
671d4ea47c13 Make __PHYSFS_platformDirSeparator into a single char.
Ryan C. Gordon <icculus@icculus.org>
parents: 1224
diff changeset
   419
#endif
130
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   420
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   421
/*
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   422
 * 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
   423
 *  the application.
130
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   424
 *
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   425
 * 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
   426
 *  functioning at all), and non-zero otherwise.
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   427
 */
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   428
int __PHYSFS_platformInit(void);
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   429
240
052041af9001 Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents: 172
diff changeset
   430
130
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   431
/*
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   432
 * 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
   433
 *  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
   434
 *  allocated in your platform driver.
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   435
 */
1536
c791c9aaa2a2 __PHYSFS_platformDeinit() should return void.
Ryan C. Gordon <icculus@icculus.org>
parents: 1518
diff changeset
   436
void __PHYSFS_platformDeinit(void);
130
2deec3eb7430 Added __PHYSFS_platformInit() and __PHYSFS_platformDeinit().
Ryan C. Gordon <icculus@icculus.org>
parents: 126
diff changeset
   437
240
052041af9001 Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents: 172
diff changeset
   438
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   439
/*
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   440
 * 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
   441
 *  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
   442
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   443
 * 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
   444
 *  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
   445
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   446
 * 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
   447
 *  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
   448
 *  conditions in the archivers.
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   449
 *
1328
a5314f07614a Remove __PHYSFS_setError(), use the new public API instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1327
diff changeset
   450
 * 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
   451
 */
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   452
void *__PHYSFS_platformOpenRead(const char *filename);
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   453
240
052041af9001 Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents: 172
diff changeset
   454
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   455
/*
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   456
 * 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
   457
 *  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
   458
 *  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
   459
 *  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
   460
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   461
 * 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
   462
 *  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
   463
 *  etc.
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   464
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   465
 * 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
   466
 *
1328
a5314f07614a Remove __PHYSFS_setError(), use the new public API instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1327
diff changeset
   467
 * 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
   468
 */
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   469
void *__PHYSFS_platformOpenWrite(const char *filename);
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   470
240
052041af9001 Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents: 172
diff changeset
   471
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   472
/*
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   473
 * 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
   474
 *  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
   475
 *  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
   476
 *  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
   477
 *  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
   478
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   479
 * 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
   480
 *  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
   481
 *  etc.
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   482
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   483
 * 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
   484
 *
1328
a5314f07614a Remove __PHYSFS_setError(), use the new public API instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1327
diff changeset
   485
 * 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
   486
 */
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   487
void *__PHYSFS_platformOpenAppend(const char *filename);
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   488
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   489
/*
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   490
 * 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
   491
 *  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
   492
 *  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
   493
 *  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
   494
 *  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
   495
 *  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
   496
 *  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
   497
 *  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
   498
 *  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
   499
 *  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
   500
 *  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
   501
 */
1098
4e86cec1143f Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents: 1097
diff changeset
   502
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
   503
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   504
/*
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   505
 * 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
   506
 *  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
   507
 *  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
   508
 *  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
   509
 *  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
   510
 *  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
   511
 *  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
   512
 *  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
   513
 *  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
   514
 */
134
eb030f2e342a Fixed a const thing.
Ryan C. Gordon <icculus@icculus.org>
parents: 132
diff changeset
   515
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
   516
                                     PHYSFS_uint64 len);
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   517
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   518
/*
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   519
 * 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
   520
 *  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
   521
 *  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
   522
 *  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
   523
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   524
 * 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
   525
 *
1328
a5314f07614a Remove __PHYSFS_setError(), use the new public API instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1327
diff changeset
   526
 * 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
   527
 *  a non-zero value.
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   528
 */
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   529
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
   530
240
052041af9001 Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents: 172
diff changeset
   531
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   532
/*
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   533
 * 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
   534
 *  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
   535
 *  uses.
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   536
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   537
 * 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
   538
 *
1328
a5314f07614a Remove __PHYSFS_setError(), use the new public API instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1327
diff changeset
   539
 * 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
   540
 */
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   541
PHYSFS_sint64 __PHYSFS_platformTell(void *opaque);
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   542
240
052041af9001 Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents: 172
diff changeset
   543
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   544
/*
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   545
 * 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
   546
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   547
 * 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
   548
 *  file types on all platforms.
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   549
 *
1328
a5314f07614a Remove __PHYSFS_setError(), use the new public API instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1327
diff changeset
   550
 * 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
   551
 *  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
   552
 */
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   553
PHYSFS_sint64 __PHYSFS_platformFileLength(void *handle);
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   554
1054
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   555
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   556
/*
1568
9e0c6ceefd41 Filled in more documentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 1567
diff changeset
   557
 * Read filesystem metadata for a specific path.
9e0c6ceefd41 Filled in more documentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 1567
diff changeset
   558
 *
9e0c6ceefd41 Filled in more documentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 1567
diff changeset
   559
 * This needs to fill in all the fields of (stat). For fields that might not
9e0c6ceefd41 Filled in more documentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 1567
diff changeset
   560
 *  mean anything on a platform (access time, perhaps), choose a reasonable
1620
f3459eaad51b Fixed mounting a symlink to a real directory.
Ryan C. Gordon <icculus@icculus.org>
parents: 1591
diff changeset
   561
 *  default. if (follow), we want to follow symlinks and stat what they
f3459eaad51b Fixed mounting a symlink to a real directory.
Ryan C. Gordon <icculus@icculus.org>
parents: 1591
diff changeset
   562
 *  link to and not the link itself.
1568
9e0c6ceefd41 Filled in more documentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 1567
diff changeset
   563
 *
9e0c6ceefd41 Filled in more documentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 1567
diff changeset
   564
 *  Return zero on failure, non-zero on success.
1054
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   565
 */
1620
f3459eaad51b Fixed mounting a symlink to a real directory.
Ryan C. Gordon <icculus@icculus.org>
parents: 1591
diff changeset
   566
int __PHYSFS_platformStat(const char *fn, PHYSFS_Stat *stat, const int follow);
1054
57f4af811ffb THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents: 1053
diff changeset
   567
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   568
/*
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   569
 * 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
   570
 *  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
   571
 *  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
   572
 *
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   573
 *  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
   574
 */
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   575
int __PHYSFS_platformFlush(void *opaque);
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   576
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   577
/*
1118
2e09fc635fdd Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1115
diff changeset
   578
 * 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
   579
 *  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
   580
 *  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
   581
 *
1118
2e09fc635fdd Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1115
diff changeset
   582
 * 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
   583
 *  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
   584
 */
1118
2e09fc635fdd Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1115
diff changeset
   585
void __PHYSFS_platformClose(void *opaque);
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   586
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   587
/*
657
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   588
 * 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
   589
 *  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
   590
 *  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
   591
 *  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
   592
 *  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
   593
 */
657
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   594
void __PHYSFS_platformDetectAvailableCDs(PHYSFS_StringCallback cb, void *data);
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   595
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   596
/*
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   597
 * 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
   598
 *  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
   599
 *  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
   600
 * 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
   601
 *  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
   602
 */
23
bd6ba9c8717c Initial debugging: dropped PhysicsFS routines into the Build engine,
Ryan C. Gordon <icculus@icculus.org>
parents: 22
diff changeset
   603
char *__PHYSFS_platformCalcBaseDir(const char *argv0);
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   604
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   605
/*
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   606
 * Get the platform-specific user dir.
1266
135cb99a06a0 More FIXME cleanup.
Ryan C. Gordon <icculus@icculus.org>
parents: 1264
diff changeset
   607
 * As of PhysicsFS 2.1, returning NULL means fatal error.
135cb99a06a0 More FIXME cleanup.
Ryan C. Gordon <icculus@icculus.org>
parents: 1264
diff changeset
   608
 * 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
   609
 *  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
   610
 */
1248
632895970ed6 Cleaned up some FIXMEs.
Ryan C. Gordon <icculus@icculus.org>
parents: 1246
diff changeset
   611
char *__PHYSFS_platformCalcUserDir(void);
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   612
1242
1e6db80d2393 Added PHYSFS_getPrefDir().
Ryan C. Gordon <icculus@icculus.org>
parents: 1240
diff changeset
   613
1e6db80d2393 Added PHYSFS_getPrefDir().
Ryan C. Gordon <icculus@icculus.org>
parents: 1240
diff changeset
   614
/* 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
   615
const char *__PHYSFS_getUserDir(void);  /* not deprecated internal version. */
1e6db80d2393 Added PHYSFS_getPrefDir().
Ryan C. Gordon <icculus@icculus.org>
parents: 1240
diff changeset
   616
1266
135cb99a06a0 More FIXME cleanup.
Ryan C. Gordon <icculus@icculus.org>
parents: 1264
diff changeset
   617
1242
1e6db80d2393 Added PHYSFS_getPrefDir().
Ryan C. Gordon <icculus@icculus.org>
parents: 1240
diff changeset
   618
/*
1266
135cb99a06a0 More FIXME cleanup.
Ryan C. Gordon <icculus@icculus.org>
parents: 1264
diff changeset
   619
 * Get the platform-specific pref dir.
135cb99a06a0 More FIXME cleanup.
Ryan C. Gordon <icculus@icculus.org>
parents: 1264
diff changeset
   620
 * Returning NULL means fatal error.
135cb99a06a0 More FIXME cleanup.
Ryan C. Gordon <icculus@icculus.org>
parents: 1264
diff changeset
   621
 * 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
   622
 *  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
   623
 *  Caller will make missing directories if necessary; this just reports
135cb99a06a0 More FIXME cleanup.
Ryan C. Gordon <icculus@icculus.org>
parents: 1264
diff changeset
   624
 *   the final path.
1242
1e6db80d2393 Added PHYSFS_getPrefDir().
Ryan C. Gordon <icculus@icculus.org>
parents: 1240
diff changeset
   625
 */
1e6db80d2393 Added PHYSFS_getPrefDir().
Ryan C. Gordon <icculus@icculus.org>
parents: 1240
diff changeset
   626
char *__PHYSFS_platformCalcPrefDir(const char *org, const char *app);
1e6db80d2393 Added PHYSFS_getPrefDir().
Ryan C. Gordon <icculus@icculus.org>
parents: 1240
diff changeset
   627
1e6db80d2393 Added PHYSFS_getPrefDir().
Ryan C. Gordon <icculus@icculus.org>
parents: 1240
diff changeset
   628
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   629
/*
1012
f254870dd7dd Attempt to clean up the thread ID mess in platform_unix ...
Ryan C. Gordon <icculus@icculus.org>
parents: 984
diff changeset
   630
 * 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
   631
 *  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
   632
 *  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
   633
 *  pointer.
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   634
 */
1012
f254870dd7dd Attempt to clean up the thread ID mess in platform_unix ...
Ryan C. Gordon <icculus@icculus.org>
parents: 984
diff changeset
   635
void *__PHYSFS_platformGetThreadID(void);
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   636
240
052041af9001 Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents: 172
diff changeset
   637
20
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   638
/*
efdde0d21521 Implementation compiles and links with no actual archive support. No test
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
   639
 * Enumerate a directory of files. This follows the rules for the
1559
aaee2b83291f Reworked enumeration to be more powerful.
Ryan C. Gordon <icculus@icculus.org>
parents: 1558
diff changeset
   640
 *  PHYSFS_Archiver::enumerate() method, except that the (dirName) that is
aaee2b83291f Reworked enumeration to be more powerful.
Ryan C. Gordon <icculus@icculus.org>
parents: 1558
diff changeset
   641
 *  passed to this function is converted to platform-DEPENDENT notation by
aaee2b83291f Reworked enumeration to be more powerful.
Ryan C. Gordon <icculus@icculus.org>
parents: 1558
diff changeset
   642
 *  the caller. The PHYSFS_Archiver version uses platform-independent
aaee2b83291f Reworked enumeration to be more powerful.
Ryan C. Gordon <icculus@icculus.org>
parents: 1558
diff changeset
   643
 *  notation. Note that ".", "..", and other meta-entries should always
aaee2b83291f Reworked enumeration to be more powerful.
Ryan C. Gordon <icculus@icculus.org>
parents: 1558
diff changeset
   644
 *  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
   645
 */
1591
97d3641bfba3 Make PHYSFS_EnumerateCallback return an enum instead of an int.
Ryan C. Gordon <icculus@icculus.org>
parents: 1590
diff changeset
   646
PHYSFS_EnumerateCallbackResult __PHYSFS_platformEnumerate(const char *dirname,
1559
aaee2b83291f Reworked enumeration to be more powerful.
Ryan C. Gordon <icculus@icculus.org>
parents: 1558
diff changeset
   647
                               PHYSFS_EnumerateCallback callback,
aaee2b83291f Reworked enumeration to be more powerful.
Ryan C. Gordon <icculus@icculus.org>
parents: 1558
diff changeset
   648
                               const char *origdir, 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
   649
39
bc29e1ee7ef6 Lots of bugfixes, enhancements, and corrections due to the work on
Ryan C. Gordon <icculus@icculus.org>
parents: 30
diff changeset
   650
/*
69
546a95cc5591 Updates, corrections and enhancements to get this ported to win32.
Ryan C. Gordon <icculus@icculus.org>
parents: 49
diff changeset
   651
 * 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
   652
 *  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
   653
 *  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
   654
 */
546a95cc5591 Updates, corrections and enhancements to get this ported to win32.
Ryan C. Gordon <icculus@icculus.org>
parents: 49
diff changeset
   655
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
   656
240
052041af9001 Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents: 172
diff changeset
   657
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
   658
/*
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
   659
 * 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
   660
 *  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
   661
 *  _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
   662
 *  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
   663
 *  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
   664
 *
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
   665
 * 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
   666
 *
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
   667
 * 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
   668
 */
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
   669
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
   670
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
   671
145
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   672
/*
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   673
 * 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
   674
 *  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
   675
 *
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   676
 * 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
   677
 *  return any arbitrary non-NULL value.
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   678
 */
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   679
void *__PHYSFS_platformCreateMutex(void);
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   680
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   681
/*
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   682
 * 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
   683
 *  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
   684
 *  __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
   685
 *  platforms.
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   686
 */
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   687
void __PHYSFS_platformDestroyMutex(void *mutex);
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   688
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   689
/*
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   690
 * 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
   691
 *  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
   692
 *  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
   693
 *  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
   694
 *
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   695
 * 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
   696
 *  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
   697
 *  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
   698
 *  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
   699
 *
1328
a5314f07614a Remove __PHYSFS_setError(), use the new public API instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1327
diff changeset
   700
 * _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
   701
 *  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
   702
 *  use the BAIL_*MACRO* macros, either.
145
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   703
 */
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   704
int __PHYSFS_platformGrabMutex(void *mutex);
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   705
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   706
/*
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   707
 * 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
   708
 *  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
   709
 *  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
   710
 *  proceed.
156
f45e26b5f398 Added warning about potential infinite recursion between setError and grabMutex.
Ryan C. Gordon <icculus@icculus.org>
parents: 150
diff changeset
   711
 *
1328
a5314f07614a Remove __PHYSFS_setError(), use the new public API instead.
Ryan C. Gordon <icculus@icculus.org>
parents: 1327
diff changeset
   712
 * _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
   713
 *  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
   714
 *  use the BAIL_*MACRO* macros, either.
145
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   715
 */
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   716
void __PHYSFS_platformReleaseMutex(void *mutex);
d6385584f6c4 First shot at thread-safety.
Ryan C. Gordon <icculus@icculus.org>
parents: 137
diff changeset
   717
1449
6df9e1a43f7c Cleaned up what symbols are exported from the library.
Ryan C. Gordon <icculus@icculus.org>
parents: 1442
diff changeset
   718
#if PHYSFS_HAVE_PRAGMA_VISIBILITY
6df9e1a43f7c Cleaned up what symbols are exported from the library.
Ryan C. Gordon <icculus@icculus.org>
parents: 1442
diff changeset
   719
#pragma GCC visibility pop
6df9e1a43f7c Cleaned up what symbols are exported from the library.
Ryan C. Gordon <icculus@icculus.org>
parents: 1442
diff changeset
   720
#endif
6df9e1a43f7c Cleaned up what symbols are exported from the library.
Ryan C. Gordon <icculus@icculus.org>
parents: 1442
diff changeset
   721
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   722
#ifdef __cplusplus
132
b53fa5093749 Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents: 130
diff changeset
   723
}
9
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   724
#endif
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   725
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   726
#endif
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   727
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   728
/* end of physfs_internal.h ... */
1155788ccbe3 Initial add. Ways to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   729