Skip to content

Latest commit

 

History

History
499 lines (393 loc) · 13.7 KB

archiver_wad.c

File metadata and controls

499 lines (393 loc) · 13.7 KB
 
Dec 15, 2003
Dec 15, 2003
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
* WAD support routines for PhysicsFS.
*
* This driver handles DOOM engine archives ("wads").
* This format (but not this driver) was designed by id Software for use
* with the DOOM engine.
* The specs of the format are from the unofficial doom specs v1.666
* found here: http://www.gamers.org/dhs/helpdocs/dmsp1666.html
* The format of the archive: (from the specs)
*
* A WAD file has three parts:
* (1) a twelve-byte header
* (2) one or more "lumps"
* (3) a directory or "info table" that contains the names, offsets, and
* sizes of all the lumps in the WAD
*
* The header consists of three four-byte parts:
* (a) an ASCII string which must be either "IWAD" or "PWAD"
* (b) a 4-byte (long) integer which is the number of lumps in the wad
* (c) a long integer which is the file offset to the start of
* the directory
*
* The directory has one 16-byte entry for every lump. Each entry consists
* of three parts:
*
* (a) a long integer, the file offset to the start of the lump
* (b) a long integer, the size of the lump in bytes
* (c) an 8-byte ASCII string, the name of the lump, padded with zeros.
* For example, the "DEMO1" entry in hexadecimal would be
* (44 45 4D 4F 31 00 00 00)
*
* Note that there is no way to tell if an opened WAD archive is a
* IWAD or PWAD with this archiver.
* I couldn't think of a way to provide that information, without being too
* hacky.
* I don't think it's really that important though.
*
*
Mar 11, 2007
Mar 11, 2007
39
* Please see the file LICENSE.txt in the source's root directory.
Dec 15, 2003
Dec 15, 2003
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
*
* This file written by Travis Wells, based on the GRP archiver by
* Ryan C. Gordon.
*/
#if (defined PHYSFS_SUPPORTS_WAD)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "physfs.h"
#define __PHYSICSFS_INTERNAL__
#include "physfs_internal.h"
typedef struct
{
Dec 18, 2003
Dec 18, 2003
57
char name[18];
Dec 15, 2003
Dec 15, 2003
58
59
60
61
62
63
PHYSFS_uint32 startPos;
PHYSFS_uint32 size;
} WADentry;
typedef struct
{
Aug 30, 2010
Aug 30, 2010
64
PHYSFS_Io *io;
Dec 15, 2003
Dec 15, 2003
65
66
67
68
69
70
PHYSFS_uint32 entryCount;
WADentry *entries;
} WADinfo;
typedef struct
{
Aug 30, 2010
Aug 30, 2010
71
PHYSFS_Io *io;
Dec 15, 2003
Dec 15, 2003
72
73
74
75
76
WADentry *entry;
PHYSFS_uint32 curPos;
} WADfileinfo;
Aug 30, 2010
Aug 30, 2010
77
78
79
80
81
82
static inline int readAll(PHYSFS_Io *io, void *buf, const PHYSFS_uint64 len)
{
return (io->read(io, buf, len) == len);
} /* readAll */
Sep 26, 2004
Sep 26, 2004
83
static void WAD_dirClose(dvoid *opaque)
Dec 15, 2003
Dec 15, 2003
84
{
Sep 26, 2004
Sep 26, 2004
85
WADinfo *info = ((WADinfo *) opaque);
Aug 30, 2010
Aug 30, 2010
86
info->io->destroy(info->io);
Mar 14, 2005
Mar 14, 2005
87
88
allocator.Free(info->entries);
allocator.Free(info);
Dec 15, 2003
Dec 15, 2003
89
90
91
} /* WAD_dirClose */
Aug 30, 2010
Aug 30, 2010
92
static PHYSFS_sint64 WAD_read(PHYSFS_Io *io, void *buffer, PHYSFS_uint64 len)
Dec 15, 2003
Dec 15, 2003
93
{
Aug 30, 2010
Aug 30, 2010
94
WADfileinfo *finfo = (WADfileinfo *) io->opaque;
Aug 21, 2010
Aug 21, 2010
95
96
const WADentry *entry = finfo->entry;
const PHYSFS_uint64 bytesLeft = (PHYSFS_uint64)(entry->size-finfo->curPos);
Dec 15, 2003
Dec 15, 2003
97
98
PHYSFS_sint64 rc;
Aug 21, 2010
Aug 21, 2010
99
100
if (bytesLeft < len)
len = bytesLeft;
Dec 15, 2003
Dec 15, 2003
101
Aug 30, 2010
Aug 30, 2010
102
rc = finfo->io->read(finfo->io, buffer, len);
Dec 15, 2003
Dec 15, 2003
103
if (rc > 0)
Aug 21, 2010
Aug 21, 2010
104
finfo->curPos += (PHYSFS_uint32) rc;
Dec 15, 2003
Dec 15, 2003
105
Jan 28, 2010
Jan 28, 2010
106
return rc;
Dec 15, 2003
Dec 15, 2003
107
108
109
} /* WAD_read */
Aug 30, 2010
Aug 30, 2010
110
static PHYSFS_sint64 WAD_write(PHYSFS_Io *io, const void *b, PHYSFS_uint64 len)
Dec 15, 2003
Dec 15, 2003
111
112
113
114
115
{
BAIL_MACRO(ERR_NOT_SUPPORTED, -1);
} /* WAD_write */
Aug 30, 2010
Aug 30, 2010
116
static PHYSFS_sint64 WAD_tell(PHYSFS_Io *io)
Dec 15, 2003
Dec 15, 2003
117
{
Aug 30, 2010
Aug 30, 2010
118
return ((WADfileinfo *) io->opaque)->curPos;
Dec 15, 2003
Dec 15, 2003
119
120
121
} /* WAD_tell */
Aug 30, 2010
Aug 30, 2010
122
static int WAD_seek(PHYSFS_Io *io, PHYSFS_uint64 offset)
Dec 15, 2003
Dec 15, 2003
123
{
Aug 30, 2010
Aug 30, 2010
124
125
WADfileinfo *finfo = (WADfileinfo *) io->opaque;
const WADentry *entry = finfo->entry;
Dec 15, 2003
Dec 15, 2003
126
127
128
int rc;
BAIL_IF_MACRO(offset >= entry->size, ERR_PAST_EOF, 0);
Aug 30, 2010
Aug 30, 2010
129
rc = finfo->io->seek(finfo->io, entry->startPos + offset);
Dec 15, 2003
Dec 15, 2003
130
131
132
if (rc)
finfo->curPos = (PHYSFS_uint32) offset;
Jan 28, 2010
Jan 28, 2010
133
return rc;
Dec 15, 2003
Dec 15, 2003
134
135
136
} /* WAD_seek */
Aug 30, 2010
Aug 30, 2010
137
static PHYSFS_sint64 WAD_length(PHYSFS_Io *io)
Dec 15, 2003
Dec 15, 2003
138
{
Aug 30, 2010
Aug 30, 2010
139
const WADfileinfo *finfo = (WADfileinfo *) io->opaque;
Jan 28, 2010
Jan 28, 2010
140
return ((PHYSFS_sint64) finfo->entry->size);
Aug 30, 2010
Aug 30, 2010
141
} /* WAD_length */
Dec 15, 2003
Dec 15, 2003
142
143
Aug 30, 2010
Aug 30, 2010
144
static PHYSFS_Io *WAD_duplicate(PHYSFS_Io *_io)
Dec 15, 2003
Dec 15, 2003
145
{
Aug 30, 2010
Aug 30, 2010
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
WADfileinfo *origfinfo = (WADfileinfo *) _io->opaque;
PHYSFS_Io *io = NULL;
PHYSFS_Io *retval = (PHYSFS_Io *) allocator.Malloc(sizeof (PHYSFS_Io));
WADfileinfo *finfo = (WADfileinfo *) allocator.Malloc(sizeof (WADfileinfo));
GOTO_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, WAD_duplicate_failed);
GOTO_IF_MACRO(finfo == NULL, ERR_OUT_OF_MEMORY, WAD_duplicate_failed);
io = origfinfo->io->duplicate(origfinfo->io);
GOTO_IF_MACRO(io == NULL, NULL, WAD_duplicate_failed);
finfo->io = io;
finfo->entry = origfinfo->entry;
finfo->curPos = 0;
memcpy(retval, _io, sizeof (PHYSFS_Io));
retval->opaque = finfo;
return retval;
WAD_duplicate_failed:
if (finfo != NULL) allocator.Free(finfo);
if (retval != NULL) allocator.Free(retval);
if (io != NULL) io->destroy(io);
return NULL;
} /* WAD_duplicate */
Dec 15, 2003
Dec 15, 2003
168
Aug 30, 2010
Aug 30, 2010
169
static int WAD_flush(PHYSFS_Io *io) { return 1; /* no write support. */ }
Dec 15, 2003
Dec 15, 2003
170
Aug 30, 2010
Aug 30, 2010
171
static void WAD_destroy(PHYSFS_Io *io)
Aug 21, 2010
Aug 21, 2010
172
{
Aug 30, 2010
Aug 30, 2010
173
174
175
176
177
WADfileinfo *finfo = (WADfileinfo *) io->opaque;
finfo->io->destroy(finfo->io);
allocator.Free(finfo);
allocator.Free(io);
} /* WAD_destroy */
Aug 21, 2010
Aug 21, 2010
178
179
Aug 30, 2010
Aug 30, 2010
180
static const PHYSFS_Io WAD_Io =
Dec 15, 2003
Dec 15, 2003
181
{
Aug 30, 2010
Aug 30, 2010
182
183
184
185
186
187
188
189
190
191
WAD_read,
WAD_write,
WAD_seek,
WAD_tell,
WAD_length,
WAD_duplicate,
WAD_flush,
WAD_destroy,
NULL
};
Dec 15, 2003
Dec 15, 2003
192
193
194
Aug 30, 2010
Aug 30, 2010
195
static int wadEntryCmp(void *_a, PHYSFS_uint32 one, PHYSFS_uint32 two)
Dec 15, 2003
Dec 15, 2003
196
{
Feb 20, 2008
Feb 20, 2008
197
198
199
if (one != two)
{
const WADentry *a = (const WADentry *) _a;
Aug 30, 2010
Aug 30, 2010
200
return __PHYSFS_stricmpASCII(a[one].name, a[two].name);
Feb 20, 2008
Feb 20, 2008
201
202
203
} /* if */
return 0;
Aug 30, 2010
Aug 30, 2010
204
} /* wadEntryCmp */
Dec 15, 2003
Dec 15, 2003
205
206
Aug 30, 2010
Aug 30, 2010
207
static void wadEntrySwap(void *_a, PHYSFS_uint32 one, PHYSFS_uint32 two)
Dec 15, 2003
Dec 15, 2003
208
{
Feb 20, 2008
Feb 20, 2008
209
210
211
212
213
214
215
216
217
if (one != two)
{
WADentry tmp;
WADentry *first = &(((WADentry *) _a)[one]);
WADentry *second = &(((WADentry *) _a)[two]);
memcpy(&tmp, first, sizeof (WADentry));
memcpy(first, second, sizeof (WADentry));
memcpy(second, &tmp, sizeof (WADentry));
} /* if */
Aug 30, 2010
Aug 30, 2010
218
} /* wadEntrySwap */
Dec 15, 2003
Dec 15, 2003
219
220
Aug 30, 2010
Aug 30, 2010
221
static int wad_load_entries(PHYSFS_Io *io, WADinfo *info)
Dec 15, 2003
Dec 15, 2003
222
{
Aug 30, 2010
Aug 30, 2010
223
PHYSFS_uint32 fileCount = info->entryCount;
Dec 15, 2003
Dec 15, 2003
224
225
PHYSFS_uint32 directoryOffset;
WADentry *entry;
Dec 18, 2003
Dec 18, 2003
226
Aug 30, 2010
Aug 30, 2010
227
228
BAIL_IF_MACRO(!readAll(io, &directoryOffset, 4), NULL, 0);
directoryOffset = PHYSFS_swapULE32(directoryOffset);
Dec 15, 2003
Dec 15, 2003
229
Mar 14, 2005
Mar 14, 2005
230
info->entries = (WADentry *) allocator.Malloc(sizeof(WADentry)*fileCount);
Aug 30, 2010
Aug 30, 2010
231
232
BAIL_IF_MACRO(info->entries == NULL, ERR_OUT_OF_MEMORY, 0);
BAIL_IF_MACRO(!io->seek(io, directoryOffset), NULL, 0);
Dec 15, 2003
Dec 15, 2003
233
234
235
for (entry = info->entries; fileCount > 0; fileCount--, entry++)
{
Aug 30, 2010
Aug 30, 2010
236
237
238
BAIL_IF_MACRO(!readAll(io, &entry->startPos, 4), NULL, 0);
BAIL_IF_MACRO(!readAll(io, &entry->size, 4), NULL, 0);
BAIL_IF_MACRO(!readAll(io, &entry->name, 8), NULL, 0);
Dec 15, 2003
Dec 15, 2003
239
240
241
242
243
244
entry->name[8] = '\0'; /* name might not be null-terminated in file. */
entry->size = PHYSFS_swapULE32(entry->size);
entry->startPos = PHYSFS_swapULE32(entry->startPos);
} /* for */
Aug 30, 2010
Aug 30, 2010
245
__PHYSFS_sort(info->entries, info->entryCount, wadEntryCmp, wadEntrySwap);
Jan 28, 2010
Jan 28, 2010
246
return 1;
Dec 15, 2003
Dec 15, 2003
247
248
249
} /* wad_load_entries */
Aug 30, 2010
Aug 30, 2010
250
static void *WAD_openArchive(PHYSFS_Io *io, const char *name, int forWriting)
Dec 15, 2003
Dec 15, 2003
251
{
Aug 30, 2010
Aug 30, 2010
252
253
254
PHYSFS_uint8 buf[4];
WADinfo *info = NULL;
PHYSFS_uint32 val = 0;
Dec 15, 2003
Dec 15, 2003
255
Aug 30, 2010
Aug 30, 2010
256
257
258
259
260
261
262
263
264
265
assert(io != NULL); /* shouldn't ever happen. */
BAIL_IF_MACRO(forWriting, ERR_ARC_IS_READ_ONLY, 0);
BAIL_IF_MACRO(!readAll(io, buf, sizeof (buf)), NULL, NULL);
if ((memcmp(buf, "IWAD", 4) != 0) && (memcmp(buf, "PWAD", 4) != 0))
GOTO_MACRO(ERR_NOT_AN_ARCHIVE, WAD_openArchive_failed);
info = (WADinfo *) allocator.Malloc(sizeof (WADinfo));
GOTO_IF_MACRO(info == NULL, ERR_OUT_OF_MEMORY, WAD_openArchive_failed);
Dec 15, 2003
Dec 15, 2003
266
memset(info, '\0', sizeof (WADinfo));
Aug 30, 2010
Aug 30, 2010
267
info->io = io;
Dec 15, 2003
Dec 15, 2003
268
Aug 30, 2010
Aug 30, 2010
269
270
GOTO_IF_MACRO(!readAll(io,&val,sizeof(val)), NULL, WAD_openArchive_failed);
info->entryCount = PHYSFS_swapULE32(val);
Dec 15, 2003
Dec 15, 2003
271
Aug 30, 2010
Aug 30, 2010
272
GOTO_IF_MACRO(!wad_load_entries(io, info), NULL, WAD_openArchive_failed);
Dec 15, 2003
Dec 15, 2003
273
Jan 28, 2010
Jan 28, 2010
274
return info;
Dec 15, 2003
Dec 15, 2003
275
276
WAD_openArchive_failed:
Sep 26, 2004
Sep 26, 2004
277
if (info != NULL)
Dec 15, 2003
Dec 15, 2003
278
{
Sep 26, 2004
Sep 26, 2004
279
if (info->entries != NULL)
Mar 14, 2005
Mar 14, 2005
280
281
allocator.Free(info->entries);
allocator.Free(info);
Dec 15, 2003
Dec 15, 2003
282
283
} /* if */
Jan 28, 2010
Jan 28, 2010
284
return NULL;
Dec 15, 2003
Dec 15, 2003
285
286
287
} /* WAD_openArchive */
Sep 29, 2004
Sep 29, 2004
288
static void WAD_enumerateFiles(dvoid *opaque, const char *dname,
Sep 18, 2005
Sep 18, 2005
289
290
int omitSymLinks, PHYSFS_EnumFilesCallback cb,
const char *origdir, void *callbackdata)
Dec 15, 2003
Dec 15, 2003
291
{
Aug 30, 2010
Aug 30, 2010
292
293
/* no directories in WAD files. */
if (*dname == '\0')
Dec 18, 2003
Dec 18, 2003
294
{
Aug 30, 2010
Aug 30, 2010
295
296
297
298
299
WADinfo *info = (WADinfo *) opaque;
WADentry *entry = info->entries;
PHYSFS_uint32 max = info->entryCount;
PHYSFS_uint32 i;
Dec 18, 2003
Dec 18, 2003
300
for (i = 0; i < max; i++, entry++)
Aug 30, 2010
Aug 30, 2010
301
cb(callbackdata, origdir, entry->name);
Dec 18, 2003
Dec 18, 2003
302
} /* if */
Dec 15, 2003
Dec 15, 2003
303
304
305
} /* WAD_enumerateFiles */
Feb 15, 2010
Feb 15, 2010
306
static WADentry *wad_find_entry(const WADinfo *info, const char *name)
Dec 15, 2003
Dec 15, 2003
307
{
Aug 30, 2010
Aug 30, 2010
308
char *ptr = strchr(name, '.');
Dec 15, 2003
Dec 15, 2003
309
310
311
312
313
314
WADentry *a = info->entries;
PHYSFS_sint32 lo = 0;
PHYSFS_sint32 hi = (PHYSFS_sint32) (info->entryCount - 1);
PHYSFS_sint32 middle;
int rc;
Aug 30, 2010
Aug 30, 2010
315
316
317
318
319
320
321
322
/*
* Rule out filenames to avoid unneeded processing...no dirs,
* big filenames, or extensions.
*/
BAIL_IF_MACRO(ptr != NULL, ERR_NO_SUCH_FILE, NULL);
BAIL_IF_MACRO(strlen(name) > 8, ERR_NO_SUCH_FILE, NULL);
BAIL_IF_MACRO(strchr(name, '/') != NULL, ERR_NO_SUCH_FILE, NULL);
Dec 15, 2003
Dec 15, 2003
323
324
325
while (lo <= hi)
{
middle = lo + ((hi - lo) / 2);
Aug 30, 2010
Aug 30, 2010
326
rc = __PHYSFS_stricmpASCII(name, a[middle].name);
Dec 15, 2003
Dec 15, 2003
327
if (rc == 0) /* found it! */
Jan 28, 2010
Jan 28, 2010
328
return &a[middle];
Dec 15, 2003
Dec 15, 2003
329
330
331
332
333
334
335
336
337
338
else if (rc > 0)
lo = middle + 1;
else
hi = middle - 1;
} /* while */
BAIL_MACRO(ERR_NO_SUCH_FILE, NULL);
} /* wad_find_entry */
Sep 26, 2004
Sep 26, 2004
339
static int WAD_exists(dvoid *opaque, const char *name)
Dec 15, 2003
Dec 15, 2003
340
{
Jan 28, 2010
Jan 28, 2010
341
return (wad_find_entry((WADinfo *) opaque, name) != NULL);
Dec 15, 2003
Dec 15, 2003
342
343
344
} /* WAD_exists */
Sep 26, 2004
Sep 26, 2004
345
static int WAD_isDirectory(dvoid *opaque, const char *name, int *fileExists)
Dec 15, 2003
Dec 15, 2003
346
{
Sep 26, 2004
Sep 26, 2004
347
WADentry *entry = wad_find_entry(((WADinfo *) opaque), name);
Aug 30, 2010
Aug 30, 2010
348
349
350
const int exists = (entry != NULL);
*fileExists = exists;
if (exists)
Dec 18, 2003
Dec 18, 2003
351
352
353
354
355
{
char *n;
/* Can't be a directory if it's a subdirectory. */
if (strchr(entry->name, '/') != NULL)
Jan 28, 2010
Jan 28, 2010
356
return 0;
Dec 18, 2003
Dec 18, 2003
357
Aug 30, 2010
Aug 30, 2010
358
359
/* !!! FIXME: this isn't really something we should do. */
/* !!! FIXME: I probably broke enumeration up there, too. */
Dec 18, 2003
Dec 18, 2003
360
361
362
363
364
/* Check if it matches "MAP??" or "E?M?" ... */
n = entry->name;
if ((n[0] == 'E' && n[2] == 'M') ||
(n[0] == 'M' && n[1] == 'A' && n[2] == 'P' && n[6] == 0))
{
Jan 28, 2010
Jan 28, 2010
365
return 1;
Dec 18, 2003
Dec 18, 2003
366
367
} /* if */
} /* if */
Aug 30, 2010
Aug 30, 2010
368
369
return 0;
Dec 15, 2003
Dec 15, 2003
370
371
372
} /* WAD_isDirectory */
Sep 26, 2004
Sep 26, 2004
373
static int WAD_isSymLink(dvoid *opaque, const char *name, int *fileExists)
Dec 15, 2003
Dec 15, 2003
374
{
Sep 26, 2004
Sep 26, 2004
375
*fileExists = WAD_exists(opaque, name);
Jan 28, 2010
Jan 28, 2010
376
return 0; /* never symlinks in a wad. */
Dec 15, 2003
Dec 15, 2003
377
378
379
} /* WAD_isSymLink */
Aug 30, 2010
Aug 30, 2010
380
static PHYSFS_Io *WAD_openRead(dvoid *opaque, const char *fnm, int *fileExists)
Dec 15, 2003
Dec 15, 2003
381
{
Aug 30, 2010
Aug 30, 2010
382
383
PHYSFS_Io *retval = NULL;
WADinfo *info = (WADinfo *) opaque;
Dec 15, 2003
Dec 15, 2003
384
385
386
387
388
WADfileinfo *finfo;
WADentry *entry;
entry = wad_find_entry(info, fnm);
*fileExists = (entry != NULL);
Aug 30, 2010
Aug 30, 2010
389
390
391
392
GOTO_IF_MACRO(entry == NULL, NULL, WAD_openRead_failed);
retval = (PHYSFS_Io *) allocator.Malloc(sizeof (PHYSFS_Io));
GOTO_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, WAD_openRead_failed);
Dec 15, 2003
Dec 15, 2003
393
Mar 14, 2005
Mar 14, 2005
394
finfo = (WADfileinfo *) allocator.Malloc(sizeof (WADfileinfo));
Aug 30, 2010
Aug 30, 2010
395
GOTO_IF_MACRO(finfo == NULL, ERR_OUT_OF_MEMORY, WAD_openRead_failed);
Dec 15, 2003
Dec 15, 2003
396
Aug 30, 2010
Aug 30, 2010
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
finfo->io = info->io->duplicate(info->io);
GOTO_IF_MACRO(finfo->io == NULL, NULL, WAD_openRead_failed);
if (!finfo->io->seek(finfo->io, entry->startPos))
GOTO_MACRO(NULL, WAD_openRead_failed);
finfo->curPos = 0;
finfo->entry = entry;
memcpy(retval, &WAD_Io, sizeof (*retval));
retval->opaque = finfo;
return retval;
WAD_openRead_failed:
if (finfo != NULL)
Dec 15, 2003
Dec 15, 2003
412
{
Aug 30, 2010
Aug 30, 2010
413
414
if (finfo->io != NULL)
finfo->io->destroy(finfo->io);
Mar 14, 2005
Mar 14, 2005
415
allocator.Free(finfo);
Dec 15, 2003
Dec 15, 2003
416
417
} /* if */
Aug 30, 2010
Aug 30, 2010
418
419
420
421
if (retval != NULL)
allocator.Free(retval);
return NULL;
Dec 15, 2003
Dec 15, 2003
422
423
424
} /* WAD_openRead */
Aug 30, 2010
Aug 30, 2010
425
static PHYSFS_Io *WAD_openWrite(dvoid *opaque, const char *name)
Dec 15, 2003
Dec 15, 2003
426
427
428
429
430
{
BAIL_MACRO(ERR_NOT_SUPPORTED, NULL);
} /* WAD_openWrite */
Aug 30, 2010
Aug 30, 2010
431
static PHYSFS_Io *WAD_openAppend(dvoid *opaque, const char *name)
Dec 15, 2003
Dec 15, 2003
432
433
434
435
436
{
BAIL_MACRO(ERR_NOT_SUPPORTED, NULL);
} /* WAD_openAppend */
Sep 26, 2004
Sep 26, 2004
437
static int WAD_remove(dvoid *opaque, const char *name)
Dec 15, 2003
Dec 15, 2003
438
439
440
441
442
{
BAIL_MACRO(ERR_NOT_SUPPORTED, 0);
} /* WAD_remove */
Sep 26, 2004
Sep 26, 2004
443
static int WAD_mkdir(dvoid *opaque, const char *name)
Dec 15, 2003
Dec 15, 2003
444
445
446
447
{
BAIL_MACRO(ERR_NOT_SUPPORTED, 0);
} /* WAD_mkdir */
Sep 29, 2004
Sep 29, 2004
448
Aug 22, 2010
Aug 22, 2010
449
static int WAD_stat(dvoid *opaque, const char *filename, int *exists,
Feb 15, 2010
Feb 15, 2010
450
451
452
453
454
455
456
457
458
459
460
PHYSFS_Stat *stat)
{
const WADinfo *info = (const WADinfo *) opaque;
const WADentry *entry = wad_find_entry(info, filename);
*exists = (entry != 0);
if (!entry)
return 0;
stat->filesize = entry->size;
stat->filetype = PHYSFS_FILETYPE_REGULAR;
Aug 25, 2010
Aug 25, 2010
461
462
stat->modtime = -1;
stat->createtime = -1;
Aug 30, 2010
Aug 30, 2010
463
464
stat->accesstime = -1;
stat->readonly = 1;
Feb 15, 2010
Feb 15, 2010
465
Aug 21, 2010
Aug 21, 2010
466
return 1;
Feb 15, 2010
Feb 15, 2010
467
468
469
} /* WAD_stat */
Sep 29, 2004
Sep 29, 2004
470
471
472
const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_WAD =
{
"WAD",
Mar 16, 2005
Mar 16, 2005
473
WAD_ARCHIVE_DESCRIPTION,
Sep 29, 2004
Sep 29, 2004
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
"Travis Wells <traviswells@mchsi.com>",
"http://www.3dmm2.com/doom/",
};
const PHYSFS_Archiver __PHYSFS_Archiver_WAD =
{
&__PHYSFS_ArchiveInfo_WAD,
WAD_openArchive, /* openArchive() method */
WAD_enumerateFiles, /* enumerateFiles() method */
WAD_exists, /* exists() method */
WAD_isDirectory, /* isDirectory() method */
WAD_isSymLink, /* isSymLink() method */
WAD_openRead, /* openRead() method */
WAD_openWrite, /* openWrite() method */
WAD_openAppend, /* openAppend() method */
WAD_remove, /* remove() method */
WAD_mkdir, /* mkdir() method */
WAD_dirClose, /* dirClose() method */
Aug 30, 2010
Aug 30, 2010
493
WAD_stat /* stat() method */
Sep 29, 2004
Sep 29, 2004
494
495
};
Dec 15, 2003
Dec 15, 2003
496
497
498
#endif /* defined PHYSFS_SUPPORTS_WAD */
/* end of wad.c ... */