author | Ryan C. Gordon <icculus@icculus.org> |
Sun, 26 Sep 2004 00:25:04 +0000 | |
changeset 648 | 5c993684b8f2 |
parent 504 | 3420d82f9b01 |
child 650 | 298b8bb26775 |
permissions | -rw-r--r-- |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
1 |
/* |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
2 |
* GRP support routines for PhysicsFS. |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
3 |
* |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
4 |
* This driver handles BUILD engine archives ("groupfiles"). This format |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
5 |
* (but not this driver) was put together by Ken Silverman. |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
6 |
* |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
7 |
* The format is simple enough. In Ken's words: |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
8 |
* |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
9 |
* What's the .GRP file format? |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
10 |
* |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
11 |
* The ".grp" file format is just a collection of a lot of files stored |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
12 |
* into 1 big one. I tried to make the format as simple as possible: The |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
13 |
* first 12 bytes contains my name, "KenSilverman". The next 4 bytes is |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
14 |
* the number of files that were compacted into the group file. Then for |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
15 |
* each file, there is a 16 byte structure, where the first 12 bytes are |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
16 |
* the filename, and the last 4 bytes are the file's size. The rest of |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
17 |
* the group file is just the raw data packed one after the other in the |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
18 |
* same order as the list of files. |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
19 |
* |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
20 |
* (That info is from http://www.advsys.net/ken/build.htm ...) |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
21 |
* |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
22 |
* Please see the file LICENSE in the source's root directory. |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
23 |
* |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
24 |
* This file written by Ryan C. Gordon. |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
25 |
*/ |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
26 |
|
214
19846c18071b
Initial autoconf support.
Ryan C. Gordon <icculus@icculus.org>
parents:
194
diff
changeset
|
27 |
#if HAVE_CONFIG_H |
19846c18071b
Initial autoconf support.
Ryan C. Gordon <icculus@icculus.org>
parents:
194
diff
changeset
|
28 |
# include <config.h> |
19846c18071b
Initial autoconf support.
Ryan C. Gordon <icculus@icculus.org>
parents:
194
diff
changeset
|
29 |
#endif |
19846c18071b
Initial autoconf support.
Ryan C. Gordon <icculus@icculus.org>
parents:
194
diff
changeset
|
30 |
|
19846c18071b
Initial autoconf support.
Ryan C. Gordon <icculus@icculus.org>
parents:
194
diff
changeset
|
31 |
#if (defined PHYSFS_SUPPORTS_GRP) |
19846c18071b
Initial autoconf support.
Ryan C. Gordon <icculus@icculus.org>
parents:
194
diff
changeset
|
32 |
|
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
33 |
#include <stdio.h> |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
34 |
#include <stdlib.h> |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
35 |
#include <string.h> |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
36 |
#include "physfs.h" |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
37 |
|
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
38 |
#define __PHYSICSFS_INTERNAL__ |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
39 |
#include "physfs_internal.h" |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
40 |
|
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
41 |
typedef struct |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
42 |
{ |
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
43 |
char name[13]; |
480
2cf0b6edd200
Cleaned up some stuff, reduced some unnecessary 64-bit ints to 32.
Ryan C. Gordon <icculus@icculus.org>
parents:
467
diff
changeset
|
44 |
PHYSFS_uint32 startPos; |
2cf0b6edd200
Cleaned up some stuff, reduced some unnecessary 64-bit ints to 32.
Ryan C. Gordon <icculus@icculus.org>
parents:
467
diff
changeset
|
45 |
PHYSFS_uint32 size; |
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
46 |
} GRPentry; |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
47 |
|
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
48 |
typedef struct |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
49 |
{ |
139
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
50 |
char *filename; |
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
51 |
PHYSFS_sint64 last_mod_time; |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
52 |
PHYSFS_uint32 entryCount; |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
53 |
GRPentry *entries; |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
54 |
} GRPinfo; |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
55 |
|
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
56 |
typedef struct |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
57 |
{ |
139
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
58 |
void *handle; |
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
59 |
GRPentry *entry; |
480
2cf0b6edd200
Cleaned up some stuff, reduced some unnecessary 64-bit ints to 32.
Ryan C. Gordon <icculus@icculus.org>
parents:
467
diff
changeset
|
60 |
PHYSFS_uint32 curPos; |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
61 |
} GRPfileinfo; |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
62 |
|
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
63 |
|
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
64 |
static void GRP_dirClose(void *opaque); |
132
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
107
diff
changeset
|
65 |
static PHYSFS_sint64 GRP_read(FileHandle *handle, void *buffer, |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
107
diff
changeset
|
66 |
PHYSFS_uint32 objSize, PHYSFS_uint32 objCount); |
467
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
67 |
static PHYSFS_sint64 GRP_write(FileHandle *handle, const void *buffer, |
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
68 |
PHYSFS_uint32 objSize, PHYSFS_uint32 objCount); |
93
74d1df359be3
Patched to compile with an ancient version of CodeWarrior.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
69 |
static int GRP_eof(FileHandle *handle); |
132
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
107
diff
changeset
|
70 |
static PHYSFS_sint64 GRP_tell(FileHandle *handle); |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
107
diff
changeset
|
71 |
static int GRP_seek(FileHandle *handle, PHYSFS_uint64 offset); |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
107
diff
changeset
|
72 |
static PHYSFS_sint64 GRP_fileLength(FileHandle *handle); |
93
74d1df359be3
Patched to compile with an ancient version of CodeWarrior.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
73 |
static int GRP_fileClose(FileHandle *handle); |
74d1df359be3
Patched to compile with an ancient version of CodeWarrior.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
74 |
static int GRP_isArchive(const char *filename, int forWriting); |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
75 |
static void *GRP_openArchive(const char *name, int forWriting); |
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
76 |
static LinkedStringList *GRP_enumerateFiles(void *opaque, |
93
74d1df359be3
Patched to compile with an ancient version of CodeWarrior.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
77 |
const char *dirname, |
74d1df359be3
Patched to compile with an ancient version of CodeWarrior.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
78 |
int omitSymLinks); |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
79 |
static int GRP_exists(void *opaque, const char *name); |
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
80 |
static int GRP_isDirectory(void *opaque, const char *name, int *fileExists); |
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
81 |
static int GRP_isSymLink(void *opaque, const char *name, int *fileExists); |
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
82 |
static PHYSFS_sint64 GRP_getLastModTime(void *opaque, const char *n, int *e); |
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
83 |
static FileHandle *GRP_openRead(void *opaque, const char *name, int *exist); |
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
84 |
static FileHandle *GRP_openWrite(void *opaque, const char *name); |
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
85 |
static FileHandle *GRP_openAppend(void *opaque, const char *name); |
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
86 |
static int GRP_remove(void *opaque, const char *name); |
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
87 |
static int GRP_mkdir(void *opaque, const char *name); |
93
74d1df359be3
Patched to compile with an ancient version of CodeWarrior.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
88 |
|
399
02dd53688315
Changed DirFunctions struct a little.
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
89 |
const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_GRP = |
02dd53688315
Changed DirFunctions struct a little.
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
90 |
{ |
02dd53688315
Changed DirFunctions struct a little.
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
91 |
"GRP", |
427
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
399
diff
changeset
|
92 |
GRP_ARCHIVE_DESCRIPTION, |
399
02dd53688315
Changed DirFunctions struct a little.
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
93 |
"Ryan C. Gordon <icculus@clutteredmind.org>", |
02dd53688315
Changed DirFunctions struct a little.
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
94 |
"http://icculus.org/physfs/", |
02dd53688315
Changed DirFunctions struct a little.
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
95 |
}; |
02dd53688315
Changed DirFunctions struct a little.
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
96 |
|
02dd53688315
Changed DirFunctions struct a little.
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
97 |
|
93
74d1df359be3
Patched to compile with an ancient version of CodeWarrior.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
98 |
static const FileFunctions __PHYSFS_FileFunctions_GRP = |
74d1df359be3
Patched to compile with an ancient version of CodeWarrior.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
99 |
{ |
74d1df359be3
Patched to compile with an ancient version of CodeWarrior.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
100 |
GRP_read, /* read() method */ |
467
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
101 |
GRP_write, /* write() method */ |
93
74d1df359be3
Patched to compile with an ancient version of CodeWarrior.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
102 |
GRP_eof, /* eof() method */ |
74d1df359be3
Patched to compile with an ancient version of CodeWarrior.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
103 |
GRP_tell, /* tell() method */ |
74d1df359be3
Patched to compile with an ancient version of CodeWarrior.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
104 |
GRP_seek, /* seek() method */ |
74d1df359be3
Patched to compile with an ancient version of CodeWarrior.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
105 |
GRP_fileLength, /* fileLength() method */ |
74d1df359be3
Patched to compile with an ancient version of CodeWarrior.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
106 |
GRP_fileClose /* fileClose() method */ |
74d1df359be3
Patched to compile with an ancient version of CodeWarrior.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
107 |
}; |
74d1df359be3
Patched to compile with an ancient version of CodeWarrior.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
108 |
|
74d1df359be3
Patched to compile with an ancient version of CodeWarrior.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
109 |
|
74d1df359be3
Patched to compile with an ancient version of CodeWarrior.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
110 |
const DirFunctions __PHYSFS_DirFunctions_GRP = |
74d1df359be3
Patched to compile with an ancient version of CodeWarrior.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
111 |
{ |
399
02dd53688315
Changed DirFunctions struct a little.
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
112 |
&__PHYSFS_ArchiveInfo_GRP, |
93
74d1df359be3
Patched to compile with an ancient version of CodeWarrior.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
113 |
GRP_isArchive, /* isArchive() method */ |
74d1df359be3
Patched to compile with an ancient version of CodeWarrior.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
114 |
GRP_openArchive, /* openArchive() method */ |
74d1df359be3
Patched to compile with an ancient version of CodeWarrior.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
115 |
GRP_enumerateFiles, /* enumerateFiles() method */ |
74d1df359be3
Patched to compile with an ancient version of CodeWarrior.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
116 |
GRP_exists, /* exists() method */ |
74d1df359be3
Patched to compile with an ancient version of CodeWarrior.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
117 |
GRP_isDirectory, /* isDirectory() method */ |
74d1df359be3
Patched to compile with an ancient version of CodeWarrior.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
118 |
GRP_isSymLink, /* isSymLink() method */ |
258
80fe5c9954dd
getLastModTime implemented.
Ryan C. Gordon <icculus@icculus.org>
parents:
240
diff
changeset
|
119 |
GRP_getLastModTime, /* getLastModTime() method */ |
93
74d1df359be3
Patched to compile with an ancient version of CodeWarrior.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
120 |
GRP_openRead, /* openRead() method */ |
467
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
121 |
GRP_openWrite, /* openWrite() method */ |
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
122 |
GRP_openAppend, /* openAppend() method */ |
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
123 |
GRP_remove, /* remove() method */ |
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
124 |
GRP_mkdir, /* mkdir() method */ |
93
74d1df359be3
Patched to compile with an ancient version of CodeWarrior.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
125 |
GRP_dirClose /* dirClose() method */ |
74d1df359be3
Patched to compile with an ancient version of CodeWarrior.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
126 |
}; |
74d1df359be3
Patched to compile with an ancient version of CodeWarrior.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
127 |
|
74d1df359be3
Patched to compile with an ancient version of CodeWarrior.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
128 |
|
74d1df359be3
Patched to compile with an ancient version of CodeWarrior.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
129 |
|
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
130 |
static void GRP_dirClose(void *opaque) |
93
74d1df359be3
Patched to compile with an ancient version of CodeWarrior.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
131 |
{ |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
132 |
GRPinfo *info = ((GRPinfo *) opaque); |
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
133 |
free(info->filename); |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
134 |
free(info->entries); |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
135 |
free(info); |
93
74d1df359be3
Patched to compile with an ancient version of CodeWarrior.
Ryan C. Gordon <icculus@icculus.org>
parents:
69
diff
changeset
|
136 |
} /* GRP_dirClose */ |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
137 |
|
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
138 |
|
132
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
107
diff
changeset
|
139 |
static PHYSFS_sint64 GRP_read(FileHandle *handle, void *buffer, |
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
107
diff
changeset
|
140 |
PHYSFS_uint32 objSize, PHYSFS_uint32 objCount) |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
141 |
{ |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
142 |
GRPfileinfo *finfo = (GRPfileinfo *) (handle->opaque); |
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
143 |
GRPentry *entry = finfo->entry; |
480
2cf0b6edd200
Cleaned up some stuff, reduced some unnecessary 64-bit ints to 32.
Ryan C. Gordon <icculus@icculus.org>
parents:
467
diff
changeset
|
144 |
PHYSFS_uint32 bytesLeft = entry->size - finfo->curPos; |
2cf0b6edd200
Cleaned up some stuff, reduced some unnecessary 64-bit ints to 32.
Ryan C. Gordon <icculus@icculus.org>
parents:
467
diff
changeset
|
145 |
PHYSFS_uint32 objsLeft = (bytesLeft / objSize); |
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
146 |
PHYSFS_sint64 rc; |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
147 |
|
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
148 |
if (objsLeft < objCount) |
480
2cf0b6edd200
Cleaned up some stuff, reduced some unnecessary 64-bit ints to 32.
Ryan C. Gordon <icculus@icculus.org>
parents:
467
diff
changeset
|
149 |
objCount = objsLeft; |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
150 |
|
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
151 |
rc = __PHYSFS_platformRead(finfo->handle, buffer, objSize, objCount); |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
152 |
if (rc > 0) |
480
2cf0b6edd200
Cleaned up some stuff, reduced some unnecessary 64-bit ints to 32.
Ryan C. Gordon <icculus@icculus.org>
parents:
467
diff
changeset
|
153 |
finfo->curPos += (PHYSFS_uint32) (rc * objSize); |
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
154 |
|
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
155 |
return(rc); |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
156 |
} /* GRP_read */ |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
157 |
|
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
158 |
|
467
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
159 |
static PHYSFS_sint64 GRP_write(FileHandle *handle, const void *buffer, |
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
160 |
PHYSFS_uint32 objSize, PHYSFS_uint32 objCount) |
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
161 |
{ |
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
162 |
BAIL_MACRO(ERR_NOT_SUPPORTED, -1); |
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
163 |
} /* GRP_write */ |
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
164 |
|
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
165 |
|
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
166 |
static int GRP_eof(FileHandle *handle) |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
167 |
{ |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
168 |
GRPfileinfo *finfo = (GRPfileinfo *) (handle->opaque); |
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
169 |
GRPentry *entry = finfo->entry; |
480
2cf0b6edd200
Cleaned up some stuff, reduced some unnecessary 64-bit ints to 32.
Ryan C. Gordon <icculus@icculus.org>
parents:
467
diff
changeset
|
170 |
return(finfo->curPos >= entry->size); |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
171 |
} /* GRP_eof */ |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
172 |
|
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
173 |
|
132
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
107
diff
changeset
|
174 |
static PHYSFS_sint64 GRP_tell(FileHandle *handle) |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
175 |
{ |
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
176 |
return(((GRPfileinfo *) (handle->opaque))->curPos); |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
177 |
} /* GRP_tell */ |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
178 |
|
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
179 |
|
132
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
107
diff
changeset
|
180 |
static int GRP_seek(FileHandle *handle, PHYSFS_uint64 offset) |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
181 |
{ |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
182 |
GRPfileinfo *finfo = (GRPfileinfo *) (handle->opaque); |
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
183 |
GRPentry *entry = finfo->entry; |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
184 |
int rc; |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
185 |
|
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
186 |
BAIL_IF_MACRO(offset < 0, ERR_INVALID_ARGUMENT, 0); |
480
2cf0b6edd200
Cleaned up some stuff, reduced some unnecessary 64-bit ints to 32.
Ryan C. Gordon <icculus@icculus.org>
parents:
467
diff
changeset
|
187 |
BAIL_IF_MACRO(offset >= entry->size, ERR_PAST_EOF, 0); |
2cf0b6edd200
Cleaned up some stuff, reduced some unnecessary 64-bit ints to 32.
Ryan C. Gordon <icculus@icculus.org>
parents:
467
diff
changeset
|
188 |
rc = __PHYSFS_platformSeek(finfo->handle, entry->startPos + offset); |
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
189 |
if (rc) |
480
2cf0b6edd200
Cleaned up some stuff, reduced some unnecessary 64-bit ints to 32.
Ryan C. Gordon <icculus@icculus.org>
parents:
467
diff
changeset
|
190 |
finfo->curPos = (PHYSFS_uint32) offset; |
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
191 |
|
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
192 |
return(rc); |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
193 |
} /* GRP_seek */ |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
194 |
|
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
195 |
|
132
b53fa5093749
Added typedefs and platform-specific i/o.
Ryan C. Gordon <icculus@icculus.org>
parents:
107
diff
changeset
|
196 |
static PHYSFS_sint64 GRP_fileLength(FileHandle *handle) |
28
529214f57d1b
Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents:
26
diff
changeset
|
197 |
{ |
480
2cf0b6edd200
Cleaned up some stuff, reduced some unnecessary 64-bit ints to 32.
Ryan C. Gordon <icculus@icculus.org>
parents:
467
diff
changeset
|
198 |
GRPfileinfo *finfo = ((GRPfileinfo *) handle->opaque); |
2cf0b6edd200
Cleaned up some stuff, reduced some unnecessary 64-bit ints to 32.
Ryan C. Gordon <icculus@icculus.org>
parents:
467
diff
changeset
|
199 |
return((PHYSFS_sint64) finfo->entry->size); |
28
529214f57d1b
Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents:
26
diff
changeset
|
200 |
} /* GRP_fileLength */ |
529214f57d1b
Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents:
26
diff
changeset
|
201 |
|
529214f57d1b
Added PHYSFS_fileLength(). Bleh.
Ryan C. Gordon <icculus@icculus.org>
parents:
26
diff
changeset
|
202 |
|
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
203 |
static int GRP_fileClose(FileHandle *handle) |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
204 |
{ |
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
205 |
GRPfileinfo *finfo = ((GRPfileinfo *) handle->opaque); |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
206 |
BAIL_IF_MACRO(!__PHYSFS_platformClose(finfo->handle), NULL, 0); |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
207 |
free(finfo); |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
208 |
free(handle); |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
209 |
return(1); |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
210 |
} /* GRP_fileClose */ |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
211 |
|
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
212 |
|
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
213 |
static int grp_open(const char *filename, int forWriting, |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
214 |
void **fh, PHYSFS_uint32 *count) |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
215 |
{ |
139
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
216 |
PHYSFS_uint8 buf[12]; |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
217 |
|
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
218 |
*fh = NULL; |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
219 |
BAIL_IF_MACRO(forWriting, ERR_ARC_IS_READ_ONLY, 0); |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
220 |
|
139
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
221 |
*fh = __PHYSFS_platformOpenRead(filename); |
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
222 |
BAIL_IF_MACRO(*fh == NULL, NULL, 0); |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
223 |
|
139
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
224 |
if (__PHYSFS_platformRead(*fh, buf, 12, 1) != 1) |
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
225 |
goto openGrp_failed; |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
226 |
|
139
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
227 |
if (memcmp(buf, "KenSilverman", 12) != 0) |
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
228 |
{ |
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
229 |
__PHYSFS_setError(ERR_UNSUPPORTED_ARCHIVE); |
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
230 |
goto openGrp_failed; |
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
231 |
} /* if */ |
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
232 |
|
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
233 |
if (__PHYSFS_platformRead(*fh, count, sizeof (PHYSFS_uint32), 1) != 1) |
139
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
234 |
goto openGrp_failed; |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
235 |
|
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
236 |
*count = PHYSFS_swapULE32(*count); |
175
45e423c38ff8
Fixed byte ordering bugs.
Ryan C. Gordon <icculus@icculus.org>
parents:
163
diff
changeset
|
237 |
|
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
238 |
return(1); |
139
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
239 |
|
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
240 |
openGrp_failed: |
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
241 |
if (*fh != NULL) |
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
242 |
__PHYSFS_platformClose(*fh); |
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
243 |
|
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
244 |
*count = -1; |
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
245 |
*fh = NULL; |
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
246 |
return(0); |
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
247 |
} /* grp_open */ |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
248 |
|
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
249 |
|
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
250 |
static int GRP_isArchive(const char *filename, int forWriting) |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
251 |
{ |
139
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
252 |
void *fh; |
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
253 |
PHYSFS_uint32 fileCount; |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
254 |
int retval = grp_open(filename, forWriting, &fh, &fileCount); |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
255 |
|
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
256 |
if (fh != NULL) |
139
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
257 |
__PHYSFS_platformClose(fh); |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
258 |
|
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
259 |
return(retval); |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
260 |
} /* GRP_isArchive */ |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
261 |
|
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
262 |
|
464
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
427
diff
changeset
|
263 |
static int grp_entry_cmp(void *_a, PHYSFS_uint32 one, PHYSFS_uint32 two) |
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
264 |
{ |
464
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
427
diff
changeset
|
265 |
GRPentry *a = (GRPentry *) _a; |
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
427
diff
changeset
|
266 |
return(strcmp(a[one].name, a[two].name)); |
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
427
diff
changeset
|
267 |
} /* grp_entry_cmp */ |
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
268 |
|
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
269 |
|
464
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
427
diff
changeset
|
270 |
static void grp_entry_swap(void *_a, PHYSFS_uint32 one, PHYSFS_uint32 two) |
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
271 |
{ |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
272 |
GRPentry tmp; |
464
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
427
diff
changeset
|
273 |
GRPentry *first = &(((GRPentry *) _a)[one]); |
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
427
diff
changeset
|
274 |
GRPentry *second = &(((GRPentry *) _a)[two]); |
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
427
diff
changeset
|
275 |
memcpy(&tmp, first, sizeof (GRPentry)); |
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
427
diff
changeset
|
276 |
memcpy(first, second, sizeof (GRPentry)); |
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
427
diff
changeset
|
277 |
memcpy(second, &tmp, sizeof (GRPentry)); |
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
427
diff
changeset
|
278 |
} /* grp_entry_swap */ |
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
279 |
|
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
280 |
|
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
281 |
static int grp_load_entries(const char *name, int forWriting, GRPinfo *info) |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
282 |
{ |
139
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
283 |
void *fh = NULL; |
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
284 |
PHYSFS_uint32 fileCount; |
370 | 285 |
PHYSFS_uint32 location = 16; /* sizeof sig. */ |
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
286 |
GRPentry *entry; |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
287 |
char *ptr; |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
288 |
|
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
289 |
BAIL_IF_MACRO(!grp_open(name, forWriting, &fh, &fileCount), NULL, 0); |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
290 |
info->entryCount = fileCount; |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
291 |
info->entries = (GRPentry *) malloc(sizeof (GRPentry) * fileCount); |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
292 |
if (info->entries == NULL) |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
293 |
{ |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
294 |
__PHYSFS_platformClose(fh); |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
295 |
BAIL_MACRO(ERR_OUT_OF_MEMORY, 0); |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
296 |
} /* if */ |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
297 |
|
370 | 298 |
location += (16 * fileCount); |
299 |
||
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
300 |
for (entry = info->entries; fileCount > 0; fileCount--, entry++) |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
301 |
{ |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
302 |
if (__PHYSFS_platformRead(fh, &entry->name, 12, 1) != 1) |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
303 |
{ |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
304 |
__PHYSFS_platformClose(fh); |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
305 |
return(0); |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
306 |
} /* if */ |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
307 |
|
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
308 |
entry->name[12] = '\0'; /* name isn't null-terminated in file. */ |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
309 |
if ((ptr = strchr(entry->name, ' ')) != NULL) |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
310 |
*ptr = '\0'; /* trim extra spaces. */ |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
311 |
|
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
312 |
if (__PHYSFS_platformRead(fh, &entry->size, 4, 1) != 1) |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
313 |
{ |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
314 |
__PHYSFS_platformClose(fh); |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
315 |
return(0); |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
316 |
} /* if */ |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
317 |
|
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
318 |
entry->size = PHYSFS_swapULE32(entry->size); |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
319 |
entry->startPos = location; |
370 | 320 |
location += entry->size; |
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
321 |
} /* for */ |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
322 |
|
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
323 |
__PHYSFS_platformClose(fh); |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
324 |
|
464
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
427
diff
changeset
|
325 |
__PHYSFS_sort(info->entries, info->entryCount, |
21c8e0d1578c
Generalized sorting routines, and removed individual implementations.
Ryan C. Gordon <icculus@icculus.org>
parents:
427
diff
changeset
|
326 |
grp_entry_cmp, grp_entry_swap); |
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
327 |
return(1); |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
328 |
} /* grp_load_entries */ |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
329 |
|
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
330 |
|
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
331 |
static void *GRP_openArchive(const char *name, int forWriting) |
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
332 |
{ |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
333 |
PHYSFS_sint64 modtime = __PHYSFS_platformGetLastModTime(name); |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
334 |
GRPinfo *info = malloc(sizeof (GRPinfo)); |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
335 |
|
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
336 |
BAIL_IF_MACRO(info == NULL, ERR_OUT_OF_MEMORY, 0); |
139
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
337 |
|
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
338 |
memset(info, '\0', sizeof (GRPinfo)); |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
339 |
info->filename = (char *) malloc(strlen(name) + 1); |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
340 |
if (info->filename == NULL) |
139
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
341 |
{ |
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
342 |
__PHYSFS_setError(ERR_OUT_OF_MEMORY); |
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
343 |
goto GRP_openArchive_failed; |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
344 |
} /* if */ |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
345 |
|
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
346 |
if (!grp_load_entries(name, forWriting, info)) |
139
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
347 |
goto GRP_openArchive_failed; |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
348 |
|
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
349 |
strcpy(info->filename, name); |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
350 |
info->last_mod_time = modtime; |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
351 |
|
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
352 |
return(info); |
139
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
353 |
|
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
354 |
GRP_openArchive_failed: |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
355 |
if (info != NULL) |
139
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
356 |
{ |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
357 |
if (info->filename != NULL) |
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
358 |
free(info->filename); |
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
359 |
if (info->entries != NULL) |
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
360 |
free(info->entries); |
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
361 |
free(info); |
139
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
362 |
} /* if */ |
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
363 |
|
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
364 |
return(NULL); |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
365 |
} /* GRP_openArchive */ |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
366 |
|
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
367 |
|
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
368 |
static LinkedStringList *GRP_enumerateFiles(void *opaque, |
41
ff60d39d0862
Architecture adjustment for enumerating files with regards to whether
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
369 |
const char *dirname, |
ff60d39d0862
Architecture adjustment for enumerating files with regards to whether
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
370 |
int omitSymLinks) |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
371 |
{ |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
372 |
GRPinfo *info = ((GRPinfo *) opaque); |
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
373 |
GRPentry *entry = info->entries; |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
374 |
LinkedStringList *retval = NULL, *p = NULL; |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
375 |
PHYSFS_uint32 max = info->entryCount; |
161
4fcc863fdc5f
-Added type casting that Ryan needs to approve.
Gregory S. Read <zeph@clutteredmind.org>
parents:
150
diff
changeset
|
376 |
PHYSFS_uint32 i; |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
377 |
|
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
378 |
/* no directories in GRP files. */ |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
379 |
BAIL_IF_MACRO(*dirname != '\0', ERR_NOT_A_DIR, NULL); |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
380 |
|
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
381 |
for (i = 0; i < max; i++, entry++) |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
382 |
retval = __PHYSFS_addToLinkedStringList(retval, &p, entry->name, -1); |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
383 |
|
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
384 |
return(retval); |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
385 |
} /* GRP_enumerateFiles */ |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
386 |
|
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
387 |
|
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
388 |
static GRPentry *grp_find_entry(GRPinfo *info, const char *name) |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
389 |
{ |
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
390 |
char *ptr = strchr(name, '.'); |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
391 |
GRPentry *a = info->entries; |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
392 |
PHYSFS_sint32 lo = 0; |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
393 |
PHYSFS_sint32 hi = (PHYSFS_sint32) (info->entryCount - 1); |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
394 |
PHYSFS_sint32 middle; |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
395 |
int rc; |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
396 |
|
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
397 |
/* |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
398 |
* Rule out filenames to avoid unneeded processing...no dirs, |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
399 |
* big filenames, or extensions > 3 chars. |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
400 |
*/ |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
401 |
BAIL_IF_MACRO((ptr) && (strlen(ptr) > 4), ERR_NO_SUCH_FILE, NULL); |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
402 |
BAIL_IF_MACRO(strlen(name) > 12, ERR_NO_SUCH_FILE, NULL); |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
403 |
BAIL_IF_MACRO(strchr(name, '/') != NULL, ERR_NO_SUCH_FILE, NULL); |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
404 |
|
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
405 |
while (lo <= hi) |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
406 |
{ |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
407 |
middle = lo + ((hi - lo) / 2); |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
408 |
rc = strcmp(name, a[middle].name); |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
409 |
if (rc == 0) /* found it! */ |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
410 |
return(&a[middle]); |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
411 |
else if (rc > 0) |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
412 |
lo = middle + 1; |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
413 |
else |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
414 |
hi = middle - 1; |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
415 |
} /* while */ |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
416 |
|
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
417 |
BAIL_MACRO(ERR_NO_SUCH_FILE, NULL); |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
418 |
} /* grp_find_entry */ |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
419 |
|
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
420 |
|
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
421 |
static int GRP_exists(void *opaque, const char *name) |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
422 |
{ |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
423 |
return(grp_find_entry(((GRPinfo *) opaque), name) != NULL); |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
424 |
} /* GRP_exists */ |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
425 |
|
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
426 |
|
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
427 |
static int GRP_isDirectory(void *opaque, const char *name, int *fileExists) |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
428 |
{ |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
429 |
*fileExists = GRP_exists(opaque, name); |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
430 |
return(0); /* never directories in a groupfile. */ |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
431 |
} /* GRP_isDirectory */ |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
432 |
|
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
433 |
|
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
434 |
static int GRP_isSymLink(void *opaque, const char *name, int *fileExists) |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
435 |
{ |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
436 |
*fileExists = GRP_exists(opaque, name); |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
437 |
return(0); /* never symlinks in a groupfile. */ |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
438 |
} /* GRP_isSymLink */ |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
439 |
|
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
440 |
|
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
441 |
static PHYSFS_sint64 GRP_getLastModTime(void *opaque, |
467
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
442 |
const char *name, |
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
443 |
int *fileExists) |
258
80fe5c9954dd
getLastModTime implemented.
Ryan C. Gordon <icculus@icculus.org>
parents:
240
diff
changeset
|
444 |
{ |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
445 |
GRPinfo *info = ((GRPinfo *) opaque); |
467
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
446 |
PHYSFS_sint64 retval = -1; |
393 | 447 |
|
467
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
448 |
*fileExists = (grp_find_entry(info, name) != NULL); |
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
449 |
if (*fileExists) /* use time of GRP itself in the physical filesystem. */ |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
450 |
retval = info->last_mod_time; |
467
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
451 |
|
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
452 |
return(retval); |
258
80fe5c9954dd
getLastModTime implemented.
Ryan C. Gordon <icculus@icculus.org>
parents:
240
diff
changeset
|
453 |
} /* GRP_getLastModTime */ |
80fe5c9954dd
getLastModTime implemented.
Ryan C. Gordon <icculus@icculus.org>
parents:
240
diff
changeset
|
454 |
|
80fe5c9954dd
getLastModTime implemented.
Ryan C. Gordon <icculus@icculus.org>
parents:
240
diff
changeset
|
455 |
|
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
456 |
static FileHandle *GRP_openRead(void *opaque, const char *fnm, int *fileExists) |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
457 |
{ |
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
458 |
GRPinfo *info = ((GRPinfo *) opaque); |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
459 |
FileHandle *retval; |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
460 |
GRPfileinfo *finfo; |
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
461 |
GRPentry *entry; |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
462 |
|
467
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
463 |
entry = grp_find_entry(info, fnm); |
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
464 |
*fileExists = (entry != NULL); |
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
465 |
BAIL_IF_MACRO(entry == NULL, NULL, NULL); |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
466 |
|
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
467 |
retval = (FileHandle *) malloc(sizeof (FileHandle)); |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
468 |
BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL); |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
469 |
finfo = (GRPfileinfo *) malloc(sizeof (GRPfileinfo)); |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
470 |
if (finfo == NULL) |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
471 |
{ |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
472 |
free(retval); |
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
473 |
BAIL_MACRO(ERR_OUT_OF_MEMORY, NULL); |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
474 |
} /* if */ |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
475 |
|
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
476 |
finfo->handle = __PHYSFS_platformOpenRead(info->filename); |
139
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
477 |
if ( (finfo->handle == NULL) || |
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
478 |
(!__PHYSFS_platformSeek(finfo->handle, entry->startPos)) ) |
139
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
479 |
{ |
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
480 |
free(finfo); |
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
481 |
free(retval); |
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
482 |
return(NULL); |
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
483 |
} /* if */ |
616420dc210c
Converted to file i/o abstraction, removed race condition.
Ryan C. Gordon <icculus@icculus.org>
parents:
132
diff
changeset
|
484 |
|
364
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
485 |
finfo->curPos = 0; |
51da162c76f7
Major overhauls. More efficient, robust, and bug-free.
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
486 |
finfo->entry = entry; |
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
487 |
retval->opaque = (void *) finfo; |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
488 |
retval->funcs = &__PHYSFS_FileFunctions_GRP; |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
489 |
return(retval); |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
490 |
} /* GRP_openRead */ |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
491 |
|
467
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
492 |
|
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
493 |
static FileHandle *GRP_openWrite(void *opaque, const char *name) |
467
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
494 |
{ |
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
495 |
BAIL_MACRO(ERR_NOT_SUPPORTED, NULL); |
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
496 |
} /* GRP_openWrite */ |
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
497 |
|
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
498 |
|
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
499 |
static FileHandle *GRP_openAppend(void *opaque, const char *name) |
467
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
500 |
{ |
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
501 |
BAIL_MACRO(ERR_NOT_SUPPORTED, NULL); |
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
502 |
} /* GRP_openAppend */ |
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
503 |
|
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
504 |
|
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
505 |
static int GRP_remove(void *opaque, const char *name) |
467
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
506 |
{ |
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
507 |
BAIL_MACRO(ERR_NOT_SUPPORTED, 0); |
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
508 |
} /* GRP_remove */ |
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
509 |
|
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
510 |
|
648
5c993684b8f2
Cleaned up archiver interface to not deal with DirHandles anymore,
Ryan C. Gordon <icculus@icculus.org>
parents:
504
diff
changeset
|
511 |
static int GRP_mkdir(void *opaque, const char *name) |
467
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
512 |
{ |
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
513 |
BAIL_MACRO(ERR_NOT_SUPPORTED, 0); |
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
514 |
} /* GRP_mkdir */ |
99664d9842cb
Bunch of tedious corrections, optimizations, and cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
464
diff
changeset
|
515 |
|
214
19846c18071b
Initial autoconf support.
Ryan C. Gordon <icculus@icculus.org>
parents:
194
diff
changeset
|
516 |
#endif /* defined PHYSFS_SUPPORTS_GRP */ |
19846c18071b
Initial autoconf support.
Ryan C. Gordon <icculus@icculus.org>
parents:
194
diff
changeset
|
517 |
|
24
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
518 |
/* end of grp.c ... */ |
b050804123a3
Initial add. Implemented, buggy, but not crashing.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
519 |