misc/libphysfs/archiver_dir.c
author Wuzzy <Wuzzy2@mail.ru>
Tue, 31 Jul 2018 22:40:23 +0200
changeset 13581 9c8749bb0d06
parent 12213 bb5522e88ab2
permissions -rw-r--r--
Clean up Tumbler captions a bit
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
 * Standard directory I/O support routines for PhysicsFS.
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     3
 *
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     4
 * Please see the file LICENSE.txt in the source's root directory.
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     5
 *
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     6
 *  This file written by Ryan C. Gordon.
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     7
 */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     8
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     9
#define __PHYSICSFS_INTERNAL__
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    10
#include "physfs_internal.h"
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    11
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    12
/* There's no PHYSFS_Io interface here. Use __PHYSFS_createNativeIo(). */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    13
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    14
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    15
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    16
static char *cvtToDependent(const char *prepend, const char *path, char *buf)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    17
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    18
    BAIL_IF_MACRO(buf == NULL, PHYSFS_ERR_OUT_OF_MEMORY, NULL);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    19
    sprintf(buf, "%s%s", prepend ? prepend : "", path);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    20
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    21
    if (__PHYSFS_platformDirSeparator != '/')
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    22
    {
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    23
        char *p;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    24
        for (p = strchr(buf, '/'); p != NULL; p = strchr(p + 1, '/'))
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    25
            *p = __PHYSFS_platformDirSeparator;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    26
    } /* if */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    27
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    28
    return buf;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    29
} /* cvtToDependent */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    30
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    31
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    32
#define CVT_TO_DEPENDENT(buf, pre, dir) { \
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    33
    const size_t len = ((pre) ? strlen((char *) pre) : 0) + strlen(dir) + 1; \
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    34
    buf = cvtToDependent((char*)pre,dir,(char*)__PHYSFS_smallAlloc(len)); \
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    35
}
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    36
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    37
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    38
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    39
static void *DIR_openArchive(PHYSFS_Io *io, const char *name, int forWriting)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    40
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    41
    PHYSFS_Stat st;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    42
    const char dirsep = __PHYSFS_platformDirSeparator;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    43
    char *retval = NULL;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    44
    const size_t namelen = strlen(name);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    45
    const size_t seplen = 1;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    46
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    47
    assert(io == NULL);  /* shouldn't create an Io for these. */
12213
bb5522e88ab2 bulk copy of latest physfs to our misc/libphysfs since this seems to fix an off-by-1 error reliably hit in readln read of 1 byte probably introduced in the addition of the buffered read. Whether this is excessive or whether libphysfs should even be maintained by us is another matter. But at least we shouldn't crash
nemo
parents: 8524
diff changeset
    48
    BAIL_IF_MACRO(!__PHYSFS_platformStat(name, &st), ERRPASS, NULL);
7768
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    49
    if (st.filetype != PHYSFS_FILETYPE_DIRECTORY)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    50
        BAIL_MACRO(PHYSFS_ERR_UNSUPPORTED, NULL);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    51
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    52
    retval = allocator.Malloc(namelen + seplen + 1);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    53
    BAIL_IF_MACRO(retval == NULL, PHYSFS_ERR_OUT_OF_MEMORY, NULL);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    54
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    55
    strcpy(retval, name);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    56
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    57
    /* make sure there's a dir separator at the end of the string */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    58
    if (retval[namelen - 1] != dirsep)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    59
    {
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    60
        retval[namelen] = dirsep;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    61
        retval[namelen + 1] = '\0';
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    62
    } /* if */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    63
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    64
    return retval;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    65
} /* DIR_openArchive */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    66
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    67
12213
bb5522e88ab2 bulk copy of latest physfs to our misc/libphysfs since this seems to fix an off-by-1 error reliably hit in readln read of 1 byte probably introduced in the addition of the buffered read. Whether this is excessive or whether libphysfs should even be maintained by us is another matter. But at least we shouldn't crash
nemo
parents: 8524
diff changeset
    68
static void DIR_enumerateFiles(void *opaque, const char *dname,
bb5522e88ab2 bulk copy of latest physfs to our misc/libphysfs since this seems to fix an off-by-1 error reliably hit in readln read of 1 byte probably introduced in the addition of the buffered read. Whether this is excessive or whether libphysfs should even be maintained by us is another matter. But at least we shouldn't crash
nemo
parents: 8524
diff changeset
    69
                               PHYSFS_EnumFilesCallback cb,
7768
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    70
                               const char *origdir, void *callbackdata)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    71
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    72
    char *d;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    73
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    74
    CVT_TO_DEPENDENT(d, opaque, dname);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    75
    if (d != NULL)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    76
    {
12213
bb5522e88ab2 bulk copy of latest physfs to our misc/libphysfs since this seems to fix an off-by-1 error reliably hit in readln read of 1 byte probably introduced in the addition of the buffered read. Whether this is excessive or whether libphysfs should even be maintained by us is another matter. But at least we shouldn't crash
nemo
parents: 8524
diff changeset
    77
        __PHYSFS_platformEnumerateFiles(d, cb, origdir, callbackdata);
7768
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    78
        __PHYSFS_smallFree(d);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    79
    } /* if */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    80
} /* DIR_enumerateFiles */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    81
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    82
12213
bb5522e88ab2 bulk copy of latest physfs to our misc/libphysfs since this seems to fix an off-by-1 error reliably hit in readln read of 1 byte probably introduced in the addition of the buffered read. Whether this is excessive or whether libphysfs should even be maintained by us is another matter. But at least we shouldn't crash
nemo
parents: 8524
diff changeset
    83
static PHYSFS_Io *doOpen(void *opaque, const char *name, const int mode)
7768
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    84
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    85
    PHYSFS_Io *io = NULL;
12213
bb5522e88ab2 bulk copy of latest physfs to our misc/libphysfs since this seems to fix an off-by-1 error reliably hit in readln read of 1 byte probably introduced in the addition of the buffered read. Whether this is excessive or whether libphysfs should even be maintained by us is another matter. But at least we shouldn't crash
nemo
parents: 8524
diff changeset
    86
    char *f = NULL;
7768
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    87
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    88
    CVT_TO_DEPENDENT(f, opaque, name);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    89
    BAIL_IF_MACRO(!f, ERRPASS, NULL);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    90
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    91
    io = __PHYSFS_createNativeIo(f, mode);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    92
    if (io == NULL)
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    93
    {
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    94
        const PHYSFS_ErrorCode err = PHYSFS_getLastErrorCode();
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    95
        PHYSFS_Stat statbuf;
12213
bb5522e88ab2 bulk copy of latest physfs to our misc/libphysfs since this seems to fix an off-by-1 error reliably hit in readln read of 1 byte probably introduced in the addition of the buffered read. Whether this is excessive or whether libphysfs should even be maintained by us is another matter. But at least we shouldn't crash
nemo
parents: 8524
diff changeset
    96
        __PHYSFS_platformStat(f, &statbuf);
bb5522e88ab2 bulk copy of latest physfs to our misc/libphysfs since this seems to fix an off-by-1 error reliably hit in readln read of 1 byte probably introduced in the addition of the buffered read. Whether this is excessive or whether libphysfs should even be maintained by us is another matter. But at least we shouldn't crash
nemo
parents: 8524
diff changeset
    97
        PHYSFS_setErrorCode(err);
7768
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    98
    } /* if */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    99
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   100
    __PHYSFS_smallFree(f);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   101
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   102
    return io;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   103
} /* doOpen */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   104
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   105
12213
bb5522e88ab2 bulk copy of latest physfs to our misc/libphysfs since this seems to fix an off-by-1 error reliably hit in readln read of 1 byte probably introduced in the addition of the buffered read. Whether this is excessive or whether libphysfs should even be maintained by us is another matter. But at least we shouldn't crash
nemo
parents: 8524
diff changeset
   106
static PHYSFS_Io *DIR_openRead(void *opaque, const char *filename)
7768
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   107
{
12213
bb5522e88ab2 bulk copy of latest physfs to our misc/libphysfs since this seems to fix an off-by-1 error reliably hit in readln read of 1 byte probably introduced in the addition of the buffered read. Whether this is excessive or whether libphysfs should even be maintained by us is another matter. But at least we shouldn't crash
nemo
parents: 8524
diff changeset
   108
    return doOpen(opaque, filename, 'r');
7768
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   109
} /* DIR_openRead */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   110
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   111
12213
bb5522e88ab2 bulk copy of latest physfs to our misc/libphysfs since this seems to fix an off-by-1 error reliably hit in readln read of 1 byte probably introduced in the addition of the buffered read. Whether this is excessive or whether libphysfs should even be maintained by us is another matter. But at least we shouldn't crash
nemo
parents: 8524
diff changeset
   112
static PHYSFS_Io *DIR_openWrite(void *opaque, const char *filename)
7768
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   113
{
12213
bb5522e88ab2 bulk copy of latest physfs to our misc/libphysfs since this seems to fix an off-by-1 error reliably hit in readln read of 1 byte probably introduced in the addition of the buffered read. Whether this is excessive or whether libphysfs should even be maintained by us is another matter. But at least we shouldn't crash
nemo
parents: 8524
diff changeset
   114
    return doOpen(opaque, filename, 'w');
7768
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   115
} /* DIR_openWrite */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   116
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   117
12213
bb5522e88ab2 bulk copy of latest physfs to our misc/libphysfs since this seems to fix an off-by-1 error reliably hit in readln read of 1 byte probably introduced in the addition of the buffered read. Whether this is excessive or whether libphysfs should even be maintained by us is another matter. But at least we shouldn't crash
nemo
parents: 8524
diff changeset
   118
static PHYSFS_Io *DIR_openAppend(void *opaque, const char *filename)
7768
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   119
{
12213
bb5522e88ab2 bulk copy of latest physfs to our misc/libphysfs since this seems to fix an off-by-1 error reliably hit in readln read of 1 byte probably introduced in the addition of the buffered read. Whether this is excessive or whether libphysfs should even be maintained by us is another matter. But at least we shouldn't crash
nemo
parents: 8524
diff changeset
   120
    return doOpen(opaque, filename, 'a');
7768
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   121
} /* DIR_openAppend */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   122
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   123
12213
bb5522e88ab2 bulk copy of latest physfs to our misc/libphysfs since this seems to fix an off-by-1 error reliably hit in readln read of 1 byte probably introduced in the addition of the buffered read. Whether this is excessive or whether libphysfs should even be maintained by us is another matter. But at least we shouldn't crash
nemo
parents: 8524
diff changeset
   124
static int DIR_remove(void *opaque, const char *name)
7768
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   125
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   126
    int retval;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   127
    char *f;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   128
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   129
    CVT_TO_DEPENDENT(f, opaque, name);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   130
    BAIL_IF_MACRO(!f, ERRPASS, 0);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   131
    retval = __PHYSFS_platformDelete(f);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   132
    __PHYSFS_smallFree(f);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   133
    return retval;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   134
} /* DIR_remove */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   135
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   136
12213
bb5522e88ab2 bulk copy of latest physfs to our misc/libphysfs since this seems to fix an off-by-1 error reliably hit in readln read of 1 byte probably introduced in the addition of the buffered read. Whether this is excessive or whether libphysfs should even be maintained by us is another matter. But at least we shouldn't crash
nemo
parents: 8524
diff changeset
   137
static int DIR_mkdir(void *opaque, const char *name)
7768
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   138
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   139
    int retval;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   140
    char *f;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   141
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   142
    CVT_TO_DEPENDENT(f, opaque, name);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   143
    BAIL_IF_MACRO(!f, ERRPASS, 0);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   144
    retval = __PHYSFS_platformMkDir(f);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   145
    __PHYSFS_smallFree(f);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   146
    return retval;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   147
} /* DIR_mkdir */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   148
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   149
12213
bb5522e88ab2 bulk copy of latest physfs to our misc/libphysfs since this seems to fix an off-by-1 error reliably hit in readln read of 1 byte probably introduced in the addition of the buffered read. Whether this is excessive or whether libphysfs should even be maintained by us is another matter. But at least we shouldn't crash
nemo
parents: 8524
diff changeset
   150
static void DIR_closeArchive(void *opaque)
7768
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   151
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   152
    allocator.Free(opaque);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   153
} /* DIR_closeArchive */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   154
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   155
12213
bb5522e88ab2 bulk copy of latest physfs to our misc/libphysfs since this seems to fix an off-by-1 error reliably hit in readln read of 1 byte probably introduced in the addition of the buffered read. Whether this is excessive or whether libphysfs should even be maintained by us is another matter. But at least we shouldn't crash
nemo
parents: 8524
diff changeset
   156
static int DIR_stat(void *opaque, const char *name, PHYSFS_Stat *stat)
7768
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   157
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   158
    int retval = 0;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   159
    char *d;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   160
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   161
    CVT_TO_DEPENDENT(d, opaque, name);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   162
    BAIL_IF_MACRO(!d, ERRPASS, 0);
12213
bb5522e88ab2 bulk copy of latest physfs to our misc/libphysfs since this seems to fix an off-by-1 error reliably hit in readln read of 1 byte probably introduced in the addition of the buffered read. Whether this is excessive or whether libphysfs should even be maintained by us is another matter. But at least we shouldn't crash
nemo
parents: 8524
diff changeset
   163
    retval = __PHYSFS_platformStat(d, stat);
7768
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   164
    __PHYSFS_smallFree(d);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   165
    return retval;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   166
} /* DIR_stat */
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   167
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   168
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   169
const PHYSFS_Archiver __PHYSFS_Archiver_DIR =
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   170
{
12213
bb5522e88ab2 bulk copy of latest physfs to our misc/libphysfs since this seems to fix an off-by-1 error reliably hit in readln read of 1 byte probably introduced in the addition of the buffered read. Whether this is excessive or whether libphysfs should even be maintained by us is another matter. But at least we shouldn't crash
nemo
parents: 8524
diff changeset
   171
    CURRENT_PHYSFS_ARCHIVER_API_VERSION,
7768
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   172
    {
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   173
        "",
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   174
        "Non-archive, direct filesystem I/O",
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   175
        "Ryan C. Gordon <icculus@icculus.org>",
12213
bb5522e88ab2 bulk copy of latest physfs to our misc/libphysfs since this seems to fix an off-by-1 error reliably hit in readln read of 1 byte probably introduced in the addition of the buffered read. Whether this is excessive or whether libphysfs should even be maintained by us is another matter. But at least we shouldn't crash
nemo
parents: 8524
diff changeset
   176
        "https://icculus.org/physfs/",
bb5522e88ab2 bulk copy of latest physfs to our misc/libphysfs since this seems to fix an off-by-1 error reliably hit in readln read of 1 byte probably introduced in the addition of the buffered read. Whether this is excessive or whether libphysfs should even be maintained by us is another matter. But at least we shouldn't crash
nemo
parents: 8524
diff changeset
   177
        1,  /* supportsSymlinks */
7768
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   178
    },
12213
bb5522e88ab2 bulk copy of latest physfs to our misc/libphysfs since this seems to fix an off-by-1 error reliably hit in readln read of 1 byte probably introduced in the addition of the buffered read. Whether this is excessive or whether libphysfs should even be maintained by us is another matter. But at least we shouldn't crash
nemo
parents: 8524
diff changeset
   179
    DIR_openArchive,
bb5522e88ab2 bulk copy of latest physfs to our misc/libphysfs since this seems to fix an off-by-1 error reliably hit in readln read of 1 byte probably introduced in the addition of the buffered read. Whether this is excessive or whether libphysfs should even be maintained by us is another matter. But at least we shouldn't crash
nemo
parents: 8524
diff changeset
   180
    DIR_enumerateFiles,
bb5522e88ab2 bulk copy of latest physfs to our misc/libphysfs since this seems to fix an off-by-1 error reliably hit in readln read of 1 byte probably introduced in the addition of the buffered read. Whether this is excessive or whether libphysfs should even be maintained by us is another matter. But at least we shouldn't crash
nemo
parents: 8524
diff changeset
   181
    DIR_openRead,
bb5522e88ab2 bulk copy of latest physfs to our misc/libphysfs since this seems to fix an off-by-1 error reliably hit in readln read of 1 byte probably introduced in the addition of the buffered read. Whether this is excessive or whether libphysfs should even be maintained by us is another matter. But at least we shouldn't crash
nemo
parents: 8524
diff changeset
   182
    DIR_openWrite,
bb5522e88ab2 bulk copy of latest physfs to our misc/libphysfs since this seems to fix an off-by-1 error reliably hit in readln read of 1 byte probably introduced in the addition of the buffered read. Whether this is excessive or whether libphysfs should even be maintained by us is another matter. But at least we shouldn't crash
nemo
parents: 8524
diff changeset
   183
    DIR_openAppend,
bb5522e88ab2 bulk copy of latest physfs to our misc/libphysfs since this seems to fix an off-by-1 error reliably hit in readln read of 1 byte probably introduced in the addition of the buffered read. Whether this is excessive or whether libphysfs should even be maintained by us is another matter. But at least we shouldn't crash
nemo
parents: 8524
diff changeset
   184
    DIR_remove,
bb5522e88ab2 bulk copy of latest physfs to our misc/libphysfs since this seems to fix an off-by-1 error reliably hit in readln read of 1 byte probably introduced in the addition of the buffered read. Whether this is excessive or whether libphysfs should even be maintained by us is another matter. But at least we shouldn't crash
nemo
parents: 8524
diff changeset
   185
    DIR_mkdir,
bb5522e88ab2 bulk copy of latest physfs to our misc/libphysfs since this seems to fix an off-by-1 error reliably hit in readln read of 1 byte probably introduced in the addition of the buffered read. Whether this is excessive or whether libphysfs should even be maintained by us is another matter. But at least we shouldn't crash
nemo
parents: 8524
diff changeset
   186
    DIR_stat,
bb5522e88ab2 bulk copy of latest physfs to our misc/libphysfs since this seems to fix an off-by-1 error reliably hit in readln read of 1 byte probably introduced in the addition of the buffered read. Whether this is excessive or whether libphysfs should even be maintained by us is another matter. But at least we shouldn't crash
nemo
parents: 8524
diff changeset
   187
    DIR_closeArchive
7768
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   188
};
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   189
12213
bb5522e88ab2 bulk copy of latest physfs to our misc/libphysfs since this seems to fix an off-by-1 error reliably hit in readln read of 1 byte probably introduced in the addition of the buffered read. Whether this is excessive or whether libphysfs should even be maintained by us is another matter. But at least we shouldn't crash
nemo
parents: 8524
diff changeset
   190
/* end of archiver_dir.c ... */
7768
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
   191