archivers/hog.c
author Ryan C. Gordon <icculus@icculus.org>
Sun, 11 Mar 2007 10:10:28 +0000
changeset 809 116b8fe30371
parent 808 7656f86a9a2c
child 828 ee871d51510d
permissions -rw-r--r--
Renamed LICENSE to LICENSE.txt
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     1
/*
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     2
 * HOG support routines for PhysicsFS.
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     3
 *
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     4
 * This driver handles Descent I/II HOG archives.
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     5
 *
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     6
 * The format is very simple:
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     7
 *
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     8
 *   The file always starts with the 3-byte signature "DHF" (Descent
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     9
 *   HOG file). After that the files of a HOG are just attached after
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    10
 *   another, divided by a 17 bytes header, which specifies the name
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    11
 *   and length (in bytes) of the forthcoming file! So you just read
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    12
 *   the header with its information of how big the following file is,
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    13
 *   and then skip exact that number of bytes to get to the next file
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    14
 *   in that HOG.
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    15
 *
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    16
 *    char sig[3] = {'D', 'H', 'F'}; // "DHF"=Descent HOG File
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    17
 *
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    18
 *    struct {
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    19
 *     char file_name[13]; // Filename, padded to 13 bytes with 0s
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    20
 *     int file_size; // filesize in bytes
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    21
 *     char data[file_size]; // The file data
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    22
 *    } FILE_STRUCT; // Repeated until the end of the file.
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    23
 *
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    24
 * (That info is from http://www.descent2.com/ddn/specs/hog/)
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    25
 *
809
116b8fe30371 Renamed LICENSE to LICENSE.txt
Ryan C. Gordon <icculus@icculus.org>
parents: 808
diff changeset
    26
 * Please see the file LICENSE.txt in the source's root directory.
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    27
 *
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    28
 *  This file written by Bradley Bell.
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    29
 *  Based on grp.c by Ryan C. Gordon.
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    30
 */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    31
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    32
#if (defined PHYSFS_SUPPORTS_HOG)
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    33
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    34
#include <stdio.h>
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    35
#include <stdlib.h>
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    36
#include <string.h>
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    37
#include "physfs.h"
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    38
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    39
#define __PHYSICSFS_INTERNAL__
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    40
#include "physfs_internal.h"
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    41
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    42
/*
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    43
 * One HOGentry is kept for each file in an open HOG archive.
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    44
 */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    45
typedef struct
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    46
{
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    47
    char name[13];
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    48
    PHYSFS_uint32 startPos;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    49
    PHYSFS_uint32 size;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    50
} HOGentry;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    51
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    52
/*
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    53
 * One HOGinfo is kept for each open HOG archive.
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    54
 */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    55
typedef struct
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    56
{
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    57
    char *filename;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    58
    PHYSFS_sint64 last_mod_time;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    59
    PHYSFS_uint32 entryCount;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    60
    HOGentry *entries;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    61
} HOGinfo;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    62
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    63
/*
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    64
 * One HOGfileinfo is kept for each open file in a HOG archive.
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    65
 */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    66
typedef struct
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    67
{
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    68
    void *handle;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    69
    HOGentry *entry;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    70
    PHYSFS_uint32 curPos;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    71
} HOGfileinfo;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    72
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    73
650
298b8bb26775 Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents: 648
diff changeset
    74
static void HOG_dirClose(dvoid *opaque)
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    75
{
648
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 622
diff changeset
    76
    HOGinfo *info = ((HOGinfo *) opaque);
691
71d9affe0d8a All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents: 678
diff changeset
    77
    allocator.Free(info->filename);
71d9affe0d8a All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents: 678
diff changeset
    78
    allocator.Free(info->entries);
71d9affe0d8a All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents: 678
diff changeset
    79
    allocator.Free(info);
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    80
} /* HOG_dirClose */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    81
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    82
650
298b8bb26775 Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents: 648
diff changeset
    83
static PHYSFS_sint64 HOG_read(fvoid *opaque, void *buffer,
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    84
                              PHYSFS_uint32 objSize, PHYSFS_uint32 objCount)
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    85
{
650
298b8bb26775 Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents: 648
diff changeset
    86
    HOGfileinfo *finfo = (HOGfileinfo *) opaque;
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    87
    HOGentry *entry = finfo->entry;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    88
    PHYSFS_uint32 bytesLeft = entry->size - finfo->curPos;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    89
    PHYSFS_uint32 objsLeft = (bytesLeft / objSize);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    90
    PHYSFS_sint64 rc;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    91
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    92
    if (objsLeft < objCount)
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    93
        objCount = objsLeft;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    94
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    95
    rc = __PHYSFS_platformRead(finfo->handle, buffer, objSize, objCount);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    96
    if (rc > 0)
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    97
        finfo->curPos += (PHYSFS_uint32) (rc * objSize);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    98
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    99
    return(rc);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   100
} /* HOG_read */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   101
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   102
650
298b8bb26775 Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents: 648
diff changeset
   103
static PHYSFS_sint64 HOG_write(fvoid *opaque, const void *buffer,
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   104
                               PHYSFS_uint32 objSize, PHYSFS_uint32 objCount)
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   105
{
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   106
    BAIL_MACRO(ERR_NOT_SUPPORTED, -1);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   107
} /* HOG_write */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   108
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   109
650
298b8bb26775 Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents: 648
diff changeset
   110
static int HOG_eof(fvoid *opaque)
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   111
{
650
298b8bb26775 Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents: 648
diff changeset
   112
    HOGfileinfo *finfo = (HOGfileinfo *) opaque;
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   113
    HOGentry *entry = finfo->entry;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   114
    return(finfo->curPos >= entry->size);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   115
} /* HOG_eof */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   116
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   117
650
298b8bb26775 Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents: 648
diff changeset
   118
static PHYSFS_sint64 HOG_tell(fvoid *opaque)
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   119
{
650
298b8bb26775 Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents: 648
diff changeset
   120
    return(((HOGfileinfo *) opaque)->curPos);
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   121
} /* HOG_tell */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   122
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   123
650
298b8bb26775 Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents: 648
diff changeset
   124
static int HOG_seek(fvoid *opaque, PHYSFS_uint64 offset)
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   125
{
650
298b8bb26775 Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents: 648
diff changeset
   126
    HOGfileinfo *finfo = (HOGfileinfo *) opaque;
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   127
    HOGentry *entry = finfo->entry;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   128
    int rc;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   129
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   130
    BAIL_IF_MACRO(offset < 0, ERR_INVALID_ARGUMENT, 0);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   131
    BAIL_IF_MACRO(offset >= entry->size, ERR_PAST_EOF, 0);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   132
    rc = __PHYSFS_platformSeek(finfo->handle, entry->startPos + offset);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   133
    if (rc)
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   134
        finfo->curPos = (PHYSFS_uint32) offset;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   135
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   136
    return(rc);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   137
} /* HOG_seek */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   138
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   139
650
298b8bb26775 Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents: 648
diff changeset
   140
static PHYSFS_sint64 HOG_fileLength(fvoid *opaque)
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   141
{
650
298b8bb26775 Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents: 648
diff changeset
   142
    HOGfileinfo *finfo = (HOGfileinfo *) opaque;
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   143
    return((PHYSFS_sint64) finfo->entry->size);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   144
} /* HOG_fileLength */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   145
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   146
650
298b8bb26775 Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents: 648
diff changeset
   147
static int HOG_fileClose(fvoid *opaque)
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   148
{
650
298b8bb26775 Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents: 648
diff changeset
   149
    HOGfileinfo *finfo = (HOGfileinfo *) opaque;
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   150
    BAIL_IF_MACRO(!__PHYSFS_platformClose(finfo->handle), NULL, 0);
691
71d9affe0d8a All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents: 678
diff changeset
   151
    allocator.Free(finfo);
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   152
    return(1);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   153
} /* HOG_fileClose */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   154
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   155
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   156
static int hog_open(const char *filename, int forWriting,
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   157
                    void **fh, PHYSFS_uint32 *count)
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   158
{
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   159
    PHYSFS_uint8 buf[13];
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   160
    PHYSFS_uint32 size;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   161
    PHYSFS_sint64 pos;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   162
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   163
    *count = 0;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   164
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   165
    *fh = NULL;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   166
    BAIL_IF_MACRO(forWriting, ERR_ARC_IS_READ_ONLY, 0);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   167
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   168
    *fh = __PHYSFS_platformOpenRead(filename);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   169
    BAIL_IF_MACRO(*fh == NULL, NULL, 0);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   170
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   171
    if (__PHYSFS_platformRead(*fh, buf, 3, 1) != 1)
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   172
        goto openHog_failed;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   173
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   174
    if (memcmp(buf, "DHF", 3) != 0)
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   175
    {
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   176
        __PHYSFS_setError(ERR_UNSUPPORTED_ARCHIVE);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   177
        goto openHog_failed;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   178
    } /* if */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   179
622
c8e67ca63ad6 Patches to get this building on Mac Classic again.
Ryan C. Gordon <icculus@icculus.org>
parents: 591
diff changeset
   180
    while (1)
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   181
    {
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   182
        if (__PHYSFS_platformRead(*fh, buf, 13, 1) != 1)
622
c8e67ca63ad6 Patches to get this building on Mac Classic again.
Ryan C. Gordon <icculus@icculus.org>
parents: 591
diff changeset
   183
            break; /* eof here is ok */
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   184
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   185
        if (__PHYSFS_platformRead(*fh, &size, 4, 1) != 1)
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   186
            goto openHog_failed;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   187
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   188
        size = PHYSFS_swapULE32(size);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   189
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   190
        (*count)++;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   191
622
c8e67ca63ad6 Patches to get this building on Mac Classic again.
Ryan C. Gordon <icculus@icculus.org>
parents: 591
diff changeset
   192
        /* Skip over entry... */
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   193
        pos = __PHYSFS_platformTell(*fh);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   194
        if (pos == -1)
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   195
            goto openHog_failed;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   196
        if (!__PHYSFS_platformSeek(*fh, pos + size))
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   197
            goto openHog_failed;
622
c8e67ca63ad6 Patches to get this building on Mac Classic again.
Ryan C. Gordon <icculus@icculus.org>
parents: 591
diff changeset
   198
    } /* while */
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   199
622
c8e67ca63ad6 Patches to get this building on Mac Classic again.
Ryan C. Gordon <icculus@icculus.org>
parents: 591
diff changeset
   200
    /* Rewind to start of entries... */
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   201
    if (!__PHYSFS_platformSeek(*fh, 3))
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   202
        goto openHog_failed;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   203
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   204
    return(1);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   205
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   206
openHog_failed:
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   207
    if (*fh != NULL)
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   208
        __PHYSFS_platformClose(*fh);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   209
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   210
    *count = -1;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   211
    *fh = NULL;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   212
    return(0);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   213
} /* hog_open */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   214
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   215
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   216
static int HOG_isArchive(const char *filename, int forWriting)
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   217
{
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   218
    void *fh;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   219
    PHYSFS_uint32 fileCount;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   220
    int retval = hog_open(filename, forWriting, &fh, &fileCount);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   221
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   222
    if (fh != NULL)
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   223
        __PHYSFS_platformClose(fh);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   224
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   225
    return(retval);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   226
} /* HOG_isArchive */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   227
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   228
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   229
static int hog_entry_cmp(void *_a, PHYSFS_uint32 one, PHYSFS_uint32 two)
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   230
{
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   231
    HOGentry *a = (HOGentry *) _a;
671
d761900016b4 Fixed filename sorting, to fix lookups that shouldn't fail (thanks, Chris!).
Ryan C. Gordon <icculus@icculus.org>
parents: 658
diff changeset
   232
    return(__PHYSFS_platformStricmp(a[one].name, a[two].name));
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   233
} /* hog_entry_cmp */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   234
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   235
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   236
static void hog_entry_swap(void *_a, PHYSFS_uint32 one, PHYSFS_uint32 two)
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   237
{
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   238
    HOGentry tmp;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   239
    HOGentry *first = &(((HOGentry *) _a)[one]);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   240
    HOGentry *second = &(((HOGentry *) _a)[two]);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   241
    memcpy(&tmp, first, sizeof (HOGentry));
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   242
    memcpy(first, second, sizeof (HOGentry));
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   243
    memcpy(second, &tmp, sizeof (HOGentry));
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   244
} /* hog_entry_swap */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   245
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   246
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   247
static int hog_load_entries(const char *name, int forWriting, HOGinfo *info)
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   248
{
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   249
    void *fh = NULL;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   250
    PHYSFS_uint32 fileCount;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   251
    HOGentry *entry;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   252
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   253
    BAIL_IF_MACRO(!hog_open(name, forWriting, &fh, &fileCount), NULL, 0);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   254
    info->entryCount = fileCount;
691
71d9affe0d8a All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents: 678
diff changeset
   255
    info->entries = (HOGentry *) allocator.Malloc(sizeof(HOGentry)*fileCount);
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   256
    if (info->entries == NULL)
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   257
    {
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   258
        __PHYSFS_platformClose(fh);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   259
        BAIL_MACRO(ERR_OUT_OF_MEMORY, 0);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   260
    } /* if */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   261
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   262
    for (entry = info->entries; fileCount > 0; fileCount--, entry++)
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   263
    {
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   264
        if (__PHYSFS_platformRead(fh, &entry->name, 13, 1) != 1)
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   265
        {
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   266
            __PHYSFS_platformClose(fh);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   267
            return(0);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   268
        } /* if */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   269
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   270
        if (__PHYSFS_platformRead(fh, &entry->size, 4, 1) != 1)
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   271
        {
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   272
            __PHYSFS_platformClose(fh);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   273
            return(0);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   274
        } /* if */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   275
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   276
        entry->size = PHYSFS_swapULE32(entry->size);
591
f31600941752 removed a warning by adding a cast
bhook
parents: 564
diff changeset
   277
        entry->startPos = (unsigned int) __PHYSFS_platformTell(fh);
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   278
        if (entry->startPos == -1)
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   279
        {
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   280
            __PHYSFS_platformClose(fh);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   281
            return(0);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   282
        }
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   283
622
c8e67ca63ad6 Patches to get this building on Mac Classic again.
Ryan C. Gordon <icculus@icculus.org>
parents: 591
diff changeset
   284
        /* Skip over entry */
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   285
        if (!__PHYSFS_platformSeek(fh, entry->startPos + entry->size))
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   286
        {
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   287
            __PHYSFS_platformClose(fh);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   288
            return(0);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   289
        }
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   290
    } /* for */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   291
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   292
    __PHYSFS_platformClose(fh);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   293
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   294
    __PHYSFS_sort(info->entries, info->entryCount,
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   295
                  hog_entry_cmp, hog_entry_swap);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   296
    return(1);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   297
} /* hog_load_entries */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   298
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   299
648
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 622
diff changeset
   300
static void *HOG_openArchive(const char *name, int forWriting)
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   301
{
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   302
    PHYSFS_sint64 modtime = __PHYSFS_platformGetLastModTime(name);
691
71d9affe0d8a All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents: 678
diff changeset
   303
    HOGinfo *info = (HOGinfo *) allocator.Malloc(sizeof (HOGinfo));
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   304
648
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 622
diff changeset
   305
    BAIL_IF_MACRO(info == NULL, ERR_OUT_OF_MEMORY, 0);
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   306
    memset(info, '\0', sizeof (HOGinfo));
691
71d9affe0d8a All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents: 678
diff changeset
   307
    info->filename = (char *) allocator.Malloc(strlen(name) + 1);
678
73a2641375a0 Cleaned up some minor bloat with my new evil GOTO_*_MACRO macros.
Ryan C. Gordon <icculus@icculus.org>
parents: 671
diff changeset
   308
    GOTO_IF_MACRO(!info->filename, ERR_OUT_OF_MEMORY, HOG_openArchive_failed);
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   309
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   310
    if (!hog_load_entries(name, forWriting, info))
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   311
        goto HOG_openArchive_failed;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   312
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   313
    strcpy(info->filename, name);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   314
    info->last_mod_time = modtime;
648
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 622
diff changeset
   315
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 622
diff changeset
   316
    return(info);
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   317
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   318
HOG_openArchive_failed:
648
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 622
diff changeset
   319
    if (info != NULL)
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   320
    {
648
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 622
diff changeset
   321
        if (info->filename != NULL)
691
71d9affe0d8a All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents: 678
diff changeset
   322
            allocator.Free(info->filename);
648
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 622
diff changeset
   323
        if (info->entries != NULL)
691
71d9affe0d8a All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents: 678
diff changeset
   324
            allocator.Free(info->entries);
71d9affe0d8a All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents: 678
diff changeset
   325
        allocator.Free(info);
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   326
    } /* if */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   327
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   328
    return(NULL);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   329
} /* HOG_openArchive */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   330
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   331
657
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   332
static void HOG_enumerateFiles(dvoid *opaque, const char *dname,
754
e7cd7411eadf API BREAKAGE: Changed PHYSFS_enumerateFilesCallback() to pass the originally
Ryan C. Gordon <icculus@icculus.org>
parents: 691
diff changeset
   333
                               int omitSymLinks, PHYSFS_EnumFilesCallback cb,
e7cd7411eadf API BREAKAGE: Changed PHYSFS_enumerateFilesCallback() to pass the originally
Ryan C. Gordon <icculus@icculus.org>
parents: 691
diff changeset
   334
                               const char *origdir, void *callbackdata)
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   335
{
657
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   336
    /* no directories in HOG files. */
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   337
    if (*dname != '\0')
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   338
    {
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   339
        HOGinfo *info = (HOGinfo *) opaque;
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   340
        HOGentry *entry = info->entries;
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   341
        PHYSFS_uint32 max = info->entryCount;
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   342
        PHYSFS_uint32 i;
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   343
657
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   344
        for (i = 0; i < max; i++, entry++)
754
e7cd7411eadf API BREAKAGE: Changed PHYSFS_enumerateFilesCallback() to pass the originally
Ryan C. Gordon <icculus@icculus.org>
parents: 691
diff changeset
   345
            cb(callbackdata, origdir, entry->name);
657
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   346
    } /* if */
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   347
} /* HOG_enumerateFiles */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   348
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   349
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   350
static HOGentry *hog_find_entry(HOGinfo *info, const char *name)
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   351
{
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   352
    char *ptr = strchr(name, '.');
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   353
    HOGentry *a = info->entries;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   354
    PHYSFS_sint32 lo = 0;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   355
    PHYSFS_sint32 hi = (PHYSFS_sint32) (info->entryCount - 1);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   356
    PHYSFS_sint32 middle;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   357
    int rc;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   358
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   359
    /*
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   360
     * Rule out filenames to avoid unneeded processing...no dirs,
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   361
     *   big filenames, or extensions > 3 chars.
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   362
     */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   363
    BAIL_IF_MACRO((ptr) && (strlen(ptr) > 4), ERR_NO_SUCH_FILE, NULL);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   364
    BAIL_IF_MACRO(strlen(name) > 12, ERR_NO_SUCH_FILE, NULL);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   365
    BAIL_IF_MACRO(strchr(name, '/') != NULL, ERR_NO_SUCH_FILE, NULL);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   366
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   367
    while (lo <= hi)
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   368
    {
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   369
        middle = lo + ((hi - lo) / 2);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   370
        rc = __PHYSFS_platformStricmp(name, a[middle].name);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   371
        if (rc == 0)  /* found it! */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   372
            return(&a[middle]);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   373
        else if (rc > 0)
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   374
            lo = middle + 1;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   375
        else
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   376
            hi = middle - 1;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   377
    } /* while */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   378
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   379
    BAIL_MACRO(ERR_NO_SUCH_FILE, NULL);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   380
} /* hog_find_entry */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   381
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   382
650
298b8bb26775 Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents: 648
diff changeset
   383
static int HOG_exists(dvoid *opaque, const char *name)
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   384
{
648
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 622
diff changeset
   385
    return(hog_find_entry(((HOGinfo *) opaque), name) != NULL);
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   386
} /* HOG_exists */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   387
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   388
650
298b8bb26775 Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents: 648
diff changeset
   389
static int HOG_isDirectory(dvoid *opaque, const char *name, int *fileExists)
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   390
{
648
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 622
diff changeset
   391
    *fileExists = HOG_exists(opaque, name);
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   392
    return(0);  /* never directories in a groupfile. */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   393
} /* HOG_isDirectory */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   394
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   395
650
298b8bb26775 Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents: 648
diff changeset
   396
static int HOG_isSymLink(dvoid *opaque, const char *name, int *fileExists)
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   397
{
648
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 622
diff changeset
   398
    *fileExists = HOG_exists(opaque, name);
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   399
    return(0);  /* never symlinks in a groupfile. */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   400
} /* HOG_isSymLink */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   401
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   402
650
298b8bb26775 Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents: 648
diff changeset
   403
static PHYSFS_sint64 HOG_getLastModTime(dvoid *opaque,
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   404
                                        const char *name,
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   405
                                        int *fileExists)
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   406
{
648
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 622
diff changeset
   407
    HOGinfo *info = ((HOGinfo *) opaque);
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   408
    PHYSFS_sint64 retval = -1;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   409
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   410
    *fileExists = (hog_find_entry(info, name) != NULL);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   411
    if (*fileExists)  /* use time of HOG itself in the physical filesystem. */
648
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 622
diff changeset
   412
        retval = info->last_mod_time;
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   413
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   414
    return(retval);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   415
} /* HOG_getLastModTime */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   416
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   417
650
298b8bb26775 Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents: 648
diff changeset
   418
static fvoid *HOG_openRead(dvoid *opaque, const char *fnm, int *fileExists)
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   419
{
648
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 622
diff changeset
   420
    HOGinfo *info = ((HOGinfo *) opaque);
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   421
    HOGfileinfo *finfo;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   422
    HOGentry *entry;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   423
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   424
    entry = hog_find_entry(info, fnm);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   425
    *fileExists = (entry != NULL);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   426
    BAIL_IF_MACRO(entry == NULL, NULL, NULL);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   427
691
71d9affe0d8a All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents: 678
diff changeset
   428
    finfo = (HOGfileinfo *) allocator.Malloc(sizeof (HOGfileinfo));
650
298b8bb26775 Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents: 648
diff changeset
   429
    BAIL_IF_MACRO(finfo == NULL, ERR_OUT_OF_MEMORY, NULL);
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   430
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   431
    finfo->handle = __PHYSFS_platformOpenRead(info->filename);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   432
    if ( (finfo->handle == NULL) ||
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   433
         (!__PHYSFS_platformSeek(finfo->handle, entry->startPos)) )
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   434
    {
691
71d9affe0d8a All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents: 678
diff changeset
   435
        allocator.Free(finfo);
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   436
        return(NULL);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   437
    } /* if */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   438
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   439
    finfo->curPos = 0;
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   440
    finfo->entry = entry;
650
298b8bb26775 Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents: 648
diff changeset
   441
    return(finfo);
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   442
} /* HOG_openRead */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   443
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   444
650
298b8bb26775 Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents: 648
diff changeset
   445
static fvoid *HOG_openWrite(dvoid *opaque, const char *name)
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   446
{
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   447
    BAIL_MACRO(ERR_NOT_SUPPORTED, NULL);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   448
} /* HOG_openWrite */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   449
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   450
650
298b8bb26775 Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents: 648
diff changeset
   451
static fvoid *HOG_openAppend(dvoid *opaque, const char *name)
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   452
{
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   453
    BAIL_MACRO(ERR_NOT_SUPPORTED, NULL);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   454
} /* HOG_openAppend */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   455
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   456
650
298b8bb26775 Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents: 648
diff changeset
   457
static int HOG_remove(dvoid *opaque, const char *name)
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   458
{
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   459
    BAIL_MACRO(ERR_NOT_SUPPORTED, 0);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   460
} /* HOG_remove */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   461
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   462
650
298b8bb26775 Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents: 648
diff changeset
   463
static int HOG_mkdir(dvoid *opaque, const char *name)
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   464
{
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   465
    BAIL_MACRO(ERR_NOT_SUPPORTED, 0);
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   466
} /* HOG_mkdir */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   467
658
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   468
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   469
const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_HOG =
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   470
{
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   471
    "HOG",
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   472
    HOG_ARCHIVE_DESCRIPTION,
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   473
    "Bradley Bell <btb@icculus.org>",
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   474
    "http://icculus.org/physfs/",
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   475
};
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   476
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   477
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   478
const PHYSFS_Archiver __PHYSFS_Archiver_HOG =
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   479
{
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   480
    &__PHYSFS_ArchiveInfo_HOG,
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   481
    HOG_isArchive,          /* isArchive() method      */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   482
    HOG_openArchive,        /* openArchive() method    */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   483
    HOG_enumerateFiles,     /* enumerateFiles() method */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   484
    HOG_exists,             /* exists() method         */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   485
    HOG_isDirectory,        /* isDirectory() method    */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   486
    HOG_isSymLink,          /* isSymLink() method      */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   487
    HOG_getLastModTime,     /* getLastModTime() method */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   488
    HOG_openRead,           /* openRead() method       */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   489
    HOG_openWrite,          /* openWrite() method      */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   490
    HOG_openAppend,         /* openAppend() method     */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   491
    HOG_remove,             /* remove() method         */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   492
    HOG_mkdir,              /* mkdir() method          */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   493
    HOG_dirClose,           /* dirClose() method       */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   494
    HOG_read,               /* read() method           */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   495
    HOG_write,              /* write() method          */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   496
    HOG_eof,                /* eof() method            */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   497
    HOG_tell,               /* tell() method           */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   498
    HOG_seek,               /* seek() method           */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   499
    HOG_fileLength,         /* fileLength() method     */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   500
    HOG_fileClose           /* fileClose() method      */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   501
};
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   502
553
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   503
#endif  /* defined PHYSFS_SUPPORTS_HOG */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   504
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   505
/* end of hog.c ... */
4338d9c0bbcd Descent I/II HOG and MVL archive support (thanks, Bradley Bell!).
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   506