extras/physfsrwops.h
author Ryan C. Gordon <icculus@icculus.org>
Sat, 16 Mar 2002 03:51:09 +0000
changeset 123 53305c50c541
child 132 b53fa5093749
permissions -rw-r--r--
Initial add.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
123
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     1
/*
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     2
 * This code provides a glue layer between PhysicsFS and Simple Directmedia
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     3
 *  Layer's (SDL) RWops i/o abstraction.
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     4
 *
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     5
 * License: this code is public domain. I make no warranty that it is useful,
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     6
 *  correct, harmless, or environmentally safe.
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     7
 *
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     8
 * This particular file may be used however you like, including copying it
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     9
 *  verbatim into a closed-source project, exploiting it commercially, and
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    10
 *  removing any trace of my name from the source (although I hope you won't
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    11
 *  do that). I welcome enhancements and corrections to this file, but I do
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    12
 *  not require you to send me patches if you make changes.
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    13
 *
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    14
 * Unless otherwise stated, the rest of PhysicsFS falls under the GNU Lesser
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    15
 *  General Public License: http://www.gnu.org/licenses/lgpl.txt
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    16
 *
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    17
 * SDL falls under the LGPL, too. You can get SDL at http://www.libsdl.org/
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    18
 *
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    19
 *  This file was written by Ryan C. Gordon. (icculus@clutteredmind.org).
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    20
 */
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    21
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    22
#ifndef _INCLUDE_PHYSFSRWOPS_H_
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    23
#define _INCLUDE_PHYSFSRWOPS_H_
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    24
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    25
#include "physfs.h"
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    26
#include "SDL.h"
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    27
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    28
#ifdef __cplusplus
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    29
extern "C" {
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    30
#endif
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    31
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    32
#if (defined _MSC_VER)
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    33
#define __EXPORT__ __declspec(dllexport)
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    34
#else
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    35
#define __EXPORT__
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    36
#endif
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    37
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    38
/**
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    39
 * Open a platform-independent filename for reading, and make it accessible
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    40
 *  via an SDL_RWops structure. The file will be closed in PhysicsFS when the
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    41
 *  RWops is closed. PhysicsFS should be configured to your liking before
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    42
 *  opening files through this method.
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    43
 *
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    44
 *   @param filename File to open in platform-independent notation.
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    45
 *  @return A valid SDL_RWops structure on success, NULL on error. Specifics
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    46
 *           of the error can be gleaned from PHYSFS_getLastError().
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    47
 */
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    48
__EXPORT__ SDL_RWops *PHYSFSRWOPS_openRead(const char *fname);
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    49
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    50
/**
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    51
 * Open a platform-independent filename for writing, and make it accessible
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    52
 *  via an SDL_RWops structure. The file will be closed in PhysicsFS when the
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    53
 *  RWops is closed. PhysicsFS should be configured to your liking before
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    54
 *  opening files through this method.
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    55
 *
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    56
 *   @param filename File to open in platform-independent notation.
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    57
 *  @return A valid SDL_RWops structure on success, NULL on error. Specifics
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    58
 *           of the error can be gleaned from PHYSFS_getLastError().
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    59
 */
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    60
__EXPORT__ SDL_RWops *PHYSFSRWOPS_openWrite(const char *fname);
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    61
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    62
/**
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    63
 * Open a platform-independent filename for appending, and make it accessible
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    64
 *  via an SDL_RWops structure. The file will be closed in PhysicsFS when the
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    65
 *  RWops is closed. PhysicsFS should be configured to your liking before
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    66
 *  opening files through this method.
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    67
 *
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    68
 *   @param filename File to open in platform-independent notation.
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    69
 *  @return A valid SDL_RWops structure on success, NULL on error. Specifics
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    70
 *           of the error can be gleaned from PHYSFS_getLastError().
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    71
 */
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    72
__EXPORT__ SDL_RWops *PHYSFSRWOPS_openAppend(const char *fname);
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    73
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    74
/**
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    75
 * Make a SDL_RWops from an existing PhysicsFS file handle. You should
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    76
 *  dispose of any references to the handle after successful creation of
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    77
 *  the RWops. The actual PhysicsFS handle will be destroyed when the
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    78
 *  RWops is closed.
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    79
 *
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    80
 *   @param handle a valid PhysicsFS file handle.
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    81
 *  @return A valid SDL_RWops structure on success, NULL on error. Specifics
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    82
 *           of the error can be gleaned from PHYSFS_getLastError().
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    83
 */
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    84
__EXPORT__ SDL_RWops *PHYSFSRWOPS_makeRWops(PHYSFS_file *handle);
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    85
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    86
#ifdef __cplusplus
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    87
}
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    88
#endif
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    89
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    90
#endif /* include-once blocker */
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    91
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    92
/* end of physfsrwops.h ... */
53305c50c541 Initial add.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    93