author | Ryan C. Gordon <icculus@icculus.org> |
Sun, 22 Aug 2010 03:35:55 -0400 | |
changeset 1109 | c69df75dbcc3 |
parent 1108 | b63e39d5be04 |
child 1111 | 20d7c2d95a98 |
permissions | -rw-r--r-- |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
1 |
/* |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
2 |
* QPAK support routines for PhysicsFS. |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
3 |
* |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
4 |
* This archiver handles the archive format utilized by Quake 1 and 2. |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
5 |
* Quake3-based games use the PkZip/Info-Zip format (which our zip.c |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
6 |
* archiver handles). |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
7 |
* |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
8 |
* ======================================================================== |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
9 |
* |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
10 |
* This format info (in more detail) comes from: |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
11 |
* http://debian.fmi.uni-sofia.bg/~sergei/cgsr/docs/pak.txt |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
12 |
* |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
13 |
* Quake PAK Format |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
14 |
* |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
15 |
* Header |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
16 |
* (4 bytes) signature = 'PACK' |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
17 |
* (4 bytes) directory offset |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
18 |
* (4 bytes) directory length |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
19 |
* |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
20 |
* Directory |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
21 |
* (56 bytes) file name |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
22 |
* (4 bytes) file position |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
23 |
* (4 bytes) file length |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
24 |
* |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
25 |
* ======================================================================== |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
26 |
* |
809
116b8fe30371
Renamed LICENSE to LICENSE.txt
Ryan C. Gordon <icculus@icculus.org>
parents:
808
diff
changeset
|
27 |
* Please see the file LICENSE.txt in the source's root directory. |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
28 |
* |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
29 |
* This file written by Ryan C. Gordon. |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
30 |
*/ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
31 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
32 |
#if (defined PHYSFS_SUPPORTS_QPAK) |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
33 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
34 |
#include <stdio.h> |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
35 |
#include <stdlib.h> |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
36 |
#include <string.h> |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
37 |
#include "physfs.h" |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
38 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
39 |
#define __PHYSICSFS_INTERNAL__ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
40 |
#include "physfs_internal.h" |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
41 |
|
597
e84664806f86
Made QPAK archiver case insensitive again.
Ryan C. Gordon <icculus@icculus.org>
parents:
589
diff
changeset
|
42 |
#if 1 /* Make this case insensitive? */ |
828
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
43 |
#define QPAK_strcmp(x, y) __PHYSFS_stricmpASCII(x, y) |
ee871d51510d
Bunch of work on Unicode...added case-folding stricmp, removed
Ryan C. Gordon <icculus@icculus.org>
parents:
809
diff
changeset
|
44 |
#define QPAK_strncmp(x, y, z) __PHYSFS_strnicmpASCII(x, y, z) |
597
e84664806f86
Made QPAK archiver case insensitive again.
Ryan C. Gordon <icculus@icculus.org>
parents:
589
diff
changeset
|
45 |
#else |
e84664806f86
Made QPAK archiver case insensitive again.
Ryan C. Gordon <icculus@icculus.org>
parents:
589
diff
changeset
|
46 |
#define QPAK_strcmp(x, y) strcmp(x, y) |
e84664806f86
Made QPAK archiver case insensitive again.
Ryan C. Gordon <icculus@icculus.org>
parents:
589
diff
changeset
|
47 |
#define QPAK_strncmp(x, y, z) strncmp(x, y, z) |
e84664806f86
Made QPAK archiver case insensitive again.
Ryan C. Gordon <icculus@icculus.org>
parents:
589
diff
changeset
|
48 |
#endif |
e84664806f86
Made QPAK archiver case insensitive again.
Ryan C. Gordon <icculus@icculus.org>
parents:
589
diff
changeset
|
49 |
|
e84664806f86
Made QPAK archiver case insensitive again.
Ryan C. Gordon <icculus@icculus.org>
parents:
589
diff
changeset
|
50 |
|
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
51 |
typedef struct |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
52 |
{ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
53 |
char name[56]; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
54 |
PHYSFS_uint32 startPos; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
55 |
PHYSFS_uint32 size; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
56 |
} QPAKentry; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
57 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
58 |
typedef struct |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
59 |
{ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
60 |
char *filename; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
61 |
PHYSFS_sint64 last_mod_time; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
62 |
PHYSFS_uint32 entryCount; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
63 |
QPAKentry *entries; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
64 |
} QPAKinfo; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
65 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
66 |
typedef struct |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
67 |
{ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
68 |
void *handle; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
69 |
QPAKentry *entry; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
70 |
PHYSFS_uint32 curPos; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
71 |
} QPAKfileinfo; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
72 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
73 |
/* Magic numbers... */ |
678
73a2641375a0
Cleaned up some minor bloat with my new evil GOTO_*_MACRO macros.
Ryan C. Gordon <icculus@icculus.org>
parents:
658
diff
changeset
|
74 |
#define QPAK_SIG 0x4b434150 /* "PACK" in ASCII. */ |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
75 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
76 |
|
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
|
77 |
static void QPAK_dirClose(dvoid *opaque) |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
78 |
{ |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
597
diff
changeset
|
79 |
QPAKinfo *info = ((QPAKinfo *) opaque); |
691
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
678
diff
changeset
|
80 |
allocator.Free(info->filename); |
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
678
diff
changeset
|
81 |
allocator.Free(info->entries); |
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
678
diff
changeset
|
82 |
allocator.Free(info); |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
83 |
} /* QPAK_dirClose */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
84 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
85 |
|
1098
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1054
diff
changeset
|
86 |
static PHYSFS_sint64 QPAK_read(fvoid *opaque, void *buffer, PHYSFS_uint64 len) |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
87 |
{ |
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
|
88 |
QPAKfileinfo *finfo = (QPAKfileinfo *) opaque; |
1098
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1054
diff
changeset
|
89 |
const QPAKentry *entry = finfo->entry; |
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1054
diff
changeset
|
90 |
const PHYSFS_uint64 bytesLeft = (PHYSFS_uint64)(entry->size-finfo->curPos); |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
91 |
PHYSFS_sint64 rc; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
92 |
|
1098
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1054
diff
changeset
|
93 |
if (bytesLeft < len) |
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1054
diff
changeset
|
94 |
len = bytesLeft; |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
95 |
|
1098
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1054
diff
changeset
|
96 |
rc = __PHYSFS_platformRead(finfo->handle, buffer, len); |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
97 |
if (rc > 0) |
1098
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1054
diff
changeset
|
98 |
finfo->curPos += (PHYSFS_uint32) rc; |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
99 |
|
1016
957c97389257
Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents:
972
diff
changeset
|
100 |
return rc; |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
101 |
} /* QPAK_read */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
102 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
103 |
|
1098
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1054
diff
changeset
|
104 |
static PHYSFS_sint64 QPAK_write(fvoid *f, const void *buf, PHYSFS_uint64 len) |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
105 |
{ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
106 |
BAIL_MACRO(ERR_NOT_SUPPORTED, -1); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
107 |
} /* QPAK_write */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
108 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
109 |
|
650
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
110 |
static int QPAK_eof(fvoid *opaque) |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
111 |
{ |
650
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
112 |
QPAKfileinfo *finfo = (QPAKfileinfo *) opaque; |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
113 |
QPAKentry *entry = finfo->entry; |
1016
957c97389257
Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents:
972
diff
changeset
|
114 |
return (finfo->curPos >= entry->size); |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
115 |
} /* QPAK_eof */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
116 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
117 |
|
650
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
118 |
static PHYSFS_sint64 QPAK_tell(fvoid *opaque) |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
119 |
{ |
1016
957c97389257
Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents:
972
diff
changeset
|
120 |
return ((QPAKfileinfo *) opaque)->curPos; |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
121 |
} /* QPAK_tell */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
122 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
123 |
|
650
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
124 |
static int QPAK_seek(fvoid *opaque, PHYSFS_uint64 offset) |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
125 |
{ |
650
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
126 |
QPAKfileinfo *finfo = (QPAKfileinfo *) opaque; |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
127 |
QPAKentry *entry = finfo->entry; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
128 |
int rc; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
129 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
130 |
BAIL_IF_MACRO(offset < 0, ERR_INVALID_ARGUMENT, 0); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
131 |
BAIL_IF_MACRO(offset >= entry->size, ERR_PAST_EOF, 0); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
132 |
rc = __PHYSFS_platformSeek(finfo->handle, entry->startPos + offset); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
133 |
if (rc) |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
134 |
finfo->curPos = (PHYSFS_uint32) offset; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
135 |
|
1016
957c97389257
Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents:
972
diff
changeset
|
136 |
return rc; |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
137 |
} /* QPAK_seek */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
138 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
139 |
|
650
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
140 |
static PHYSFS_sint64 QPAK_fileLength(fvoid *opaque) |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
141 |
{ |
650
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
142 |
QPAKfileinfo *finfo = (QPAKfileinfo *) opaque; |
1016
957c97389257
Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents:
972
diff
changeset
|
143 |
return ((PHYSFS_sint64) finfo->entry->size); |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
144 |
} /* QPAK_fileLength */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
145 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
146 |
|
650
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
147 |
static int QPAK_fileClose(fvoid *opaque) |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
148 |
{ |
650
298b8bb26775
Did the same thing to FileHandles than I did to DirHandles, but this
Ryan C. Gordon <icculus@icculus.org>
parents:
648
diff
changeset
|
149 |
QPAKfileinfo *finfo = (QPAKfileinfo *) opaque; |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
150 |
BAIL_IF_MACRO(!__PHYSFS_platformClose(finfo->handle), NULL, 0); |
691
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
678
diff
changeset
|
151 |
allocator.Free(finfo); |
1016
957c97389257
Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents:
972
diff
changeset
|
152 |
return 1; |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
153 |
} /* QPAK_fileClose */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
154 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
155 |
|
1098
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1054
diff
changeset
|
156 |
static inline int readAll(void *fh, void *buf, const PHYSFS_uint64 len) |
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1054
diff
changeset
|
157 |
{ |
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1054
diff
changeset
|
158 |
return (__PHYSFS_platformRead(fh, buf, len) == len); |
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1054
diff
changeset
|
159 |
} /* readAll */ |
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1054
diff
changeset
|
160 |
|
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
161 |
static int qpak_open(const char *filename, int forWriting, |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
162 |
void **fh, PHYSFS_uint32 *count) |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
163 |
{ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
164 |
PHYSFS_uint32 buf; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
165 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
166 |
*fh = NULL; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
167 |
BAIL_IF_MACRO(forWriting, ERR_ARC_IS_READ_ONLY, 0); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
168 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
169 |
*fh = __PHYSFS_platformOpenRead(filename); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
170 |
BAIL_IF_MACRO(*fh == NULL, NULL, 0); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
171 |
|
1098
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1054
diff
changeset
|
172 |
if (!readAll(*fh, &buf, sizeof (PHYSFS_uint32))) |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
173 |
goto openQpak_failed; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
174 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
175 |
buf = PHYSFS_swapULE32(buf); |
678
73a2641375a0
Cleaned up some minor bloat with my new evil GOTO_*_MACRO macros.
Ryan C. Gordon <icculus@icculus.org>
parents:
658
diff
changeset
|
176 |
GOTO_IF_MACRO(buf != QPAK_SIG, ERR_UNSUPPORTED_ARCHIVE, openQpak_failed); |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
177 |
|
1098
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1054
diff
changeset
|
178 |
if (!readAll(*fh, &buf, sizeof (PHYSFS_uint32))) |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
179 |
goto openQpak_failed; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
180 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
181 |
buf = PHYSFS_swapULE32(buf); /* directory table offset. */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
182 |
|
1098
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1054
diff
changeset
|
183 |
if (!readAll(*fh, count, sizeof (PHYSFS_uint32))) |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
184 |
goto openQpak_failed; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
185 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
186 |
*count = PHYSFS_swapULE32(*count); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
187 |
|
678
73a2641375a0
Cleaned up some minor bloat with my new evil GOTO_*_MACRO macros.
Ryan C. Gordon <icculus@icculus.org>
parents:
658
diff
changeset
|
188 |
/* corrupted archive? */ |
73a2641375a0
Cleaned up some minor bloat with my new evil GOTO_*_MACRO macros.
Ryan C. Gordon <icculus@icculus.org>
parents:
658
diff
changeset
|
189 |
GOTO_IF_MACRO((*count % 64) != 0, ERR_CORRUPTED, openQpak_failed); |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
190 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
191 |
if (!__PHYSFS_platformSeek(*fh, buf)) |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
192 |
goto openQpak_failed; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
193 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
194 |
*count /= 64; |
1016
957c97389257
Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents:
972
diff
changeset
|
195 |
return 1; |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
196 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
197 |
openQpak_failed: |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
198 |
if (*fh != NULL) |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
199 |
__PHYSFS_platformClose(*fh); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
200 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
201 |
*count = -1; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
202 |
*fh = NULL; |
1016
957c97389257
Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents:
972
diff
changeset
|
203 |
return 0; |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
204 |
} /* qpak_open */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
205 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
206 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
207 |
static int QPAK_isArchive(const char *filename, int forWriting) |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
208 |
{ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
209 |
void *fh; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
210 |
PHYSFS_uint32 fileCount; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
211 |
int retval = qpak_open(filename, forWriting, &fh, &fileCount); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
212 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
213 |
if (fh != NULL) |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
214 |
__PHYSFS_platformClose(fh); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
215 |
|
1016
957c97389257
Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents:
972
diff
changeset
|
216 |
return retval; |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
217 |
} /* QPAK_isArchive */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
218 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
219 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
220 |
static int qpak_entry_cmp(void *_a, PHYSFS_uint32 one, PHYSFS_uint32 two) |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
221 |
{ |
928
0e37b8163248
Various archiver swap and compare functions now check if they are
Ryan C. Gordon <icculus@icculus.org>
parents:
852
diff
changeset
|
222 |
if (one != two) |
0e37b8163248
Various archiver swap and compare functions now check if they are
Ryan C. Gordon <icculus@icculus.org>
parents:
852
diff
changeset
|
223 |
{ |
0e37b8163248
Various archiver swap and compare functions now check if they are
Ryan C. Gordon <icculus@icculus.org>
parents:
852
diff
changeset
|
224 |
const QPAKentry *a = (const QPAKentry *) _a; |
1016
957c97389257
Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents:
972
diff
changeset
|
225 |
return QPAK_strcmp(a[one].name, a[two].name); |
928
0e37b8163248
Various archiver swap and compare functions now check if they are
Ryan C. Gordon <icculus@icculus.org>
parents:
852
diff
changeset
|
226 |
} /* if */ |
0e37b8163248
Various archiver swap and compare functions now check if they are
Ryan C. Gordon <icculus@icculus.org>
parents:
852
diff
changeset
|
227 |
|
0e37b8163248
Various archiver swap and compare functions now check if they are
Ryan C. Gordon <icculus@icculus.org>
parents:
852
diff
changeset
|
228 |
return 0; |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
229 |
} /* qpak_entry_cmp */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
230 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
231 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
232 |
static void qpak_entry_swap(void *_a, PHYSFS_uint32 one, PHYSFS_uint32 two) |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
233 |
{ |
928
0e37b8163248
Various archiver swap and compare functions now check if they are
Ryan C. Gordon <icculus@icculus.org>
parents:
852
diff
changeset
|
234 |
if (one != two) |
0e37b8163248
Various archiver swap and compare functions now check if they are
Ryan C. Gordon <icculus@icculus.org>
parents:
852
diff
changeset
|
235 |
{ |
0e37b8163248
Various archiver swap and compare functions now check if they are
Ryan C. Gordon <icculus@icculus.org>
parents:
852
diff
changeset
|
236 |
QPAKentry tmp; |
0e37b8163248
Various archiver swap and compare functions now check if they are
Ryan C. Gordon <icculus@icculus.org>
parents:
852
diff
changeset
|
237 |
QPAKentry *first = &(((QPAKentry *) _a)[one]); |
0e37b8163248
Various archiver swap and compare functions now check if they are
Ryan C. Gordon <icculus@icculus.org>
parents:
852
diff
changeset
|
238 |
QPAKentry *second = &(((QPAKentry *) _a)[two]); |
0e37b8163248
Various archiver swap and compare functions now check if they are
Ryan C. Gordon <icculus@icculus.org>
parents:
852
diff
changeset
|
239 |
memcpy(&tmp, first, sizeof (QPAKentry)); |
0e37b8163248
Various archiver swap and compare functions now check if they are
Ryan C. Gordon <icculus@icculus.org>
parents:
852
diff
changeset
|
240 |
memcpy(first, second, sizeof (QPAKentry)); |
0e37b8163248
Various archiver swap and compare functions now check if they are
Ryan C. Gordon <icculus@icculus.org>
parents:
852
diff
changeset
|
241 |
memcpy(second, &tmp, sizeof (QPAKentry)); |
0e37b8163248
Various archiver swap and compare functions now check if they are
Ryan C. Gordon <icculus@icculus.org>
parents:
852
diff
changeset
|
242 |
} /* if */ |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
243 |
} /* qpak_entry_swap */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
244 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
245 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
246 |
static int qpak_load_entries(const char *name, int forWriting, QPAKinfo *info) |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
247 |
{ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
248 |
void *fh = NULL; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
249 |
PHYSFS_uint32 fileCount; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
250 |
QPAKentry *entry; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
251 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
252 |
BAIL_IF_MACRO(!qpak_open(name, forWriting, &fh, &fileCount), NULL, 0); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
253 |
info->entryCount = fileCount; |
691
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
678
diff
changeset
|
254 |
info->entries = (QPAKentry*) allocator.Malloc(sizeof(QPAKentry)*fileCount); |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
255 |
if (info->entries == NULL) |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
256 |
{ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
257 |
__PHYSFS_platformClose(fh); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
258 |
BAIL_MACRO(ERR_OUT_OF_MEMORY, 0); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
259 |
} /* if */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
260 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
261 |
for (entry = info->entries; fileCount > 0; fileCount--, entry++) |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
262 |
{ |
1098
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1054
diff
changeset
|
263 |
if ( (!readAll(fh, &entry->name, sizeof (entry->name))) || |
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1054
diff
changeset
|
264 |
(!readAll(fh, &entry->startPos, sizeof (entry->startPos))) || |
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1054
diff
changeset
|
265 |
(!readAll(fh, &entry->size, sizeof(entry->size))) ) |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
266 |
{ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
267 |
__PHYSFS_platformClose(fh); |
1016
957c97389257
Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents:
972
diff
changeset
|
268 |
return 0; |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
269 |
} /* if */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
270 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
271 |
entry->size = PHYSFS_swapULE32(entry->size); |
1098
4e86cec1143f
Moved all the file i/o from stdio-style to POSIX-style.
Ryan C. Gordon <icculus@icculus.org>
parents:
1054
diff
changeset
|
272 |
entry->startPos = PHYSFS_swapULE32(entry->startPos); |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
273 |
} /* for */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
274 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
275 |
__PHYSFS_platformClose(fh); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
276 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
277 |
__PHYSFS_sort(info->entries, info->entryCount, |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
278 |
qpak_entry_cmp, qpak_entry_swap); |
1016
957c97389257
Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents:
972
diff
changeset
|
279 |
return 1; |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
280 |
} /* qpak_load_entries */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
281 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
282 |
|
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
597
diff
changeset
|
283 |
static void *QPAK_openArchive(const char *name, int forWriting) |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
284 |
{ |
691
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
678
diff
changeset
|
285 |
QPAKinfo *info = (QPAKinfo *) allocator.Malloc(sizeof (QPAKinfo)); |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
286 |
PHYSFS_sint64 modtime = __PHYSFS_platformGetLastModTime(name); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
287 |
|
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
597
diff
changeset
|
288 |
BAIL_IF_MACRO(info == NULL, ERR_OUT_OF_MEMORY, NULL); |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
289 |
memset(info, '\0', sizeof (QPAKinfo)); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
290 |
|
691
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
678
diff
changeset
|
291 |
info->filename = (char *) allocator.Malloc(strlen(name) + 1); |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
292 |
if (info->filename == NULL) |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
293 |
{ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
294 |
__PHYSFS_setError(ERR_OUT_OF_MEMORY); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
295 |
goto QPAK_openArchive_failed; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
296 |
} /* if */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
297 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
298 |
if (!qpak_load_entries(name, forWriting, info)) |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
299 |
goto QPAK_openArchive_failed; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
300 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
301 |
strcpy(info->filename, name); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
302 |
info->last_mod_time = modtime; |
1016
957c97389257
Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents:
972
diff
changeset
|
303 |
return info; |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
304 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
305 |
QPAK_openArchive_failed: |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
597
diff
changeset
|
306 |
if (info != NULL) |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
307 |
{ |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
597
diff
changeset
|
308 |
if (info->filename != NULL) |
691
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
678
diff
changeset
|
309 |
allocator.Free(info->filename); |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
597
diff
changeset
|
310 |
if (info->entries != NULL) |
691
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
678
diff
changeset
|
311 |
allocator.Free(info->entries); |
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
678
diff
changeset
|
312 |
allocator.Free(info); |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
313 |
} /* if */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
314 |
|
1016
957c97389257
Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents:
972
diff
changeset
|
315 |
return NULL; |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
316 |
} /* QPAK_openArchive */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
317 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
318 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
319 |
static PHYSFS_sint32 qpak_find_start_of_dir(QPAKinfo *info, const char *path, |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
320 |
int stop_on_first_find) |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
321 |
{ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
322 |
PHYSFS_sint32 lo = 0; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
323 |
PHYSFS_sint32 hi = (PHYSFS_sint32) (info->entryCount - 1); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
324 |
PHYSFS_sint32 middle; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
325 |
PHYSFS_uint32 dlen = strlen(path); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
326 |
PHYSFS_sint32 retval = -1; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
327 |
const char *name; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
328 |
int rc; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
329 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
330 |
if (*path == '\0') /* root dir? */ |
1016
957c97389257
Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents:
972
diff
changeset
|
331 |
return 0; |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
332 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
333 |
if ((dlen > 0) && (path[dlen - 1] == '/')) /* ignore trailing slash. */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
334 |
dlen--; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
335 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
336 |
while (lo <= hi) |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
337 |
{ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
338 |
middle = lo + ((hi - lo) / 2); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
339 |
name = info->entries[middle].name; |
597
e84664806f86
Made QPAK archiver case insensitive again.
Ryan C. Gordon <icculus@icculus.org>
parents:
589
diff
changeset
|
340 |
rc = QPAK_strncmp(path, name, dlen); |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
341 |
if (rc == 0) |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
342 |
{ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
343 |
char ch = name[dlen]; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
344 |
if (ch < '/') /* make sure this isn't just a substr match. */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
345 |
rc = -1; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
346 |
else if (ch > '/') |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
347 |
rc = 1; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
348 |
else |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
349 |
{ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
350 |
if (stop_on_first_find) /* Just checking dir's existance? */ |
1016
957c97389257
Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents:
972
diff
changeset
|
351 |
return middle; |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
352 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
353 |
if (name[dlen + 1] == '\0') /* Skip initial dir entry. */ |
1016
957c97389257
Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents:
972
diff
changeset
|
354 |
return (middle + 1); |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
355 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
356 |
/* there might be more entries earlier in the list. */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
357 |
retval = middle; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
358 |
hi = middle - 1; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
359 |
} /* else */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
360 |
} /* if */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
361 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
362 |
if (rc > 0) |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
363 |
lo = middle + 1; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
364 |
else |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
365 |
hi = middle - 1; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
366 |
} /* while */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
367 |
|
1016
957c97389257
Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents:
972
diff
changeset
|
368 |
return retval; |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
369 |
} /* qpak_find_start_of_dir */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
370 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
371 |
|
657
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
372 |
/* |
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
373 |
* Moved to seperate function so we can use alloca then immediately throw |
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
374 |
* away the allocated stack space... |
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
375 |
*/ |
754
e7cd7411eadf
API BREAKAGE: Changed PHYSFS_enumerateFilesCallback() to pass the originally
Ryan C. Gordon <icculus@icculus.org>
parents:
691
diff
changeset
|
376 |
static void doEnumCallback(PHYSFS_EnumFilesCallback cb, void *callbackdata, |
e7cd7411eadf
API BREAKAGE: Changed PHYSFS_enumerateFilesCallback() to pass the originally
Ryan C. Gordon <icculus@icculus.org>
parents:
691
diff
changeset
|
377 |
const char *odir, const char *str, PHYSFS_sint32 ln) |
657
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
378 |
{ |
852
9467e96abdf1
Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents:
828
diff
changeset
|
379 |
char *newstr = __PHYSFS_smallAlloc(ln + 1); |
657
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
380 |
if (newstr == NULL) |
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
381 |
return; |
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
382 |
|
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
383 |
memcpy(newstr, str, ln); |
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
384 |
newstr[ln] = '\0'; |
754
e7cd7411eadf
API BREAKAGE: Changed PHYSFS_enumerateFilesCallback() to pass the originally
Ryan C. Gordon <icculus@icculus.org>
parents:
691
diff
changeset
|
385 |
cb(callbackdata, odir, newstr); |
852
9467e96abdf1
Replaced some Malloc and all the alloca() calls with __PHYSFS_smallAlloc(),
Ryan C. Gordon <icculus@icculus.org>
parents:
828
diff
changeset
|
386 |
__PHYSFS_smallFree(newstr); |
657
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
387 |
} /* doEnumCallback */ |
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
388 |
|
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
389 |
|
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
390 |
static void QPAK_enumerateFiles(dvoid *opaque, const char *dname, |
754
e7cd7411eadf
API BREAKAGE: Changed PHYSFS_enumerateFilesCallback() to pass the originally
Ryan C. Gordon <icculus@icculus.org>
parents:
691
diff
changeset
|
391 |
int omitSymLinks, PHYSFS_EnumFilesCallback cb, |
e7cd7411eadf
API BREAKAGE: Changed PHYSFS_enumerateFilesCallback() to pass the originally
Ryan C. Gordon <icculus@icculus.org>
parents:
691
diff
changeset
|
392 |
const char *origdir, void *callbackdata) |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
393 |
{ |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
597
diff
changeset
|
394 |
QPAKinfo *info = ((QPAKinfo *) opaque); |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
395 |
PHYSFS_sint32 dlen, dlen_inc, max, i; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
396 |
|
657
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
397 |
i = qpak_find_start_of_dir(info, dname, 0); |
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
398 |
if (i == -1) /* no such directory. */ |
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
399 |
return; |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
400 |
|
657
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
401 |
dlen = strlen(dname); |
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
402 |
if ((dlen > 0) && (dname[dlen - 1] == '/')) /* ignore trailing slash. */ |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
403 |
dlen--; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
404 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
405 |
dlen_inc = ((dlen > 0) ? 1 : 0) + dlen; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
406 |
max = (PHYSFS_sint32) info->entryCount; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
407 |
while (i < max) |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
408 |
{ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
409 |
char *add; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
410 |
char *ptr; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
411 |
PHYSFS_sint32 ln; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
412 |
char *e = info->entries[i].name; |
657
dad3b5c307a9
Added callback APIs and ripped up the internals everywhere to use them.
Ryan C. Gordon <icculus@icculus.org>
parents:
650
diff
changeset
|
413 |
if ((dlen) && ((QPAK_strncmp(e, dname, dlen)) || (e[dlen] != '/'))) |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
414 |
break; /* past end of this dir; we're done. */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
415 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
416 |
add = e + dlen_inc; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
417 |
ptr = strchr(add, '/'); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
418 |
ln = (PHYSFS_sint32) ((ptr) ? ptr-add : strlen(add)); |
754
e7cd7411eadf
API BREAKAGE: Changed PHYSFS_enumerateFilesCallback() to pass the originally
Ryan C. Gordon <icculus@icculus.org>
parents:
691
diff
changeset
|
419 |
doEnumCallback(cb, callbackdata, origdir, add, ln); |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
420 |
ln += dlen_inc; /* point past entry to children... */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
421 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
422 |
/* increment counter and skip children of subdirs... */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
423 |
while ((++i < max) && (ptr != NULL)) |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
424 |
{ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
425 |
char *e_new = info->entries[i].name; |
597
e84664806f86
Made QPAK archiver case insensitive again.
Ryan C. Gordon <icculus@icculus.org>
parents:
589
diff
changeset
|
426 |
if ((QPAK_strncmp(e, e_new, ln) != 0) || (e_new[ln] != '/')) |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
427 |
break; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
428 |
} /* while */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
429 |
} /* while */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
430 |
} /* QPAK_enumerateFiles */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
431 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
432 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
433 |
/* |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
434 |
* This will find the QPAKentry associated with a path in platform-independent |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
435 |
* notation. Directories don't have QPAKentries associated with them, but |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
436 |
* (*isDir) will be set to non-zero if a dir was hit. |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
437 |
*/ |
1054
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
438 |
static QPAKentry *qpak_find_entry(const QPAKinfo *info, const char *path, |
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
439 |
int *isDir) |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
440 |
{ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
441 |
QPAKentry *a = info->entries; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
442 |
PHYSFS_sint32 pathlen = strlen(path); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
443 |
PHYSFS_sint32 lo = 0; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
444 |
PHYSFS_sint32 hi = (PHYSFS_sint32) (info->entryCount - 1); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
445 |
PHYSFS_sint32 middle; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
446 |
const char *thispath = NULL; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
447 |
int rc; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
448 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
449 |
while (lo <= hi) |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
450 |
{ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
451 |
middle = lo + ((hi - lo) / 2); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
452 |
thispath = a[middle].name; |
597
e84664806f86
Made QPAK archiver case insensitive again.
Ryan C. Gordon <icculus@icculus.org>
parents:
589
diff
changeset
|
453 |
rc = QPAK_strncmp(path, thispath, pathlen); |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
454 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
455 |
if (rc > 0) |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
456 |
lo = middle + 1; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
457 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
458 |
else if (rc < 0) |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
459 |
hi = middle - 1; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
460 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
461 |
else /* substring match...might be dir or entry or nothing. */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
462 |
{ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
463 |
if (isDir != NULL) |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
464 |
{ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
465 |
*isDir = (thispath[pathlen] == '/'); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
466 |
if (*isDir) |
1016
957c97389257
Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents:
972
diff
changeset
|
467 |
return NULL; |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
468 |
} /* if */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
469 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
470 |
if (thispath[pathlen] == '\0') /* found entry? */ |
1016
957c97389257
Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents:
972
diff
changeset
|
471 |
return &a[middle]; |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
472 |
else |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
473 |
hi = middle - 1; /* adjust search params, try again. */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
474 |
} /* if */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
475 |
} /* while */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
476 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
477 |
if (isDir != NULL) |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
478 |
*isDir = 0; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
479 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
480 |
BAIL_MACRO(ERR_NO_SUCH_FILE, NULL); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
481 |
} /* qpak_find_entry */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
482 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
483 |
|
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
|
484 |
static int QPAK_exists(dvoid *opaque, const char *name) |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
485 |
{ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
486 |
int isDir; |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
597
diff
changeset
|
487 |
QPAKinfo *info = (QPAKinfo *) opaque; |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
488 |
QPAKentry *entry = qpak_find_entry(info, name, &isDir); |
1016
957c97389257
Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents:
972
diff
changeset
|
489 |
return ((entry != NULL) || (isDir)); |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
490 |
} /* QPAK_exists */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
491 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
492 |
|
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
|
493 |
static int QPAK_isDirectory(dvoid *opaque, const char *name, int *fileExists) |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
494 |
{ |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
597
diff
changeset
|
495 |
QPAKinfo *info = (QPAKinfo *) opaque; |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
496 |
int isDir; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
497 |
QPAKentry *entry = qpak_find_entry(info, name, &isDir); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
498 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
499 |
*fileExists = ((isDir) || (entry != NULL)); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
500 |
if (isDir) |
1016
957c97389257
Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents:
972
diff
changeset
|
501 |
return 1; /* definitely a dir. */ |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
502 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
503 |
BAIL_MACRO(ERR_NO_SUCH_FILE, 0); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
504 |
} /* QPAK_isDirectory */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
505 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
506 |
|
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
|
507 |
static int QPAK_isSymLink(dvoid *opaque, const char *name, int *fileExists) |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
508 |
{ |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
597
diff
changeset
|
509 |
*fileExists = QPAK_exists(opaque, name); |
1016
957c97389257
Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents:
972
diff
changeset
|
510 |
return 0; /* never symlinks in a quake pak. */ |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
511 |
} /* QPAK_isSymLink */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
512 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
513 |
|
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
|
514 |
static PHYSFS_sint64 QPAK_getLastModTime(dvoid *opaque, |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
515 |
const char *name, |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
516 |
int *fileExists) |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
517 |
{ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
518 |
int isDir; |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
597
diff
changeset
|
519 |
QPAKinfo *info = ((QPAKinfo *) opaque); |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
520 |
PHYSFS_sint64 retval = -1; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
521 |
QPAKentry *entry = qpak_find_entry(info, name, &isDir); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
522 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
523 |
*fileExists = ((isDir) || (entry != NULL)); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
524 |
if (*fileExists) /* use time of QPAK itself in the physical filesystem. */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
525 |
retval = info->last_mod_time; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
526 |
|
1016
957c97389257
Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents:
972
diff
changeset
|
527 |
return retval; |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
528 |
} /* QPAK_getLastModTime */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
529 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
530 |
|
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
|
531 |
static fvoid *QPAK_openRead(dvoid *opaque, const char *fnm, int *fileExists) |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
532 |
{ |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
597
diff
changeset
|
533 |
QPAKinfo *info = ((QPAKinfo *) opaque); |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
534 |
QPAKfileinfo *finfo; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
535 |
QPAKentry *entry; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
536 |
int isDir; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
537 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
538 |
entry = qpak_find_entry(info, fnm, &isDir); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
539 |
*fileExists = ((entry != NULL) || (isDir)); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
540 |
BAIL_IF_MACRO(isDir, ERR_NOT_A_FILE, NULL); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
541 |
BAIL_IF_MACRO(entry == NULL, ERR_NO_SUCH_FILE, NULL); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
542 |
|
691
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
678
diff
changeset
|
543 |
finfo = (QPAKfileinfo *) allocator.Malloc(sizeof (QPAKfileinfo)); |
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
|
544 |
BAIL_IF_MACRO(finfo == NULL, ERR_OUT_OF_MEMORY, NULL); |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
545 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
546 |
finfo->handle = __PHYSFS_platformOpenRead(info->filename); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
547 |
if ( (finfo->handle == NULL) || |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
548 |
(!__PHYSFS_platformSeek(finfo->handle, entry->startPos)) ) |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
549 |
{ |
691
71d9affe0d8a
All memory management now goes through allocation hooks instead of directly to
Ryan C. Gordon <icculus@icculus.org>
parents:
678
diff
changeset
|
550 |
allocator.Free(finfo); |
1016
957c97389257
Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents:
972
diff
changeset
|
551 |
return NULL; |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
552 |
} /* if */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
553 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
554 |
finfo->curPos = 0; |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
555 |
finfo->entry = entry; |
1016
957c97389257
Cleaned up returns that look like function calls for my updated coding style.
Ryan C. Gordon <icculus@icculus.org>
parents:
972
diff
changeset
|
556 |
return finfo; |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
557 |
} /* QPAK_openRead */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
558 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
559 |
|
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
|
560 |
static fvoid *QPAK_openWrite(dvoid *opaque, const char *name) |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
561 |
{ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
562 |
BAIL_MACRO(ERR_NOT_SUPPORTED, NULL); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
563 |
} /* QPAK_openWrite */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
564 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
565 |
|
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
|
566 |
static fvoid *QPAK_openAppend(dvoid *opaque, const char *name) |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
567 |
{ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
568 |
BAIL_MACRO(ERR_NOT_SUPPORTED, NULL); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
569 |
} /* QPAK_openAppend */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
570 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
571 |
|
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
|
572 |
static int QPAK_remove(dvoid *opaque, const char *name) |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
573 |
{ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
574 |
BAIL_MACRO(ERR_NOT_SUPPORTED, 0); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
575 |
} /* QPAK_remove */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
576 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
577 |
|
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
|
578 |
static int QPAK_mkdir(dvoid *opaque, const char *name) |
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
579 |
{ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
580 |
BAIL_MACRO(ERR_NOT_SUPPORTED, 0); |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
581 |
} /* QPAK_mkdir */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
582 |
|
658
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
583 |
|
1108
b63e39d5be04
Fixed details of PHYSFS_Archiver's stat method.
Ryan C. Gordon <icculus@icculus.org>
parents:
1106
diff
changeset
|
584 |
static int QPAK_stat(dvoid *opaque, const char *filename, int *exists, |
1054
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
585 |
PHYSFS_Stat *stat) |
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
586 |
{ |
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
587 |
int isDir = 0; |
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
588 |
const QPAKinfo *info = (const QPAKinfo *) opaque; |
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
589 |
const QPAKentry *entry = qpak_find_entry(info, filename, &isDir); |
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
590 |
|
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
591 |
*exists = ((isDir) || (entry != NULL)); |
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
592 |
if (!exists) |
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
593 |
return 0; |
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
594 |
|
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
595 |
if (isDir) |
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
596 |
{ |
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
597 |
stat->filetype = PHYSFS_FILETYPE_DIRECTORY; |
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
598 |
stat->filesize = 0; |
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
599 |
} /* if */ |
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
600 |
else |
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
601 |
{ |
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
602 |
stat->filetype = PHYSFS_FILETYPE_REGULAR; |
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
603 |
stat->filesize = entry->size; |
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
604 |
} /* else */ |
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
605 |
|
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
606 |
stat->modtime = info->last_mod_time; |
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
607 |
stat->createtime = info->last_mod_time; |
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
608 |
stat->accesstime = 0; |
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
609 |
stat->readonly = 1; |
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
610 |
|
1106
94c3669d0311
Fixed PHYSFS_stat()'s return value to match rest of PhysicsFS API.
Ryan C. Gordon <icculus@icculus.org>
parents:
1098
diff
changeset
|
611 |
return 1; |
1054
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
612 |
} /* QPAK_stat */ |
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
613 |
|
57f4af811ffb
THIS is Christoph's PHYSFS_stat() work.
Ryan C. Gordon <icculus@icculus.org>
parents:
1053
diff
changeset
|
614 |
|
658
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
615 |
const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_QPAK = |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
616 |
{ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
617 |
"PAK", |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
618 |
QPAK_ARCHIVE_DESCRIPTION, |
767
db29bf06d171
Changed my email address.
Ryan C. Gordon <icculus@icculus.org>
parents:
754
diff
changeset
|
619 |
"Ryan C. Gordon <icculus@icculus.org>", |
658
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
620 |
"http://icculus.org/physfs/", |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
621 |
}; |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
622 |
|
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
623 |
|
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
624 |
const PHYSFS_Archiver __PHYSFS_Archiver_QPAK = |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
625 |
{ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
626 |
&__PHYSFS_ArchiveInfo_QPAK, |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
627 |
QPAK_isArchive, /* isArchive() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
628 |
QPAK_openArchive, /* openArchive() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
629 |
QPAK_enumerateFiles, /* enumerateFiles() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
630 |
QPAK_exists, /* exists() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
631 |
QPAK_isDirectory, /* isDirectory() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
632 |
QPAK_isSymLink, /* isSymLink() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
633 |
QPAK_getLastModTime, /* getLastModTime() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
634 |
QPAK_openRead, /* openRead() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
635 |
QPAK_openWrite, /* openWrite() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
636 |
QPAK_openAppend, /* openAppend() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
637 |
QPAK_remove, /* remove() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
638 |
QPAK_mkdir, /* mkdir() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
639 |
QPAK_dirClose, /* dirClose() method */ |
1109 | 640 |
QPAK_stat, /* stat() method */ |
658
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
641 |
QPAK_read, /* read() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
642 |
QPAK_write, /* write() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
643 |
QPAK_eof, /* eof() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
644 |
QPAK_tell, /* tell() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
645 |
QPAK_seek, /* seek() method */ |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
646 |
QPAK_fileLength, /* fileLength() method */ |
1109 | 647 |
QPAK_fileClose /* fileClose() method */ |
658
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
648 |
}; |
1981818c6170
Removed all the forward declaration cruft from the archivers.
Ryan C. Gordon <icculus@icculus.org>
parents:
657
diff
changeset
|
649 |
|
581
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
650 |
#endif /* defined PHYSFS_SUPPORTS_QPAK */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
651 |
|
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
652 |
/* end of qpak.c ... */ |
712fedcbf02c
Reimplemented qpak.c for relicensing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
653 |