src/physfs_archiver_iso9660.c
author Ryan C. Gordon <icculus@icculus.org>
Sun, 17 May 2020 01:41:52 -0400
changeset 1691 c66c9326b05d
parent 1619 4f1bf89597e5
permissions -rw-r--r--
7z: Make error handling a little more robust.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     1
/*
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     2
 * ISO9660 support routines for PhysicsFS.
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     3
 *
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     4
 * Please see the file LICENSE.txt in the source's root directory.
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     5
 *
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
     6
 *  This file originally written by Christoph Nelles, but was largely
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
     7
 *  rewritten by Ryan C. Gordon (so please harass Ryan about bugs and not
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
     8
 *  Christoph).
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     9
 */
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    10
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    11
/*
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    12
 * Handles CD-ROM disk images (and raw CD-ROM devices).
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    13
 *
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    14
 * Not supported:
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    15
 * - Rock Ridge (needed for sparse files, device nodes and symlinks, etc).
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    16
 * - Non 2048 Sectors
1502
52f70031d9bc Added some TODOs to the ISO9660 code.
Ryan C. Gordon <icculus@icculus.org>
parents: 1500
diff changeset
    17
 * - TRANS.TBL (maps 8.3 filenames on old discs to long filenames).
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    18
 * - Multiextents (4gb max file size without it).
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    19
 * - UDF
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    20
 *
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    21
 * Deviations from the standard
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    22
 * - Ignores mandatory sort order
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    23
 * - Allows various invalid file names
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    24
 *
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    25
 * Problems
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    26
 * - Ambiguities in the standard
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    27
 */
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    28
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    29
#define __PHYSICSFS_INTERNAL__
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    30
#include "physfs_internal.h"
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    31
1258
074d08049aa7 Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents: 1247
diff changeset
    32
#if PHYSFS_SUPPORTS_ISO9660
074d08049aa7 Changed so that this builds a reasonable default with no command line #defines.
Ryan C. Gordon <icculus@icculus.org>
parents: 1247
diff changeset
    33
1498
5977294d8e4b unpacked: let archivers specify create and modified times, hook up to iso9660.
Ryan C. Gordon <icculus@icculus.org>
parents: 1497
diff changeset
    34
#include <time.h>
5977294d8e4b unpacked: let archivers specify create and modified times, hook up to iso9660.
Ryan C. Gordon <icculus@icculus.org>
parents: 1497
diff changeset
    35
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    36
/* ISO9660 often stores values in both big and little endian formats: little
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    37
   first, followed by big. While technically there might be different values
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    38
   in each, we just always use the littleendian ones and swap ourselves. The
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    39
   fields aren't aligned anyhow, so you have to serialize them in any case
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    40
   to avoid crashes on many CPU archs in any case. */
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    41
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    42
static int iso9660LoadEntries(PHYSFS_Io *io, const int joliet,
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    43
                              const char *base, const PHYSFS_uint64 dirstart,
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    44
                              const PHYSFS_uint64 dirend, void *unpkarc);
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    45
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    46
static int iso9660AddEntry(PHYSFS_Io *io, const int joliet, const int isdir,
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    47
                           const char *base, PHYSFS_uint8 *fname,
1504
803282f78987 Minor code cleanups: whitespace fixes, 80-column overflows, wrong comments.
Ryan C. Gordon <icculus@icculus.org>
parents: 1502
diff changeset
    48
                           const int fnamelen, const PHYSFS_sint64 ts,
1498
5977294d8e4b unpacked: let archivers specify create and modified times, hook up to iso9660.
Ryan C. Gordon <icculus@icculus.org>
parents: 1497
diff changeset
    49
                           const PHYSFS_uint64 pos, const PHYSFS_uint64 len,
5977294d8e4b unpacked: let archivers specify create and modified times, hook up to iso9660.
Ryan C. Gordon <icculus@icculus.org>
parents: 1497
diff changeset
    50
                           void *unpkarc)
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    51
{
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    52
    char *fullpath;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    53
    char *fnamecpy;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    54
    size_t baselen;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    55
    size_t fullpathlen;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    56
    void *entry;
1569
2d7183f702ed Sanity check archivers that should only have low-ASCII filename.
Ryan C. Gordon <icculus@icculus.org>
parents: 1559
diff changeset
    57
    int i;
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    58
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    59
    if (fnamelen == 1 && ((fname[0] == 0) || (fname[0] == 1)))
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    60
        return 1;  /* Magic that represents "." and "..", ignore */
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    61
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    62
    BAIL_IF(fnamelen == 0, PHYSFS_ERR_CORRUPT, 0);
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    63
    assert(fnamelen > 0);
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    64
    assert(fnamelen <= 255);
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    65
    BAIL_IF(joliet && (fnamelen % 2), PHYSFS_ERR_CORRUPT, 0);
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    66
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    67
    /* Joliet is UCS-2, so at most UTF-8 will double the byte size */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    68
    baselen = strlen(base);
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    69
    fullpathlen = baselen + (fnamelen * (joliet ? 2 : 1)) + 2;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    70
    fullpath = (char *) __PHYSFS_smallAlloc(fullpathlen);
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    71
    BAIL_IF(!fullpath, PHYSFS_ERR_OUT_OF_MEMORY, 0);
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    72
    fnamecpy = fullpath;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    73
    if (baselen > 0)
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    74
    {
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    75
        snprintf(fullpath, fullpathlen, "%s/", base);
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    76
        fnamecpy += baselen + 1;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    77
        fullpathlen -= baselen - 1;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    78
    } /* if */
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    79
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    80
    if (joliet)
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    81
    {
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    82
        PHYSFS_uint16 *ucs2 = (PHYSFS_uint16 *) fname;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    83
        int total = fnamelen / 2;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    84
        for (i = 0; i < total; i++)
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    85
            ucs2[i] = PHYSFS_swapUBE16(ucs2[i]);
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    86
        ucs2[total] = '\0';
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
    87
        PHYSFS_utf8FromUcs2(ucs2, fnamecpy, fullpathlen);
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    88
    } /* if */
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    89
    else
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    90
    {
1569
2d7183f702ed Sanity check archivers that should only have low-ASCII filename.
Ryan C. Gordon <icculus@icculus.org>
parents: 1559
diff changeset
    91
        for (i = 0; i < fnamelen; i++)
2d7183f702ed Sanity check archivers that should only have low-ASCII filename.
Ryan C. Gordon <icculus@icculus.org>
parents: 1559
diff changeset
    92
        {
2d7183f702ed Sanity check archivers that should only have low-ASCII filename.
Ryan C. Gordon <icculus@icculus.org>
parents: 1559
diff changeset
    93
            /* We assume the filenames are low-ASCII; consider the archive
2d7183f702ed Sanity check archivers that should only have low-ASCII filename.
Ryan C. Gordon <icculus@icculus.org>
parents: 1559
diff changeset
    94
               corrupt if we see something above 127, since we don't know the
2d7183f702ed Sanity check archivers that should only have low-ASCII filename.
Ryan C. Gordon <icculus@icculus.org>
parents: 1559
diff changeset
    95
               encoding. (We can change this later if we find out these exist
2d7183f702ed Sanity check archivers that should only have low-ASCII filename.
Ryan C. Gordon <icculus@icculus.org>
parents: 1559
diff changeset
    96
               and are intended to be, say, latin-1 or UTF-8 encoding). */
2d7183f702ed Sanity check archivers that should only have low-ASCII filename.
Ryan C. Gordon <icculus@icculus.org>
parents: 1559
diff changeset
    97
            BAIL_IF(fname[i] > 127, PHYSFS_ERR_CORRUPT, 0);
2d7183f702ed Sanity check archivers that should only have low-ASCII filename.
Ryan C. Gordon <icculus@icculus.org>
parents: 1559
diff changeset
    98
            fnamecpy[i] = fname[i];
2d7183f702ed Sanity check archivers that should only have low-ASCII filename.
Ryan C. Gordon <icculus@icculus.org>
parents: 1559
diff changeset
    99
        } /* for */
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   100
        fnamecpy[fnamelen] = '\0';
1569
2d7183f702ed Sanity check archivers that should only have low-ASCII filename.
Ryan C. Gordon <icculus@icculus.org>
parents: 1559
diff changeset
   101
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   102
        if (!isdir)
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   103
        {
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   104
            /* find last SEPARATOR2 */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   105
            char *ptr = strrchr(fnamecpy, ';');
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   106
            if (ptr && (ptr != fnamecpy))
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   107
                *(ptr--) = '\0';
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   108
            else
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   109
                ptr = fnamecpy + (fnamelen - 1);
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   110
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   111
            /* chop out any trailing '.', as done in all implementations */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   112
            if (*ptr == '.')
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   113
                *ptr = '\0';
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   114
        } /* if */
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   115
    } /* else */
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   116
1504
803282f78987 Minor code cleanups: whitespace fixes, 80-column overflows, wrong comments.
Ryan C. Gordon <icculus@icculus.org>
parents: 1502
diff changeset
   117
    entry = UNPK_addEntry(unpkarc, fullpath, isdir, ts, ts, pos, len);
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   118
    if ((entry) && (isdir))
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   119
    {
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   120
        if (!iso9660LoadEntries(io, joliet, fullpath, pos, pos + len, unpkarc))
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   121
            entry = NULL;  /* so we report a failure later. */
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   122
    } /* if */
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   123
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   124
    __PHYSFS_smallFree(fullpath);
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   125
    return entry != NULL;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   126
} /* iso9660AddEntry */
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   127
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   128
static int iso9660LoadEntries(PHYSFS_Io *io, const int joliet,
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   129
                              const char *base, const PHYSFS_uint64 dirstart,
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   130
                              const PHYSFS_uint64 dirend, void *unpkarc)
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   131
{
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   132
    PHYSFS_uint64 readpos = dirstart;
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   133
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   134
    while (1)
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   135
    {
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   136
        PHYSFS_uint8 recordlen;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   137
        PHYSFS_uint8 extattrlen;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   138
        PHYSFS_uint32 extent;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   139
        PHYSFS_uint32 datalen;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   140
        PHYSFS_uint8 ignore[4];
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   141
        PHYSFS_uint8 year, month, day, hour, minute, second, offset;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   142
        PHYSFS_uint8 flags;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   143
        PHYSFS_uint8 fnamelen;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   144
        PHYSFS_uint8 fname[256];
1498
5977294d8e4b unpacked: let archivers specify create and modified times, hook up to iso9660.
Ryan C. Gordon <icculus@icculus.org>
parents: 1497
diff changeset
   145
        PHYSFS_sint64 timestamp;
5977294d8e4b unpacked: let archivers specify create and modified times, hook up to iso9660.
Ryan C. Gordon <icculus@icculus.org>
parents: 1497
diff changeset
   146
        struct tm t;
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   147
        int isdir;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   148
        int multiextent;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   149
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   150
        BAIL_IF_ERRPASS(!io->seek(io, readpos), 0);
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   151
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   152
        /* recordlen = 0 -> no more entries or fill entry */
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   153
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, &recordlen, 1), 0);
1619
4f1bf89597e5 Fixed some infinite loops that a maliciously-crafted .iso can trigger.
Ryan C. Gordon <icculus@icculus.org>
parents: 1571
diff changeset
   154
        if (recordlen > 0)
4f1bf89597e5 Fixed some infinite loops that a maliciously-crafted .iso can trigger.
Ryan C. Gordon <icculus@icculus.org>
parents: 1571
diff changeset
   155
            readpos += recordlen;  /* ready to seek to next record. */
4f1bf89597e5 Fixed some infinite loops that a maliciously-crafted .iso can trigger.
Ryan C. Gordon <icculus@icculus.org>
parents: 1571
diff changeset
   156
        else
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   157
        {
1619
4f1bf89597e5 Fixed some infinite loops that a maliciously-crafted .iso can trigger.
Ryan C. Gordon <icculus@icculus.org>
parents: 1571
diff changeset
   158
            PHYSFS_uint64 nextpos;
4f1bf89597e5 Fixed some infinite loops that a maliciously-crafted .iso can trigger.
Ryan C. Gordon <icculus@icculus.org>
parents: 1571
diff changeset
   159
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   160
            /* if we are in the last sector of the directory & it's 0 -> end */
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   161
            if ((dirend - 2048) <= (readpos - 1))
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   162
                break; /* finished */
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   163
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   164
            /* else skip to the next sector & continue; */
1619
4f1bf89597e5 Fixed some infinite loops that a maliciously-crafted .iso can trigger.
Ryan C. Gordon <icculus@icculus.org>
parents: 1571
diff changeset
   165
            nextpos = (((readpos - 1) / 2048) + 1) * 2048;
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   166
1619
4f1bf89597e5 Fixed some infinite loops that a maliciously-crafted .iso can trigger.
Ryan C. Gordon <icculus@icculus.org>
parents: 1571
diff changeset
   167
            /* whoops, can't make forward progress! */
4f1bf89597e5 Fixed some infinite loops that a maliciously-crafted .iso can trigger.
Ryan C. Gordon <icculus@icculus.org>
parents: 1571
diff changeset
   168
            BAIL_IF(nextpos == readpos, PHYSFS_ERR_CORRUPT, 0);
4f1bf89597e5 Fixed some infinite loops that a maliciously-crafted .iso can trigger.
Ryan C. Gordon <icculus@icculus.org>
parents: 1571
diff changeset
   169
4f1bf89597e5 Fixed some infinite loops that a maliciously-crafted .iso can trigger.
Ryan C. Gordon <icculus@icculus.org>
parents: 1571
diff changeset
   170
            readpos = nextpos;
4f1bf89597e5 Fixed some infinite loops that a maliciously-crafted .iso can trigger.
Ryan C. Gordon <icculus@icculus.org>
parents: 1571
diff changeset
   171
            continue;  /* start back at upper loop. */
4f1bf89597e5 Fixed some infinite loops that a maliciously-crafted .iso can trigger.
Ryan C. Gordon <icculus@icculus.org>
parents: 1571
diff changeset
   172
        } /* else */
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   173
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   174
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, &extattrlen, 1), 0);
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   175
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, &extent, 4), 0);
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   176
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, ignore, 4), 0); /* extent be */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   177
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, &datalen, 4), 0);
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   178
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, ignore, 4), 0); /* datalen be */
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   179
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   180
        /* record timestamp */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   181
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, &year, 1), 0);
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   182
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, &month, 1), 0);
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   183
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, &day, 1), 0);
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   184
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, &hour, 1), 0);
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   185
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, &minute, 1), 0);
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   186
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, &second, 1), 0);
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   187
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, &offset, 1), 0);
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   188
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   189
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, &flags, 1), 0);
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   190
        isdir = (flags & (1 << 1)) != 0;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   191
        multiextent = (flags & (1 << 7)) != 0;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   192
        BAIL_IF(multiextent, PHYSFS_ERR_UNSUPPORTED, 0);  /* !!! FIXME */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   193
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   194
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, ignore, 1), 0); /* unit size */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   195
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, ignore, 1), 0); /* interleave gap */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   196
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, ignore, 2), 0); /* seqnum le */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   197
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, ignore, 2), 0); /* seqnum be */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   198
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, &fnamelen, 1), 0);
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   199
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, fname, fnamelen), 0);
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   200
1498
5977294d8e4b unpacked: let archivers specify create and modified times, hook up to iso9660.
Ryan C. Gordon <icculus@icculus.org>
parents: 1497
diff changeset
   201
        t.tm_sec = second;
5977294d8e4b unpacked: let archivers specify create and modified times, hook up to iso9660.
Ryan C. Gordon <icculus@icculus.org>
parents: 1497
diff changeset
   202
        t.tm_min = minute;
5977294d8e4b unpacked: let archivers specify create and modified times, hook up to iso9660.
Ryan C. Gordon <icculus@icculus.org>
parents: 1497
diff changeset
   203
        t.tm_hour = hour;
5977294d8e4b unpacked: let archivers specify create and modified times, hook up to iso9660.
Ryan C. Gordon <icculus@icculus.org>
parents: 1497
diff changeset
   204
        t.tm_mday = day;
5977294d8e4b unpacked: let archivers specify create and modified times, hook up to iso9660.
Ryan C. Gordon <icculus@icculus.org>
parents: 1497
diff changeset
   205
        t.tm_mon = month - 1;
5977294d8e4b unpacked: let archivers specify create and modified times, hook up to iso9660.
Ryan C. Gordon <icculus@icculus.org>
parents: 1497
diff changeset
   206
        t.tm_year = year;
5977294d8e4b unpacked: let archivers specify create and modified times, hook up to iso9660.
Ryan C. Gordon <icculus@icculus.org>
parents: 1497
diff changeset
   207
        t.tm_wday = 0;
5977294d8e4b unpacked: let archivers specify create and modified times, hook up to iso9660.
Ryan C. Gordon <icculus@icculus.org>
parents: 1497
diff changeset
   208
        t.tm_yday = 0;
5977294d8e4b unpacked: let archivers specify create and modified times, hook up to iso9660.
Ryan C. Gordon <icculus@icculus.org>
parents: 1497
diff changeset
   209
        t.tm_isdst = -1;
5977294d8e4b unpacked: let archivers specify create and modified times, hook up to iso9660.
Ryan C. Gordon <icculus@icculus.org>
parents: 1497
diff changeset
   210
        timestamp = (PHYSFS_sint64) mktime(&t);
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   211
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   212
        extent += extattrlen;  /* skip extended attribute record. */
1619
4f1bf89597e5 Fixed some infinite loops that a maliciously-crafted .iso can trigger.
Ryan C. Gordon <icculus@icculus.org>
parents: 1571
diff changeset
   213
4f1bf89597e5 Fixed some infinite loops that a maliciously-crafted .iso can trigger.
Ryan C. Gordon <icculus@icculus.org>
parents: 1571
diff changeset
   214
        /* infinite loop, corrupt file? */
4f1bf89597e5 Fixed some infinite loops that a maliciously-crafted .iso can trigger.
Ryan C. Gordon <icculus@icculus.org>
parents: 1571
diff changeset
   215
        BAIL_IF((extent * 2048) == dirstart, PHYSFS_ERR_CORRUPT, 0);
4f1bf89597e5 Fixed some infinite loops that a maliciously-crafted .iso can trigger.
Ryan C. Gordon <icculus@icculus.org>
parents: 1571
diff changeset
   216
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   217
        if (!iso9660AddEntry(io, joliet, isdir, base, fname, fnamelen,
1498
5977294d8e4b unpacked: let archivers specify create and modified times, hook up to iso9660.
Ryan C. Gordon <icculus@icculus.org>
parents: 1497
diff changeset
   218
                             timestamp, extent * 2048, datalen, unpkarc))
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   219
        {
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   220
            return 0;
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   221
        } /* if */
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   222
    } /* while */
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   223
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   224
    return 1;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   225
} /* iso9660LoadEntries */
1118
2e09fc635fdd Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1116
diff changeset
   226
2e09fc635fdd Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1116
diff changeset
   227
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   228
static int parseVolumeDescriptor(PHYSFS_Io *io, PHYSFS_uint64 *_rootpos,
1571
fbd9698219c1 Archivers can now specify whether an archive definitely was intended for them.
Ryan C. Gordon <icculus@icculus.org>
parents: 1569
diff changeset
   229
                                 PHYSFS_uint64 *_rootlen, int *_joliet,
fbd9698219c1 Archivers can now specify whether an archive definitely was intended for them.
Ryan C. Gordon <icculus@icculus.org>
parents: 1569
diff changeset
   230
                                 int *_claimed)
1118
2e09fc635fdd Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1116
diff changeset
   231
{
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   232
    PHYSFS_uint64 pos = 32768; /* start at the Primary Volume Descriptor */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   233
    int found = 0;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   234
    int done = 0;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   235
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   236
    *_joliet = 0;
1118
2e09fc635fdd Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1116
diff changeset
   237
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   238
    while (!done)
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   239
    {
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   240
        PHYSFS_uint8 type;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   241
        PHYSFS_uint8 identifier[5];
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   242
        PHYSFS_uint8 version;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   243
        PHYSFS_uint8 flags;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   244
        PHYSFS_uint8 escapeseqs[32];
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   245
        PHYSFS_uint8 ignore[32];
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   246
        PHYSFS_uint16 blocksize;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   247
        PHYSFS_uint32 extent;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   248
        PHYSFS_uint32 datalen;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   249
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   250
        BAIL_IF_ERRPASS(!io->seek(io, pos), 0);
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   251
        pos += 2048;  /* each volume descriptor is 2048 bytes */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   252
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   253
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, &type, 1), 0);
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   254
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, &identifier, 5), 0);
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   255
1571
fbd9698219c1 Archivers can now specify whether an archive definitely was intended for them.
Ryan C. Gordon <icculus@icculus.org>
parents: 1569
diff changeset
   256
        if (memcmp(identifier, "CD001", 5) != 0)  /* maybe not an iso? */
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   257
        {
1571
fbd9698219c1 Archivers can now specify whether an archive definitely was intended for them.
Ryan C. Gordon <icculus@icculus.org>
parents: 1569
diff changeset
   258
            BAIL_IF(!*_claimed, PHYSFS_ERR_UNSUPPORTED, 0);
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   259
            continue;  /* just skip this one */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   260
        } /* if */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   261
1571
fbd9698219c1 Archivers can now specify whether an archive definitely was intended for them.
Ryan C. Gordon <icculus@icculus.org>
parents: 1569
diff changeset
   262
        *_claimed = 1; /* okay, this is probably an iso. */
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   263
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   264
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, &version, 1), 0);  /* version */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   265
        BAIL_IF(version != 1, PHYSFS_ERR_UNSUPPORTED, 0);
1118
2e09fc635fdd Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1116
diff changeset
   266
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   267
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, &flags, 1), 0);
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   268
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, ignore, 32), 0);  /* system id */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   269
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, ignore, 32), 0);  /* volume id */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   270
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, ignore, 8), 0);  /* reserved */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   271
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, ignore, 4), 0);  /* space le */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   272
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, ignore, 4), 0);  /* space be */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   273
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, escapeseqs, 32), 0);
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   274
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, ignore, 2), 0);  /* setsize le */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   275
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, ignore, 2), 0);  /* setsize be */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   276
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, ignore, 2), 0);  /* seq num le */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   277
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, ignore, 2), 0);  /* seq num be */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   278
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, &blocksize, 2), 0);
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   279
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, ignore, 2), 0); /* blocklen be */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   280
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, ignore, 4), 0); /* pthtablen le */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   281
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, ignore, 4), 0); /* pthtablen be */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   282
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, ignore, 4), 0); /* pthtabpos le */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   283
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, ignore, 4), 0); /* optpthtabpos le */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   284
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, ignore, 4), 0); /* pthtabpos be */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   285
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, ignore, 4), 0); /* optpthtabpos be */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   286
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   287
        /* root directory record... */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   288
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, ignore, 1), 0); /* len */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   289
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, ignore, 1), 0); /* attr len */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   290
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, &extent, 4), 0);
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   291
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, ignore, 4), 0); /* extent be */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   292
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, &datalen, 4), 0);
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   293
        BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, ignore, 4), 0); /* datalen be */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   294
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   295
        /* !!! FIXME: deal with this properly. */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   296
        blocksize = PHYSFS_swapULE32(blocksize);
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   297
        BAIL_IF(blocksize && (blocksize != 2048), PHYSFS_ERR_UNSUPPORTED, 0);
1118
2e09fc635fdd Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1116
diff changeset
   298
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   299
        switch (type)
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   300
        {
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   301
            case 1:  /* Primary Volume Descriptor */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   302
            case 2:  /* Supplementary Volume Descriptor */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   303
                if (found < type)
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   304
                {
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   305
                    *_rootpos = PHYSFS_swapULE32(extent) * 2048;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   306
                    *_rootlen = PHYSFS_swapULE32(datalen);
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   307
                    found = type;
1118
2e09fc635fdd Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1116
diff changeset
   308
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   309
                    if (found == 2)  /* possible Joliet volume */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   310
                    {
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   311
                        const PHYSFS_uint8 *s = escapeseqs;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   312
                        *_joliet = !(flags & 1) &&
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   313
                            (s[0] == 0x25) && (s[1] == 0x2F) &&
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   314
                            ((s[2] == 0x40) || (s[2] == 0x43) || (s[2] == 0x45));
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   315
                    } /* if */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   316
                } /* if */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   317
                break;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   318
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   319
            case 255: /* type 255 terminates the volume descriptor list */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   320
                done = 1;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   321
                break;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   322
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   323
            default:
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   324
                break;  /* skip unknown types. */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   325
        } /* switch */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   326
    } /* while */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   327
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   328
    BAIL_IF(!found, PHYSFS_ERR_CORRUPT, 0);
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   329
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   330
    return 1;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   331
} /* parseVolumeDescriptor */
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   332
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   333
1571
fbd9698219c1 Archivers can now specify whether an archive definitely was intended for them.
Ryan C. Gordon <icculus@icculus.org>
parents: 1569
diff changeset
   334
static void *ISO9660_openArchive(PHYSFS_Io *io, const char *filename,
fbd9698219c1 Archivers can now specify whether an archive definitely was intended for them.
Ryan C. Gordon <icculus@icculus.org>
parents: 1569
diff changeset
   335
                                 int forWriting, int *claimed)
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   336
{
1500
f66cb6d5a9ae Fixed compiler warnings.
Ryan C. Gordon <icculus@icculus.org>
parents: 1498
diff changeset
   337
    PHYSFS_uint64 rootpos = 0;
f66cb6d5a9ae Fixed compiler warnings.
Ryan C. Gordon <icculus@icculus.org>
parents: 1498
diff changeset
   338
    PHYSFS_uint64 len = 0;
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   339
    int joliet = 0;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   340
    void *unpkarc = NULL;
1113
2136d64bd1ad Removed PHYSFS_Archiver's isArchive() method.
Ryan C. Gordon <icculus@icculus.org>
parents: 1111
diff changeset
   341
1118
2e09fc635fdd Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1116
diff changeset
   342
    assert(io != NULL);  /* shouldn't ever happen. */
2e09fc635fdd Abstracted file i/o into PHYSFS_Io interface.
Ryan C. Gordon <icculus@icculus.org>
parents: 1116
diff changeset
   343
1402
c5a5dadb901d Cleanup BAIL_* and GOTO_* macros to be less cluttered.
Ryan C. Gordon <icculus@icculus.org>
parents: 1398
diff changeset
   344
    BAIL_IF(forWriting, PHYSFS_ERR_READ_ONLY, NULL);
1571
fbd9698219c1 Archivers can now specify whether an archive definitely was intended for them.
Ryan C. Gordon <icculus@icculus.org>
parents: 1569
diff changeset
   345
fbd9698219c1 Archivers can now specify whether an archive definitely was intended for them.
Ryan C. Gordon <icculus@icculus.org>
parents: 1569
diff changeset
   346
    if (!parseVolumeDescriptor(io, &rootpos, &len, &joliet, claimed))
fbd9698219c1 Archivers can now specify whether an archive definitely was intended for them.
Ryan C. Gordon <icculus@icculus.org>
parents: 1569
diff changeset
   347
        return NULL;
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   348
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   349
    unpkarc = UNPK_openArchive(io);
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   350
    BAIL_IF_ERRPASS(!unpkarc, NULL);
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   351
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   352
    if (!iso9660LoadEntries(io, joliet, "", rootpos, rootpos + len, unpkarc))
1402
c5a5dadb901d Cleanup BAIL_* and GOTO_* macros to be less cluttered.
Ryan C. Gordon <icculus@icculus.org>
parents: 1398
diff changeset
   353
    {
1497
b9d771d6805f unpacked: let archivers "abandon" the archive instead of closing it.
Ryan C. Gordon <icculus@icculus.org>
parents: 1496
diff changeset
   354
        UNPK_abandonArchive(unpkarc);
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   355
        return NULL;
1402
c5a5dadb901d Cleanup BAIL_* and GOTO_* macros to be less cluttered.
Ryan C. Gordon <icculus@icculus.org>
parents: 1398
diff changeset
   356
    } /* if */
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   357
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   358
    return unpkarc;
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   359
} /* ISO9660_openArchive */
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   360
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   361
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   362
const PHYSFS_Archiver __PHYSFS_Archiver_ISO9660 =
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   363
{
1322
5476917b8ddf Allow application-supplied archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 1281
diff changeset
   364
    CURRENT_PHYSFS_ARCHIVER_API_VERSION,
1281
cd136b8d3b1a Moved PHYSFS_ArchiveInfo into PHYSFS_Archiver.
Ryan C. Gordon <icculus@icculus.org>
parents: 1280
diff changeset
   365
    {
cd136b8d3b1a Moved PHYSFS_ArchiveInfo into PHYSFS_Archiver.
Ryan C. Gordon <icculus@icculus.org>
parents: 1280
diff changeset
   366
        "ISO",
cd136b8d3b1a Moved PHYSFS_ArchiveInfo into PHYSFS_Archiver.
Ryan C. Gordon <icculus@icculus.org>
parents: 1280
diff changeset
   367
        "ISO9660 image file",
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   368
        "Ryan C. Gordon <icculus@icculus.org>",
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   369
        "https://icculus.org/physfs/",
1326
ac0fac4fe6d6 Moved supportsSymlinks into PHYSFS_ArchiveInfo.
Ryan C. Gordon <icculus@icculus.org>
parents: 1324
diff changeset
   370
        0,  /* supportsSymlinks */
1281
cd136b8d3b1a Moved PHYSFS_ArchiveInfo into PHYSFS_Archiver.
Ryan C. Gordon <icculus@icculus.org>
parents: 1280
diff changeset
   371
    },
1330
ce6b4a66b3eb Removed comments added by Captain Obvious.
Ryan C. Gordon <icculus@icculus.org>
parents: 1329
diff changeset
   372
    ISO9660_openArchive,
1559
aaee2b83291f Reworked enumeration to be more powerful.
Ryan C. Gordon <icculus@icculus.org>
parents: 1544
diff changeset
   373
    UNPK_enumerate,
1496
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   374
    UNPK_openRead,
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   375
    UNPK_openWrite,
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   376
    UNPK_openAppend,
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   377
    UNPK_remove,
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   378
    UNPK_mkdir,
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   379
    UNPK_stat,
6e1c8ff88482 iso9660: rewritten and simplified.
Ryan C. Gordon <icculus@icculus.org>
parents: 1465
diff changeset
   380
    UNPK_closeArchive
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   381
};
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   382
1066
e1d83e3b5d32 Make ISO9660 archiver optional.
Ryan C. Gordon <icculus@icculus.org>
parents: 1065
diff changeset
   383
#endif  /* defined PHYSFS_SUPPORTS_ISO9660 */
e1d83e3b5d32 Make ISO9660 archiver optional.
Ryan C. Gordon <icculus@icculus.org>
parents: 1065
diff changeset
   384
1507
8953b8a171e7 Update filename comments.
Ryan C. Gordon <icculus@icculus.org>
parents: 1506
diff changeset
   385
/* end of physfs_archiver_iso9660.c ... */
1064
cc4db73e87d1 ISO9660 archiver, compliments of Christoph Nelles.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   386