archivers/mix.c
author Ryan C. Gordon <icculus@icculus.org>
Sun, 13 Mar 2005 03:33:11 +0000
changeset 678 73a2641375a0
parent 658 1981818c6170
child 691 71d9affe0d8a
permissions -rw-r--r--
Cleaned up some minor bloat with my new evil GOTO_*_MACRO macros.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     1
/*
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     2
 * MIX support routines for PhysicsFS.
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     3
 *
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     4
 * This driver handles old archives used in the famous games
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     5
 * Command&Conquer Tiberium Dawn and Command&Conquer Red Alert.
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     6
 *
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     7
 * Newer MIX files as they are used in C&C Tiberium Sun and C&C Red Alert 2
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     8
 * aren't supported yet. Keep your eyes open for future updates.
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     9
 *
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    10
 * A MIX file has three parts:
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    11
 *   (1) Header
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    12
 *        16bit integer  -> number of files stored in this MIX
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    13
 *        32bit integer  -> filesize
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    14
 *   (2) "Directory"
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    15
 *        32bit integer  -> hash of the filename
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    16
 *        32bit integer  -> starting offset in the MIX
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    17
 *        32bit integer  -> end offset in the MIX
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    18
 *   (3) Data (BODY)
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    19
 *        All data comes here
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    20
 *
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    21
 * NOTES:
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    22
 *  The offsets are relative to the body. So offset 0 is directly after
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    23
 *  the directory.
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    24
 *
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    25
 *  Filenames only exist as hashes. So enumerate_files() will only report all
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    26
 *  hashes. Searching a filename in hashes is extremly quick so I decided not
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    27
 *  to include any sorting routines after then opening of the archive.
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    28
 *
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    29
 *
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    30
 * I found the structure of MIX files here: 
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    31
 * http://www.geocities.com/SiliconValley/8682/cncmap1f.txt
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    32
 *
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    33
 *
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    34
 * Please see the file LICENSE in the source's root directory.
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    35
 *
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    36
 *  This file written by Sebastian Steinhauer <steini@steini-welt.de>
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    37
 */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    38
 
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    39
#if HAVE_CONFIG_H
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    40
#  include <config.h>
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    41
#endif
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    42
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    43
#if (defined PHYSFS_SUPPORTS_MIX)
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    44
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    45
#include <stdio.h>
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    46
#include <stdlib.h>
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    47
#include <string.h>
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    48
#include "physfs.h"
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    49
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    50
#define __PHYSICSFS_INTERNAL__
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    51
#include "physfs_internal.h"
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    52
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    53
typedef struct
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    54
{
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    55
    PHYSFS_uint16 num_files;
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    56
    PHYSFS_uint32 filesize;
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    57
} MIXheader;
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    58
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    59
typedef struct
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    60
{
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    61
    PHYSFS_uint32 hash;
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    62
    PHYSFS_uint32 start_offset;
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    63
    PHYSFS_uint32 end_offset;
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    64
} MIXentry;
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    65
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    66
typedef struct
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    67
{
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    68
    char *filename; /* filename of the archive */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    69
    MIXentry *entry; /* list of entries */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    70
    MIXheader header; /* the header of the MIX file */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    71
    PHYSFS_uint32 delta; /* size of header + entries */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    72
} MIXinfo;
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    73
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    74
typedef struct
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    75
{
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    76
    PHYSFS_uint64 size; /* filesize */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    77
    PHYSFS_uint64 cur_pos; /* position in this file */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    78
    MIXentry *entry; /* pointer to the MIX entry */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    79
    MIXinfo *info; /* pointer to our MIXinfo */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    80
    void *handle; /* filehandle */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    81
} MIXfileinfo;
17fdeeaf7b51 Westwood MIX archive support.
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
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    84
static PHYSFS_uint32 MIX_hash(const char *name)
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    85
{
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    86
    PHYSFS_uint32 id = 0;
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    87
    PHYSFS_uint32 a = 0;
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    88
    PHYSFS_uint32 i = 0;
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    89
    PHYSFS_uint32 l;
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    90
    PHYSFS_uint32 j;
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    91
    
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    92
    l = strlen(name);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    93
    while (i < l)
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    94
    {
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    95
        a = 0;
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    96
        for(j = 0; j < 4; j++)
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    97
        {
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    98
            a >>= 8;
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    99
            if (i < l)
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   100
            {
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   101
                a += (unsigned int) (name[i]) << 24;
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   102
                i++;
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   103
            } /* if */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   104
        } /* for */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   105
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   106
        id = (id << 1 | id >> 31) + a;
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   107
    } /* while */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   108
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   109
    /* a bit debuggin :)
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   110
    /printf("Filename %s -> %X\n",name,id); */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   111
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   112
    return(id);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   113
} /* MIX_hash */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   114
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   115
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
   116
static void MIX_dirClose(dvoid *opaque)
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   117
{
648
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   118
    MIXinfo *info = ((MIXinfo *) opaque);
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   119
    free(info->entry);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   120
    free(info->filename);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   121
} /* MIX_dirClose */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   122
17fdeeaf7b51 Westwood MIX archive support.
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 PHYSFS_sint64 MIX_read(fvoid *opaque, void *buffer,
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   125
                              PHYSFS_uint32 objSize, PHYSFS_uint32 objCount)
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   126
{
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
   127
    MIXfileinfo *finfo = (MIXfileinfo *) opaque;
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   128
    MIXentry *entry = finfo->entry;
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   129
    PHYSFS_uint32 read;
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   130
    
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   131
    /* set position in the archive */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   132
    __PHYSFS_platformSeek(finfo->handle,
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   133
                             finfo->info->delta +
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   134
                             entry->start_offset +
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   135
                             finfo->cur_pos);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   136
    
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   137
    /* read n bytes */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   138
    read = __PHYSFS_platformRead(finfo->handle, buffer, objSize, objCount);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   139
    
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   140
    /* keep filepointer up to date */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   141
    if (read)
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   142
        finfo->cur_pos += read * objSize;
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   143
    
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   144
    return(read);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   145
} /* MIX_read */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   146
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   147
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
   148
static PHYSFS_sint64 MIX_write(fvoid *opaque, const void *buffer,
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   149
                               PHYSFS_uint32 objSize, PHYSFS_uint32 objCount)
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   150
{
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   151
    BAIL_MACRO(ERR_NOT_SUPPORTED, -1);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   152
} /* MIX_write */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   153
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   154
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
   155
static int MIX_eof(fvoid *opaque)
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   156
{
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
   157
    MIXfileinfo *fifo = (MIXfileinfo *) opaque;
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   158
    return(fifo->cur_pos >= fifo->size);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   159
} /* MIX_eof */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   160
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   161
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
   162
static PHYSFS_sint64 MIX_tell(fvoid *opaque)
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   163
{
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
   164
    return(((MIXfileinfo *) opaque)->cur_pos);
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   165
} /* MIX_tell */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   166
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   167
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
   168
static int MIX_seek(fvoid *opaque, PHYSFS_uint64 offset)
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   169
{
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
   170
    MIXfileinfo *h = (MIXfileinfo *) opaque;
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   171
    
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   172
    BAIL_IF_MACRO(offset < 0, ERR_INVALID_ARGUMENT, 0);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   173
    BAIL_IF_MACRO(offset >= h->size, ERR_PAST_EOF, 0);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   174
    h->cur_pos = offset;
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   175
    return(1);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   176
} /* MIX_seek */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   177
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   178
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
   179
static PHYSFS_sint64 MIX_fileLength(fvoid *opaque)
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   180
{
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
   181
    return (((MIXfileinfo *) opaque)->size);
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   182
} /* MIX_fileLength */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   183
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   184
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
   185
static int MIX_fileClose(fvoid *opaque)
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   186
{
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
   187
    MIXfileinfo *finfo = (MIXfileinfo *) opaque;
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   188
    __PHYSFS_platformClose(finfo->handle);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   189
    free(finfo);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   190
    return(1);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   191
} /* MIX_fileClose */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   192
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   193
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   194
static int MIX_isArchive(const char *filename, int forWriting)
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   195
{
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
   196
    /* !!! FIXME:
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   197
            write a simple detection routine for MIX files.
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   198
            Unfortunaly MIX files have no ID in the header.
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   199
    */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   200
    return(1);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   201
} /* MIX_isArchive */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   202
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   203
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   204
/*
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   205
 * Read an unsigned 32-bit int and swap to native byte order.
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   206
 */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   207
static int readui32(void *in, PHYSFS_uint32 *val)
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   208
{
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   209
    PHYSFS_uint32 v;
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   210
    BAIL_IF_MACRO(__PHYSFS_platformRead(in, &v, sizeof (v), 1) != 1, NULL, 0);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   211
    *val = PHYSFS_swapULE32(v);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   212
    return(1);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   213
} /* readui32 */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   214
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   215
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   216
/*
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   217
 * Read an unsigned 16-bit int and swap to native byte order.
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   218
 */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   219
static int readui16(void *in, PHYSFS_uint16 *val)
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   220
{
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   221
    PHYSFS_uint16 v;
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   222
    BAIL_IF_MACRO(__PHYSFS_platformRead(in, &v, sizeof (v), 1) != 1, NULL, 0);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   223
    *val = PHYSFS_swapULE16(v);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   224
    return(1);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   225
} /* readui16 */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   226
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   227
648
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   228
static void *MIX_openArchive(const char *name, int forWriting)
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   229
{
648
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   230
    PHYSFS_uint32 i = 0;
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   231
    MIXinfo *info = NULL;
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   232
    void *handle = NULL;
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   233
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   234
    info = (MIXinfo *) malloc(sizeof (MIXinfo));
648
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   235
    BAIL_IF_MACRO(info == NULL, ERR_OUT_OF_MEMORY, 0);
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   236
    memset(info, '\0', sizeof (MIXinfo));
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   237
648
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   238
    info->filename = (char *) 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: 658
diff changeset
   239
    GOTO_IF_MACRO(!info->filename, ERR_OUT_OF_MEMORY, MIX_openArchive_failed);
73a2641375a0 Cleaned up some minor bloat with my new evil GOTO_*_MACRO macros.
Ryan C. Gordon <icculus@icculus.org>
parents: 658
diff changeset
   240
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   241
    /* store filename */
648
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   242
    strcpy(info->filename, name);
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   243
    
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   244
    /* open the file */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   245
    handle = __PHYSFS_platformOpenRead(name);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   246
    if (!handle)
648
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   247
        goto MIX_openArchive_failed;
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   248
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   249
    /* read the MIX header */
648
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   250
    if ( (!readui16(handle, &info->header.num_files)) ||
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   251
         (!readui32(handle, &info->header.filesize)) )
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   252
        goto MIX_openArchive_failed;
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   253
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   254
    info->delta = 6 + (info->header.num_files * 12);
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   255
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   256
    /* allocate space for the entries and read the entries */
648
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   257
    info->entry = malloc(sizeof (MIXentry) * info->header.num_files);
678
73a2641375a0 Cleaned up some minor bloat with my new evil GOTO_*_MACRO macros.
Ryan C. Gordon <icculus@icculus.org>
parents: 658
diff changeset
   258
    GOTO_IF_MACRO(!info->entry, ERR_OUT_OF_MEMORY, MIX_openArchive_failed);
73a2641375a0 Cleaned up some minor bloat with my new evil GOTO_*_MACRO macros.
Ryan C. Gordon <icculus@icculus.org>
parents: 658
diff changeset
   259
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   260
    /* read the directory list */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   261
    for (i = 0; i < header.num_files; i++)
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   262
    {
648
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   263
        if ( (!readui32(handle, &info->entry[i].hash)) ||
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   264
             (!readui32(handle, &info->entry[i].start_offset)) ||
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   265
             (!readui32(handle, &info->entry[i].end_offset)) )
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   266
            goto MIX_openArchive_failed;
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   267
    } /* for */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   268
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   269
    __PHYSFS_platformClose(handle);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   270
648
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   271
    return(info);
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   272
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   273
MIX_openArchive_failed:
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   274
    if (info != NULL)
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   275
    {
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   276
        if (info->filename != NULL)
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   277
            free(info->filename);
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   278
        if (info->entry != NULL)
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   279
            free(info->entry);
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   280
        free(info);
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   281
    } /* if */
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   282
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   283
    if (handle != NULL)
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   284
        __PHYSFS_platformClose(handle);
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   285
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   286
    return(NULL);
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   287
} /* MIX_openArchive */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   288
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   289
657
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   290
static void MIX_enumerateFiles(dvoid *opaque, const char *dname,
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   291
                               int omitSymLinks, PHYSFS_StringCallback cb,
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   292
                               void *callbackdata)
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   293
{
657
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   294
    /* no directories in MIX files. */
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   295
    if (*dirname != '\0')
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   296
    {
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   297
        MIXinfo *info = (MIXinfo*) opaque;
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   298
        MIXentry *entry = info->entry;
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   299
        int i;
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   300
        char buffer[32];
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   301
    
657
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   302
        for (i = 0; i < info->header.num_files; i++, entry++)
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   303
        {
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   304
            sprintf(buffer, "%X", entry->hash);
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   305
            cb(callbackdata, buffer);
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   306
        } /* for */
dad3b5c307a9 Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents: 650
diff changeset
   307
    } /* if */
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   308
} /* MIX_enumerateFiles */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   309
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   310
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   311
static MIXentry *MIX_find_entry(MIXinfo *info, const char *name)
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   312
{
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   313
    MIXentry *entry = info->entry;
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   314
    PHYSFS_uint32 i, id;
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   315
    
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   316
    /* create hash */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   317
    id = MIX_hash(name);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   318
    
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   319
    /* look for this hash */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   320
    for (i = 0; i < info->header.num_files; i++, entry++)
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   321
    {
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   322
        if (entry->hash == id)
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   323
            return(entry);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   324
    } /* for */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   325
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   326
    /* nothing found... :( */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   327
    return(NULL);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   328
} /* MIX_find_entry */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   329
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   330
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
   331
static int MIX_exists(dvoid *opaque, const char *name)
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   332
{
648
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   333
    return(MIX_find_entry(((MIXinfo *) opaque), name) != NULL);
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   334
} /* MIX_exists */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   335
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   336
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
   337
static int MIX_isDirectory(dvoid *opaque, const char *name, int *fileExists)
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   338
{
648
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   339
    *fileExists = MIX_exists(opaque, name);
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   340
    return(0);  /* never directories in a MIX */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   341
} /* MIX_isDirectory */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   342
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   343
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
   344
static int MIX_isSymLink(dvoid *opaque, const char *name, int *fileExists)
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   345
{
648
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   346
    *fileExists = MIX_exists(opaque, name);
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   347
    return(0);  /* never symlinks in a MIX. */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   348
} /* MIX_isSymLink */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   349
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   350
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
   351
static PHYSFS_sint64 MIX_getLastModTime(dvoid *opaque,
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   352
                                        const char *name,
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   353
                                        int *fileExists)
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   354
{
648
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   355
    BAIL_MACRO(ERR_NOT_SUPPORTED, 0);  /* !!! FIXME: return .MIX's modtime. */
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   356
} /* MIX_getLastModTime */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   357
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   358
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
   359
static fvoid *MIX_openRead(dvoid *opaque, const char *fnm, int *fileExists)
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   360
{
648
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   361
    MIXinfo *info = ((MIXinfo*) opaque);
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   362
    MIXfileinfo *finfo;
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   363
    MIXentry *entry;
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   364
    
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   365
    /* try to find this file */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   366
    entry = MIX_find_entry(info,fnm);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   367
    BAIL_IF_MACRO(entry == NULL, ERR_NO_SUCH_FILE, NULL);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   368
    
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   369
    /* allocate a MIX handle */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   370
    finfo = (MIXfileinfo *) malloc(sizeof (MIXfileinfo));
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   371
    BAIL_IF_MACRO(finfo == NULL, ERR_OUT_OF_MEMORY, NULL);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   372
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   373
    /* open the archive */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   374
    finfo->handle = __PHYSFS_platformOpenRead(info->filename);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   375
    if(!finfo->handle)
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   376
    {
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   377
        free(finfo);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   378
        return(NULL);
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
   379
    } /* if */
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   380
    
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   381
    /* setup structures */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   382
    finfo->cur_pos = 0;
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   383
    finfo->info = info;
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   384
    finfo->entry = entry;
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   385
    finfo->size = entry->end_offset - entry->start_offset;
648
5c993684b8f2 Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents: 631
diff changeset
   386
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
   387
    return(finfo);
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   388
} /* MIX_openRead */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   389
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   390
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
   391
static fvoid *MIX_openWrite(dvoid *opaque, const char *name)
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   392
{
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   393
    BAIL_MACRO(ERR_NOT_SUPPORTED, NULL);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   394
} /* MIX_openWrite */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   395
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   396
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
   397
static fvoid *MIX_openAppend(dvoid *opaque, const char *name)
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   398
{
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   399
    BAIL_MACRO(ERR_NOT_SUPPORTED, NULL);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   400
} /* MIX_openAppend */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   401
17fdeeaf7b51 Westwood MIX archive support.
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 int MIX_remove(dvoid *opaque, const char *name)
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   404
{
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   405
    BAIL_MACRO(ERR_NOT_SUPPORTED, 0);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   406
} /* MIX_remove */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   407
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   408
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
   409
static int MIX_mkdir(dvoid *opaque, const char *name)
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   410
{
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   411
    BAIL_MACRO(ERR_NOT_SUPPORTED, 0);
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   412
} /* MIX_mkdir */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   413
658
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   414
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   415
const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_MIX =
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   416
{
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   417
    "MIX",
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   418
    "Westwood archive (Tiberian Dawn / Red Alert)",
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   419
    "Sebastian Steinhauer <steini@steini-welt.de>",
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   420
    "http://icculus.org/physfs/",
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   421
};
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   422
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   423
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   424
const PHYSFS_Archiver __PHYSFS_Archiver_MIX =
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   425
{
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   426
    &__PHYSFS_ArchiveInfo_MIX,
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   427
    MIX_isArchive,          /* isArchive() method      */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   428
    MIX_openArchive,        /* openArchive() method    */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   429
    MIX_enumerateFiles,     /* enumerateFiles() method */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   430
    MIX_exists,             /* exists() method         */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   431
    MIX_isDirectory,        /* isDirectory() method    */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   432
    MIX_isSymLink,          /* isSymLink() method      */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   433
    MIX_getLastModTime,     /* getLastModTime() method */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   434
    MIX_openRead,           /* openRead() method       */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   435
    MIX_openWrite,          /* openWrite() method      */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   436
    MIX_openAppend,         /* openAppend() method     */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   437
    MIX_remove,             /* remove() method         */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   438
    MIX_mkdir,              /* mkdir() method          */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   439
    MIX_dirClose,           /* dirClose() method       */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   440
    MIX_read,               /* read() method           */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   441
    MIX_write,              /* write() method          */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   442
    MIX_eof,                /* eof() method            */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   443
    MIX_tell,               /* tell() method           */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   444
    MIX_seek,               /* seek() method           */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   445
    MIX_fileLength,         /* fileLength() method     */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   446
    MIX_fileClose           /* fileClose() method      */
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   447
};
1981818c6170 Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents: 657
diff changeset
   448
631
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   449
#endif  /* defined PHYSFS_SUPPORTS_MIX */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   450
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   451
/* end of mix.c ... */
17fdeeaf7b51 Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   452