author | Ryan C. Gordon <icculus@icculus.org> |
Wed, 29 Sep 2004 06:18:04 +0000 | |
changeset 658 | 1981818c6170 |
parent 657 | dad3b5c307a9 |
child 678 | 73a2641375a0 |
permissions | -rw-r--r-- |
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); |
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
631
diff
changeset
|
239 |
if (info->filename == NULL) |
631
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
240 |
{ |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
631
diff
changeset
|
241 |
__PHYSFS_setError(ERR_OUT_OF_MEMORY); |
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
631
diff
changeset
|
242 |
goto MIX_openArchive_failed; |
631
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
243 |
} /* if */ |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
244 |
|
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
245 |
/* store filename */ |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
631
diff
changeset
|
246 |
strcpy(info->filename, name); |
631
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
247 |
|
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
248 |
/* open the file */ |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
249 |
handle = __PHYSFS_platformOpenRead(name); |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
250 |
if (!handle) |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
631
diff
changeset
|
251 |
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
|
252 |
|
631
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
253 |
/* 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
|
254 |
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
|
255 |
(!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
|
256 |
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
|
257 |
|
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
631
diff
changeset
|
258 |
info->delta = 6 + (info->header.num_files * 12); |
631
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
259 |
|
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
260 |
/* 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
|
261 |
info->entry = malloc(sizeof (MIXentry) * 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
|
262 |
if (info->entry == NULL) |
631
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
263 |
{ |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
631
diff
changeset
|
264 |
__PHYSFS_setError(ERR_OUT_OF_MEMORY); |
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
631
diff
changeset
|
265 |
goto MIX_openArchive_failed; |
631
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
266 |
} /* if */ |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
267 |
|
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
268 |
/* read the directory list */ |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
269 |
for (i = 0; i < header.num_files; i++) |
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 |
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
|
272 |
(!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
|
273 |
(!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
|
274 |
goto MIX_openArchive_failed; |
631
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
275 |
} /* for */ |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
276 |
|
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
277 |
__PHYSFS_platformClose(handle); |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
278 |
|
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
631
diff
changeset
|
279 |
return(info); |
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
631
diff
changeset
|
280 |
|
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
631
diff
changeset
|
281 |
MIX_openArchive_failed: |
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
631
diff
changeset
|
282 |
if (info != NULL) |
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
631
diff
changeset
|
283 |
{ |
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
631
diff
changeset
|
284 |
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
|
285 |
free(info->filename); |
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
631
diff
changeset
|
286 |
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
|
287 |
free(info->entry); |
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
631
diff
changeset
|
288 |
free(info); |
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
631
diff
changeset
|
289 |
} /* if */ |
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
631
diff
changeset
|
290 |
|
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
631
diff
changeset
|
291 |
if (handle != NULL) |
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
631
diff
changeset
|
292 |
__PHYSFS_platformClose(handle); |
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
631
diff
changeset
|
293 |
|
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
631
diff
changeset
|
294 |
return(NULL); |
631
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
295 |
} /* MIX_openArchive */ |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
296 |
|
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
297 |
|
657
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
298 |
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
|
299 |
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
|
300 |
void *callbackdata) |
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 |
/* 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
|
303 |
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
|
304 |
{ |
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
305 |
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
|
306 |
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
|
307 |
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
|
308 |
char buffer[32]; |
631
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
309 |
|
657
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
310 |
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
|
311 |
{ |
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
312 |
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
|
313 |
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
|
314 |
} /* for */ |
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
315 |
} /* if */ |
631
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
316 |
} /* MIX_enumerateFiles */ |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
317 |
|
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 |
static MIXentry *MIX_find_entry(MIXinfo *info, const char *name) |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
320 |
{ |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
321 |
MIXentry *entry = info->entry; |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
322 |
PHYSFS_uint32 i, id; |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
323 |
|
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
324 |
/* create hash */ |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
325 |
id = MIX_hash(name); |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
326 |
|
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
327 |
/* look for this hash */ |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
328 |
for (i = 0; i < info->header.num_files; i++, 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 |
if (entry->hash == id) |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
331 |
return(entry); |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
332 |
} /* for */ |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
333 |
|
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
334 |
/* nothing found... :( */ |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
335 |
return(NULL); |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
336 |
} /* MIX_find_entry */ |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
337 |
|
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
338 |
|
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
|
339 |
static int MIX_exists(dvoid *opaque, const char *name) |
631
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
340 |
{ |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
631
diff
changeset
|
341 |
return(MIX_find_entry(((MIXinfo *) opaque), name) != NULL); |
631
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
342 |
} /* MIX_exists */ |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
343 |
|
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
344 |
|
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
|
345 |
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
|
346 |
{ |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
631
diff
changeset
|
347 |
*fileExists = MIX_exists(opaque, name); |
631
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
348 |
return(0); /* never directories in a MIX */ |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
349 |
} /* MIX_isDirectory */ |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
350 |
|
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
351 |
|
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
|
352 |
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
|
353 |
{ |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
631
diff
changeset
|
354 |
*fileExists = MIX_exists(opaque, name); |
631
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
355 |
return(0); /* never symlinks in a MIX. */ |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
356 |
} /* MIX_isSymLink */ |
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 PHYSFS_sint64 MIX_getLastModTime(dvoid *opaque, |
631
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
360 |
const char *name, |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
361 |
int *fileExists) |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
362 |
{ |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
631
diff
changeset
|
363 |
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
|
364 |
} /* MIX_getLastModTime */ |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
365 |
|
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
366 |
|
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
|
367 |
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
|
368 |
{ |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
631
diff
changeset
|
369 |
MIXinfo *info = ((MIXinfo*) opaque); |
631
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
370 |
MIXfileinfo *finfo; |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
371 |
MIXentry *entry; |
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 |
/* try to find this file */ |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
374 |
entry = MIX_find_entry(info,fnm); |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
375 |
BAIL_IF_MACRO(entry == NULL, ERR_NO_SUCH_FILE, NULL); |
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 |
/* allocate a MIX handle */ |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
378 |
finfo = (MIXfileinfo *) malloc(sizeof (MIXfileinfo)); |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
379 |
BAIL_IF_MACRO(finfo == NULL, ERR_OUT_OF_MEMORY, NULL); |
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 |
/* open the archive */ |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
382 |
finfo->handle = __PHYSFS_platformOpenRead(info->filename); |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
383 |
if(!finfo->handle) |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
384 |
{ |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
385 |
free(finfo); |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
386 |
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
|
387 |
} /* if */ |
631
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
388 |
|
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
389 |
/* setup structures */ |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
390 |
finfo->cur_pos = 0; |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
391 |
finfo->info = info; |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
392 |
finfo->entry = entry; |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
393 |
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
|
394 |
|
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
|
395 |
return(finfo); |
631
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
396 |
} /* MIX_openRead */ |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
397 |
|
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
398 |
|
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
|
399 |
static fvoid *MIX_openWrite(dvoid *opaque, const char *name) |
631
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
400 |
{ |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
401 |
BAIL_MACRO(ERR_NOT_SUPPORTED, NULL); |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
402 |
} /* MIX_openWrite */ |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
403 |
|
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
404 |
|
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
|
405 |
static fvoid *MIX_openAppend(dvoid *opaque, const char *name) |
631
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
406 |
{ |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
407 |
BAIL_MACRO(ERR_NOT_SUPPORTED, NULL); |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
408 |
} /* MIX_openAppend */ |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
409 |
|
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
410 |
|
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
|
411 |
static int MIX_remove(dvoid *opaque, const char *name) |
631
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
412 |
{ |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
413 |
BAIL_MACRO(ERR_NOT_SUPPORTED, 0); |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
414 |
} /* MIX_remove */ |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
415 |
|
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
416 |
|
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
|
417 |
static int MIX_mkdir(dvoid *opaque, const char *name) |
631
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
418 |
{ |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
419 |
BAIL_MACRO(ERR_NOT_SUPPORTED, 0); |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
420 |
} /* MIX_mkdir */ |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
421 |
|
658
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 |
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
|
424 |
{ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
425 |
"MIX", |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
426 |
"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
|
427 |
"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
|
428 |
"http://icculus.org/physfs/", |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
429 |
}; |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
430 |
|
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
431 |
|
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
432 |
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
|
433 |
{ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
434 |
&__PHYSFS_ArchiveInfo_MIX, |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
435 |
MIX_isArchive, /* isArchive() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
436 |
MIX_openArchive, /* openArchive() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
437 |
MIX_enumerateFiles, /* enumerateFiles() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
438 |
MIX_exists, /* exists() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
439 |
MIX_isDirectory, /* isDirectory() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
440 |
MIX_isSymLink, /* isSymLink() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
441 |
MIX_getLastModTime, /* getLastModTime() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
442 |
MIX_openRead, /* openRead() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
443 |
MIX_openWrite, /* openWrite() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
444 |
MIX_openAppend, /* openAppend() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
445 |
MIX_remove, /* remove() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
446 |
MIX_mkdir, /* mkdir() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
447 |
MIX_dirClose, /* dirClose() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
448 |
MIX_read, /* read() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
449 |
MIX_write, /* write() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
450 |
MIX_eof, /* eof() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
451 |
MIX_tell, /* tell() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
452 |
MIX_seek, /* seek() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
453 |
MIX_fileLength, /* fileLength() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
454 |
MIX_fileClose /* fileClose() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
455 |
}; |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
456 |
|
631
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
457 |
#endif /* defined PHYSFS_SUPPORTS_MIX */ |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
458 |
|
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
459 |
/* end of mix.c ... */ |
17fdeeaf7b51
Westwood MIX archive support.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
460 |