misc/libphyslayer/physfsrwops.c
author koda
Wed, 27 Feb 2013 16:14:24 +0100
branchphysfslayer
changeset 8561 c3bc61f21874
parent 8524 a65e9bcf0a03
child 9309 7e8f91634f80
permissions -rw-r--r--
close thei branch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7768
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     1
/*
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     2
 * This code provides a glue layer between PhysicsFS and Simple Directmedia
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     3
 *  Layer's (SDL) RWops i/o abstraction.
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     4
 *
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     5
 * License: this code is public domain. I make no warranty that it is useful,
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     6
 *  correct, harmless, or environmentally safe.
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     7
 *
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     8
 * This particular file may be used however you like, including copying it
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     9
 *  verbatim into a closed-source project, exploiting it commercially, and
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    10
 *  removing any trace of my name from the source (although I hope you won't
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    11
 *  do that). I welcome enhancements and corrections to this file, but I do
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    12
 *  not require you to send me patches if you make changes. This code has
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    13
 *  NO WARRANTY.
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    14
 *
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    15
 * Unless otherwise stated, the rest of PhysicsFS falls under the zlib license.
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    16
 *  Please see LICENSE.txt in the root of the source tree.
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    17
 *
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    18
 * SDL 1.2 falls under the LGPL license. SDL 1.3+ is zlib, like PhysicsFS.
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    19
 *  You can get SDL at http://www.libsdl.org/
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    20
 *
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    21
 *  This file was written by Ryan C. Gordon. (icculus@icculus.org).
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    22
 */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    23
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    24
#include <stdio.h>  /* used for SEEK_SET, SEEK_CUR, SEEK_END ... */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    25
#include "physfsrwops.h"
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    26
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    27
/* SDL's RWOPS interface changed a little in SDL 1.3... */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    28
#if defined(SDL_VERSION_ATLEAST)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    29
#if SDL_VERSION_ATLEAST(1, 3, 0)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    30
#define TARGET_SDL13 1
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    31
#endif
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    32
#endif
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    33
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    34
#if TARGET_SDL13
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    35
static long SDLCALL physfsrwops_seek(struct SDL_RWops *rw, long offset, int whence)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    36
#else
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    37
static int physfsrwops_seek(SDL_RWops *rw, int offset, int whence)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    38
#endif
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    39
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    40
    PHYSFS_File *handle = (PHYSFS_File *) rw->hidden.unknown.data1;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    41
    PHYSFS_sint64 pos = 0;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    42
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    43
    if (whence == SEEK_SET)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    44
        pos = (PHYSFS_sint64) offset;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    45
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    46
    else if (whence == SEEK_CUR)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    47
    {
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    48
        const PHYSFS_sint64 current = PHYSFS_tell(handle);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    49
        if (current == -1)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    50
        {
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    51
            SDL_SetError("Can't find position in file: %s",
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    52
                          PHYSFS_getLastError());
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    53
            return -1;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    54
        } /* if */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    55
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    56
        if (offset == 0)  /* this is a "tell" call. We're done. */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    57
        {
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    58
            #if TARGET_SDL13
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    59
            return (long) current;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    60
            #else
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    61
            return (int) current;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    62
            #endif
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    63
        } /* if */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    64
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    65
        pos = current + ((PHYSFS_sint64) offset);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    66
    } /* else if */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    67
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    68
    else if (whence == SEEK_END)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    69
    {
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    70
        const PHYSFS_sint64 len = PHYSFS_fileLength(handle);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    71
        if (len == -1)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    72
        {
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    73
            SDL_SetError("Can't find end of file: %s", PHYSFS_getLastError());
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    74
            return -1;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    75
        } /* if */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    76
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    77
        pos = len + ((PHYSFS_sint64) offset);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    78
    } /* else if */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    79
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    80
    else
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    81
    {
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    82
        SDL_SetError("Invalid 'whence' parameter.");
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    83
        return -1;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    84
    } /* else */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    85
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    86
    if ( pos < 0 )
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    87
    {
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    88
        SDL_SetError("Attempt to seek past start of file.");
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    89
        return -1;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    90
    } /* if */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    91
    
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    92
    if (!PHYSFS_seek(handle, (PHYSFS_uint64) pos))
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    93
    {
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    94
        SDL_SetError("PhysicsFS error: %s", PHYSFS_getLastError());
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    95
        return -1;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    96
    } /* if */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    97
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    98
    #if TARGET_SDL13
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    99
    return (long) pos;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   100
    #else
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   101
    return (int) pos;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   102
    #endif
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   103
} /* physfsrwops_seek */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   104
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   105
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   106
#if TARGET_SDL13
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   107
static size_t SDLCALL physfsrwops_read(struct SDL_RWops *rw, void *ptr,
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   108
                                       size_t size, size_t maxnum)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   109
#else
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   110
static int physfsrwops_read(SDL_RWops *rw, void *ptr, int size, int maxnum)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   111
#endif
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   112
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   113
    PHYSFS_File *handle = (PHYSFS_File *) rw->hidden.unknown.data1;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   114
    const PHYSFS_uint64 readlen = (PHYSFS_uint64) (maxnum * size);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   115
    const PHYSFS_sint64 rc = PHYSFS_readBytes(handle, ptr, readlen);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   116
    if (rc != ((PHYSFS_sint64) readlen))
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   117
    {
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   118
        if (!PHYSFS_eof(handle)) /* not EOF? Must be an error. */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   119
            SDL_SetError("PhysicsFS error: %s", PHYSFS_getLastError());
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   120
    } /* if */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   121
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   122
    #if TARGET_SDL13
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   123
    return (size_t) rc;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   124
    #else
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   125
    return (int) rc;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   126
    #endif
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   127
} /* physfsrwops_read */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   128
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   129
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   130
#if TARGET_SDL13
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   131
static size_t SDLCALL physfsrwops_write(struct SDL_RWops *rw, const void *ptr,
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   132
                                        size_t size, size_t num)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   133
#else
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   134
static int physfsrwops_write(SDL_RWops *rw, const void *ptr, int size, int num)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   135
#endif
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   136
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   137
    PHYSFS_File *handle = (PHYSFS_File *) rw->hidden.unknown.data1;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   138
    const PHYSFS_uint64 writelen = (PHYSFS_uint64) (num * size);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   139
    const PHYSFS_sint64 rc = PHYSFS_writeBytes(handle, ptr, writelen);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   140
    if (rc != ((PHYSFS_sint64) writelen))
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   141
        SDL_SetError("PhysicsFS error: %s", PHYSFS_getLastError());
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   142
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   143
    #if TARGET_SDL13
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   144
    return (size_t) rc;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   145
    #else
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   146
    return (int) rc;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   147
    #endif
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   148
} /* physfsrwops_write */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   149
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   150
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   151
static int physfsrwops_close(SDL_RWops *rw)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   152
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   153
    PHYSFS_File *handle = (PHYSFS_File *) rw->hidden.unknown.data1;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   154
    if (!PHYSFS_close(handle))
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   155
    {
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   156
        SDL_SetError("PhysicsFS error: %s", PHYSFS_getLastError());
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   157
        return -1;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   158
    } /* if */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   159
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   160
    SDL_FreeRW(rw);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   161
    return 0;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   162
} /* physfsrwops_close */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   163
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   164
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   165
static SDL_RWops *create_rwops(PHYSFS_File *handle)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   166
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   167
    SDL_RWops *retval = NULL;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   168
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   169
    if (handle == NULL)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   170
        SDL_SetError("PhysicsFS error: %s", PHYSFS_getLastError());
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   171
    else
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   172
    {
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   173
        retval = SDL_AllocRW();
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   174
        if (retval != NULL)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   175
        {
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   176
            retval->seek  = physfsrwops_seek;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   177
            retval->read  = physfsrwops_read;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   178
            retval->write = physfsrwops_write;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   179
            retval->close = physfsrwops_close;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   180
            retval->hidden.unknown.data1 = handle;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   181
        } /* if */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   182
    } /* else */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   183
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   184
    return retval;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   185
} /* create_rwops */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   186
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   187
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   188
SDL_RWops *PHYSFSRWOPS_makeRWops(PHYSFS_File *handle)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   189
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   190
    SDL_RWops *retval = NULL;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   191
    if (handle == NULL)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   192
        SDL_SetError("NULL pointer passed to PHYSFSRWOPS_makeRWops().");
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   193
    else
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   194
        retval = create_rwops(handle);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   195
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   196
    return retval;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   197
} /* PHYSFSRWOPS_makeRWops */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   198
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   199
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   200
SDL_RWops *PHYSFSRWOPS_openRead(const char *fname)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   201
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   202
    return create_rwops(PHYSFS_openRead(fname));
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   203
} /* PHYSFSRWOPS_openRead */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   204
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   205
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   206
SDL_RWops *PHYSFSRWOPS_openWrite(const char *fname)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   207
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   208
    return create_rwops(PHYSFS_openWrite(fname));
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   209
} /* PHYSFSRWOPS_openWrite */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   210
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   211
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   212
SDL_RWops *PHYSFSRWOPS_openAppend(const char *fname)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   213
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   214
    return create_rwops(PHYSFS_openAppend(fname));
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   215
} /* PHYSFSRWOPS_openAppend */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   216
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   217
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   218
/* end of physfsrwops.c ... */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   219