author | Ryan C. Gordon <icculus@icculus.org> |
Tue, 28 Jan 2003 18:29:10 +0000 | |
changeset 534 | 2aeee045f27e |
parent 427 | c38ace41039f |
child 538 | 8752e3c0dbf9 |
permissions | -rw-r--r-- |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
1 |
/* |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
2 |
* MacOS Classic support routines for PhysicsFS. |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
3 |
* |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
4 |
* Please see the file LICENSE in the source's root directory. |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
5 |
* |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
6 |
* This file written by Ryan C. Gordon. |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
7 |
*/ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
8 |
|
214
19846c18071b
Initial autoconf support.
Ryan C. Gordon <icculus@icculus.org>
parents:
185
diff
changeset
|
9 |
#if HAVE_CONFIG_H |
19846c18071b
Initial autoconf support.
Ryan C. Gordon <icculus@icculus.org>
parents:
185
diff
changeset
|
10 |
# include <config.h> |
19846c18071b
Initial autoconf support.
Ryan C. Gordon <icculus@icculus.org>
parents:
185
diff
changeset
|
11 |
#endif |
19846c18071b
Initial autoconf support.
Ryan C. Gordon <icculus@icculus.org>
parents:
185
diff
changeset
|
12 |
|
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
13 |
#include <stdlib.h> |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
14 |
#include <string.h> |
183
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
15 |
#include <alloca.h> |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
16 |
|
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
17 |
/* |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
18 |
* Most of the API calls in here are, according to ADC, available since |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
19 |
* MacOS 8.1. I don't think I used any MacOS 9 or CarbonLib-specific |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
20 |
* functions. There might be one or two 8.5 calls, and perhaps when the |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
21 |
* ADC docs say "Available in MacOS 8.1" they really mean "this works |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
22 |
* with System 6, but we don't want to hear about it at this point." |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
23 |
* |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
24 |
* IsAliasFile() showed up in MacOS 8.5. You can duplicate this code with |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
25 |
* PBGetCatInfoSync(), which is an older API, if you hope the bits in the |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
26 |
* catalog info never change (which they won't for, say, MacOS 8.1). |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
27 |
* See Apple Technote FL-30: |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
28 |
* http://developer.apple.com/technotes/fl/fl_30.html |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
29 |
* |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
30 |
* If you want to use weak pointers and Gestalt, and choose the correct |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
31 |
* code to use during __PHYSFS_platformInit(), I'll accept a patch, but |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
32 |
* chances are, it wasn't worth the time it took to write this, let alone |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
33 |
* implement that. |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
34 |
*/ |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
35 |
|
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
36 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
37 |
/* |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
38 |
* Please note that I haven't tried this code with CarbonLib or under |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
39 |
* MacOS X at all. The code in unix.c is known to work with Darwin, |
183
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
40 |
* and you may or may not be better off using that, especially since |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
41 |
* mutexes are no-ops in this file. Patches welcome. |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
42 |
*/ |
183
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
43 |
#ifdef __PHYSFS_CARBONIZED__ /* this is currently not defined anywhere. */ |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
44 |
#include <Carbon.h> |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
45 |
#else |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
46 |
#include <OSUtils.h> |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
47 |
#include <Processes.h> |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
48 |
#include <Files.h> |
158
ecc4a7f173c1
Username is now accurately reported, which means that the default user dir works more correctly.
Ryan C. Gordon <icculus@icculus.org>
parents:
157
diff
changeset
|
49 |
#include <TextUtils.h> |
ecc4a7f173c1
Username is now accurately reported, which means that the default user dir works more correctly.
Ryan C. Gordon <icculus@icculus.org>
parents:
157
diff
changeset
|
50 |
#include <Resources.h> |
ecc4a7f173c1
Username is now accurately reported, which means that the default user dir works more correctly.
Ryan C. Gordon <icculus@icculus.org>
parents:
157
diff
changeset
|
51 |
#include <MacMemory.h> |
162
06ed1dc94f73
Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents:
158
diff
changeset
|
52 |
#include <Events.h> |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
53 |
#include <DriverGestalt.h> |
183
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
54 |
#include <Aliases.h> |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
55 |
#endif |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
56 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
57 |
#define __PHYSICSFS_INTERNAL__ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
58 |
#include "physfs_internal.h" |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
59 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
60 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
61 |
const char *__PHYSFS_platformDirSeparator = ":"; |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
62 |
|
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
63 |
|
427
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
64 |
static const char *get_macos_error_string(OSErr err) |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
65 |
{ |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
66 |
if (err == noErr) |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
67 |
return(NULL); |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
68 |
|
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
69 |
switch (err) |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
70 |
{ |
427
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
71 |
case fnfErr: return(ERR_NO_SUCH_FILE); |
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
72 |
case notOpenErr: return(ERR_NO_SUCH_VOLUME); |
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
73 |
case dirFulErr: return(ERR_DIRECTORY_FULL); |
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
74 |
case dskFulErr: return(ERR_DISK_FULL); |
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
75 |
case nsvErr: return(ERR_NO_SUCH_VOLUME); |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
76 |
case ioErr: return(ERR_IO_ERROR); |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
77 |
case bdNamErr: return(ERR_BAD_FILENAME); |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
78 |
case fnOpnErr: return(ERR_NOT_A_HANDLE); |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
79 |
case eofErr: return(ERR_PAST_EOF); |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
80 |
case posErr: return(ERR_SEEK_OUT_OF_RANGE); |
427
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
81 |
case tmfoErr: return(ERR_TOO_MANY_HANDLES); |
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
82 |
case wPrErr: return(ERR_VOL_LOCKED_HW); |
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
83 |
case fLckdErr: return(ERR_FILE_LOCKED); |
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
84 |
case vLckdErr: return(ERR_VOL_LOCKED_SW); |
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
85 |
case fBsyErr: return(ERR_FILE_OR_DIR_BUSY); |
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
86 |
case dupFNErr: return(ERR_FILE_ALREADY_EXISTS); |
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
87 |
case opWrErr: return(ERR_FILE_ALREADY_OPEN_W); |
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
88 |
case rfNumErr: return(ERR_INVALID_REFNUM); |
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
89 |
case gfpErr: return(ERR_GETTING_FILE_POS); |
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
90 |
case volOffLinErr: return(ERR_VOLUME_OFFLINE); |
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
91 |
case permErr: return(ERR_PERMISSION_DENIED); |
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
92 |
case volOnLinErr: return(ERR_VOL_ALREADY_ONLINE); |
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
93 |
case nsDrvErr: return(ERR_NO_SUCH_DRIVE); |
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
94 |
case noMacDskErr: return(ERR_NOT_MAC_DISK); |
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
95 |
case extFSErr: return(ERR_VOL_EXTERNAL_FS); |
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
96 |
case fsRnErr: return(ERR_PROBLEM_RENAME); |
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
97 |
case badMDBErr: return(ERR_BAD_MASTER_BLOCK); |
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
98 |
case wrPermErr: return(ERR_PERMISSION_DENIED); |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
99 |
case memFullErr: return(ERR_OUT_OF_MEMORY); |
427
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
100 |
case dirNFErr: return(ERR_NO_SUCH_PATH); |
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
101 |
case tmwdoErr: return(ERR_TOO_MANY_HANDLES); |
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
102 |
case badMovErr: return(ERR_CANT_MOVE_FORBIDDEN); |
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
103 |
case wrgVolTypErr: return(ERR_WRONG_VOL_TYPE); |
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
104 |
case volGoneErr: return(ERR_SERVER_VOL_LOST); |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
105 |
case errFSNameTooLong: return(ERR_BAD_FILENAME); |
427
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
106 |
case errFSNotAFolder: return(ERR_NOT_A_DIR); |
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
107 |
case errFSNotAFile: return(ERR_NOT_A_FILE); |
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
108 |
case fidNotFound: return(ERR_FILE_ID_NOT_FOUND); |
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
109 |
case fidExists: return(ERR_FILE_ID_EXISTS); |
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
110 |
case afpAccessDenied: return(ERR_ACCESS_DENIED); |
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
111 |
case afpNoServer: return(ERR_SERVER_NO_RESPOND); |
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
112 |
case afpUserNotAuth: return(ERR_USER_AUTH_FAILED); |
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
113 |
case afpPwdExpiredErr: return(ERR_PWORD_EXPIRED); |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
114 |
|
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
115 |
case paramErr: |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
116 |
case errFSBadFSRef: |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
117 |
case errFSBadBuffer: |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
118 |
case errFSMissingName: |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
119 |
case errFSBadPosMode: |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
120 |
case errFSBadAllocFlags: |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
121 |
case errFSBadItemCount |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
122 |
case errFSBadSearchParams |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
123 |
case afpDenyConflict |
427
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
124 |
return(ERR_PHYSFS_BAD_OS_CALL); |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
125 |
|
427
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
126 |
default: return(ERR_MACOS_GENERIC); |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
127 |
} /* switch */ |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
128 |
|
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
129 |
return(NULL); |
427
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
130 |
} /* get_macos_error_string */ |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
131 |
|
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
132 |
|
427
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
133 |
static OSErr oserr(OSErr retval) |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
134 |
{ |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
135 |
char buf[128]; |
427
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
136 |
const char *errstr = get_macos_error_string(retval); |
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
137 |
if (errstr == ERR_MACOS_GENERIC) |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
138 |
{ |
427
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
139 |
snprintf(buf, ERR_MACOS_GENERIC, (int) retval); |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
140 |
errstr = buf; |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
141 |
} /* if */ |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
142 |
|
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
143 |
if (errstr != NULL) |
427
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
144 |
__PHYSFS_setError(errstr); |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
145 |
|
427
c38ace41039f
Natural language #defines and build system support.
Ryan C. Gordon <icculus@icculus.org>
parents:
424
diff
changeset
|
146 |
return(retval); |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
147 |
} /* oserr */ |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
148 |
|
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
149 |
|
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
150 |
static struct ProcessInfoRec procInfo; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
151 |
static FSSpec procfsspec; |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
152 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
153 |
int __PHYSFS_platformInit(void) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
154 |
{ |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
155 |
OSErr err; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
156 |
ProcessSerialNumber psn; |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
157 |
BAIL_IF_MACRO(oserr(GetCurrentProcess(&psn)) != noErr, NULL, 0); |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
158 |
memset(&procInfo, '\0', sizeof (ProcessInfoRec)); |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
159 |
memset(&procfsspec, '\0', sizeof (FSSpec)); |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
160 |
procInfo.processInfoLength = sizeof (ProcessInfoRec); |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
161 |
procInfo.processAppSpec = &procfsspec; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
162 |
err = GetProcessInformation(&psn, &procInfo); |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
163 |
BAIL_IF_MACRO(oserr(err) != noErr, NULL, 0); |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
164 |
return(1); /* we're golden. */ |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
165 |
} /* __PHYSFS_platformInit */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
166 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
167 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
168 |
int __PHYSFS_platformDeinit(void) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
169 |
{ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
170 |
return(1); /* always succeed. */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
171 |
} /* __PHYSFS_platformDeinit */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
172 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
173 |
|
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
174 |
/* |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
175 |
* CD detection code is borrowed from Apple Technical Q&A DV18. |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
176 |
* http://developer.apple.com/qa/dv/dv18.html |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
177 |
*/ |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
178 |
char **__PHYSFS_platformDetectAvailableCDs(void) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
179 |
{ |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
180 |
DriverGestaltParam pb; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
181 |
DrvQEl *dqp; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
182 |
OSErr status; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
183 |
char **retval = (char **) malloc(sizeof (char *)); |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
184 |
int cd_count = 1; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
185 |
|
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
186 |
BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL); |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
187 |
|
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
188 |
*retval = NULL; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
189 |
|
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
190 |
pb.csCode = kDriverGestaltCode; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
191 |
pb.driverGestaltSelector = kdgDeviceType; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
192 |
dqp = (DrvQEl *) GetDrvQHdr()->qHead; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
193 |
|
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
194 |
while (dqp != NULL) |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
195 |
{ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
196 |
pb.ioCRefNum = dqp->dQRefNum; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
197 |
pb.ioVRefNum = dqp->dQDrive; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
198 |
status = PBStatusSync((ParmBlkPtr) &pb); |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
199 |
if ((status == noErr) && (pb.driverGestaltResponse == kdgCDType)) |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
200 |
{ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
201 |
Str63 volName; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
202 |
HParamBlockRec hpbr; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
203 |
memset(&hpbr, '\0', sizeof (HParamBlockRec)); |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
204 |
hpbr.volumeParam.ioNamePtr = volName; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
205 |
hpbr.volumeParam.ioVRefNum = dqp->dQDrive; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
206 |
hpbr.volumeParam.ioVolIndex = 0; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
207 |
if (PBHGetVInfoSync(&hpbr) == noErr) |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
208 |
{ |
316
29a4d12d1dc6
Fixed buffer overflow in CD-ROM detection code.
Ryan C. Gordon <icculus@icculus.org>
parents:
247
diff
changeset
|
209 |
char **tmp = realloc(retval, sizeof (char *) * (cd_count + 1)); |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
210 |
if (tmp) |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
211 |
{ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
212 |
char *str = (char *) malloc(volName[0] + 1); |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
213 |
retval = tmp; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
214 |
if (str != NULL) |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
215 |
{ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
216 |
memcpy(str, &volName[1], volName[0]); |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
217 |
str[volName[0]] = '\0'; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
218 |
retval[cd_count-1] = str; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
219 |
cd_count++; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
220 |
} /* if */ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
221 |
} /* if */ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
222 |
} /* if */ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
223 |
} /* if */ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
224 |
|
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
225 |
dqp = (DrvQEl *) dqp->qLink; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
226 |
} /* while */ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
227 |
|
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
228 |
retval[cd_count - 1] = NULL; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
229 |
return(retval); |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
230 |
} /* __PHYSFS_platformDetectAvailableCDs */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
231 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
232 |
|
185
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
233 |
static char *convFSSpecToPath(FSSpec *spec, int includeFile) |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
234 |
{ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
235 |
char *ptr; |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
236 |
char *retval = NULL; |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
237 |
UInt32 retLength = 0; |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
238 |
CInfoPBRec infoPB; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
239 |
Str255 str255; |
185
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
240 |
|
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
241 |
str255[0] = spec->name[0]; |
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
242 |
memcpy(&str255[1], &spec->name[1], str255[0]); |
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
243 |
|
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
244 |
memset(&infoPB, '\0', sizeof (CInfoPBRec)); |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
245 |
infoPB.dirInfo.ioNamePtr = str255; /* put name in here. */ |
185
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
246 |
infoPB.dirInfo.ioVRefNum = spec->vRefNum; /* ID of bin's volume. */ |
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
247 |
infoPB.dirInfo.ioDrParID = spec->parID; /* ID of bin's dir. */ |
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
248 |
infoPB.dirInfo.ioFDirIndex = (includeFile) ? 0 : -1; |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
249 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
250 |
/* walk the tree back to the root dir (volume), building path string... */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
251 |
do |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
252 |
{ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
253 |
/* check parent dir of what we last looked at... */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
254 |
infoPB.dirInfo.ioDrDirID = infoPB.dirInfo.ioDrParID; |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
255 |
if (oserr(PBGetCatInfoSync(&infoPB)) != noErr) |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
256 |
{ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
257 |
if (retval != NULL) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
258 |
free(retval); |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
259 |
return(NULL); |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
260 |
} /* if */ |
185
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
261 |
|
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
262 |
infoPB.dirInfo.ioFDirIndex = -1; /* look at parent dir next time. */ |
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
263 |
|
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
264 |
/* allocate more space for the retval... */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
265 |
retLength += str255[0] + 1; /* + 1 for a ':' or null char... */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
266 |
ptr = (char *) malloc(retLength); |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
267 |
if (ptr == NULL) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
268 |
{ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
269 |
if (retval != NULL) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
270 |
free(retval); |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
271 |
BAIL_MACRO(ERR_OUT_OF_MEMORY, NULL); |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
272 |
} /* if */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
273 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
274 |
/* prepend new dir to retval and cleanup... */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
275 |
memcpy(ptr, &str255[1], str255[0]); |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
276 |
ptr[str255[0]] = '\0'; /* null terminate it. */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
277 |
if (retval != NULL) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
278 |
{ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
279 |
strcat(ptr, ":"); |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
280 |
strcat(ptr, retval); |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
281 |
free(retval); |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
282 |
} /* if */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
283 |
retval = ptr; |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
284 |
} while (infoPB.dirInfo.ioDrDirID != fsRtDirID); |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
285 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
286 |
return(retval); |
185
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
287 |
} /* convFSSpecToPath */ |
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
288 |
|
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
289 |
|
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
290 |
char *__PHYSFS_platformCalcBaseDir(const char *argv0) |
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
291 |
{ |
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
292 |
FSSpec spec; |
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
293 |
|
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
294 |
/* Get the name of the binary's parent directory. */ |
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
295 |
FSMakeFSSpec(procfsspec.vRefNum, procfsspec.parID, procfsspec.name, &spec); |
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
296 |
return(convFSSpecToPath(&spec, 0)); |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
297 |
} /* __PHYSFS_platformCalcBaseDir */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
298 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
299 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
300 |
char *__PHYSFS_platformGetUserName(void) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
301 |
{ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
302 |
char *retval = NULL; |
158
ecc4a7f173c1
Username is now accurately reported, which means that the default user dir works more correctly.
Ryan C. Gordon <icculus@icculus.org>
parents:
157
diff
changeset
|
303 |
StringHandle strHandle; |
ecc4a7f173c1
Username is now accurately reported, which means that the default user dir works more correctly.
Ryan C. Gordon <icculus@icculus.org>
parents:
157
diff
changeset
|
304 |
short origResourceFile = CurResFile(); |
ecc4a7f173c1
Username is now accurately reported, which means that the default user dir works more correctly.
Ryan C. Gordon <icculus@icculus.org>
parents:
157
diff
changeset
|
305 |
|
ecc4a7f173c1
Username is now accurately reported, which means that the default user dir works more correctly.
Ryan C. Gordon <icculus@icculus.org>
parents:
157
diff
changeset
|
306 |
/* use the System resource file. */ |
ecc4a7f173c1
Username is now accurately reported, which means that the default user dir works more correctly.
Ryan C. Gordon <icculus@icculus.org>
parents:
157
diff
changeset
|
307 |
UseResFile(0); |
ecc4a7f173c1
Username is now accurately reported, which means that the default user dir works more correctly.
Ryan C. Gordon <icculus@icculus.org>
parents:
157
diff
changeset
|
308 |
/* apparently, -16096 specifies the username. */ |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
309 |
strHandle = oserr(GetString(-16096)); |
158
ecc4a7f173c1
Username is now accurately reported, which means that the default user dir works more correctly.
Ryan C. Gordon <icculus@icculus.org>
parents:
157
diff
changeset
|
310 |
UseResFile(origResourceFile); |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
311 |
BAIL_IF_MACRO(strHandle == NULL, NULL, NULL); |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
312 |
|
158
ecc4a7f173c1
Username is now accurately reported, which means that the default user dir works more correctly.
Ryan C. Gordon <icculus@icculus.org>
parents:
157
diff
changeset
|
313 |
HLock((Handle) strHandle); |
ecc4a7f173c1
Username is now accurately reported, which means that the default user dir works more correctly.
Ryan C. Gordon <icculus@icculus.org>
parents:
157
diff
changeset
|
314 |
retval = (char *) malloc((*strHandle)[0] + 1); |
ecc4a7f173c1
Username is now accurately reported, which means that the default user dir works more correctly.
Ryan C. Gordon <icculus@icculus.org>
parents:
157
diff
changeset
|
315 |
if (retval == NULL) |
ecc4a7f173c1
Username is now accurately reported, which means that the default user dir works more correctly.
Ryan C. Gordon <icculus@icculus.org>
parents:
157
diff
changeset
|
316 |
{ |
ecc4a7f173c1
Username is now accurately reported, which means that the default user dir works more correctly.
Ryan C. Gordon <icculus@icculus.org>
parents:
157
diff
changeset
|
317 |
HUnlock((Handle) strHandle); |
ecc4a7f173c1
Username is now accurately reported, which means that the default user dir works more correctly.
Ryan C. Gordon <icculus@icculus.org>
parents:
157
diff
changeset
|
318 |
BAIL_MACRO(ERR_OUT_OF_MEMORY, NULL); |
ecc4a7f173c1
Username is now accurately reported, which means that the default user dir works more correctly.
Ryan C. Gordon <icculus@icculus.org>
parents:
157
diff
changeset
|
319 |
} /* if */ |
ecc4a7f173c1
Username is now accurately reported, which means that the default user dir works more correctly.
Ryan C. Gordon <icculus@icculus.org>
parents:
157
diff
changeset
|
320 |
memcpy(retval, &(*strHandle)[1], (*strHandle)[0]); |
ecc4a7f173c1
Username is now accurately reported, which means that the default user dir works more correctly.
Ryan C. Gordon <icculus@icculus.org>
parents:
157
diff
changeset
|
321 |
retval[(*strHandle)[0]] = '\0'; /* null-terminate it. */ |
ecc4a7f173c1
Username is now accurately reported, which means that the default user dir works more correctly.
Ryan C. Gordon <icculus@icculus.org>
parents:
157
diff
changeset
|
322 |
HUnlock((Handle) strHandle); |
ecc4a7f173c1
Username is now accurately reported, which means that the default user dir works more correctly.
Ryan C. Gordon <icculus@icculus.org>
parents:
157
diff
changeset
|
323 |
|
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
324 |
return(retval); |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
325 |
} /* __PHYSFS_platformGetUserName */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
326 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
327 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
328 |
char *__PHYSFS_platformGetUserDir(void) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
329 |
{ |
185
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
330 |
#if 0 |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
331 |
return(NULL); /* bah...use default behaviour, I guess. */ |
185
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
332 |
#else |
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
333 |
/* (Hmm. Default behaviour is broken in the base library. :) ) */ |
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
334 |
return(__PHYSFS_platformCalcBaseDir(NULL)); |
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
335 |
#endif |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
336 |
} /* __PHYSFS_platformGetUserDir */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
337 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
338 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
339 |
PHYSFS_uint64 __PHYSFS_platformGetThreadID(void) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
340 |
{ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
341 |
return(1); /* single threaded. */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
342 |
} /* __PHYSFS_platformGetThreadID */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
343 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
344 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
345 |
int __PHYSFS_platformStricmp(const char *x, const char *y) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
346 |
{ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
347 |
extern int _stricmp(const char *, const char *); |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
348 |
return(_stricmp(x, y)); /* (*shrug*) */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
349 |
} /* __PHYSFS_platformStricmp */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
350 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
351 |
|
183
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
352 |
static OSErr fnameToFSSpecNoAlias(const char *fname, FSSpec *spec) |
166
ed10fe7cb16e
More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
162
diff
changeset
|
353 |
{ |
169
34829282ffe8
Fixed isDirectory and enumarateFiles (had wrong param in PBGetCatInfoSync()).
Ryan C. Gordon <icculus@icculus.org>
parents:
166
diff
changeset
|
354 |
OSErr err; |
166
ed10fe7cb16e
More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
162
diff
changeset
|
355 |
Str255 str255; |
335 | 356 |
int needColon = (strchr(fname, ':') == NULL); |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
357 |
int len = strlen(fname) + ((needColon) ? 1 : 0); |
166
ed10fe7cb16e
More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
162
diff
changeset
|
358 |
if (len > 255) |
ed10fe7cb16e
More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
162
diff
changeset
|
359 |
return(bdNamErr); |
ed10fe7cb16e
More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
162
diff
changeset
|
360 |
|
ed10fe7cb16e
More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
162
diff
changeset
|
361 |
/* !!! FIXME: What happens with relative pathnames? */ |
ed10fe7cb16e
More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
162
diff
changeset
|
362 |
|
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
363 |
str255[0] = len; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
364 |
memcpy(&str255[1], fname, len); |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
365 |
|
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
366 |
/* probably just a volume name, which seems to need a ':' at the end. */ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
367 |
if (needColon) |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
368 |
str255[len] = ':'; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
369 |
|
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
370 |
err = oserr(FSMakeFSSpec(0, 0, str255, spec)); |
169
34829282ffe8
Fixed isDirectory and enumarateFiles (had wrong param in PBGetCatInfoSync()).
Ryan C. Gordon <icculus@icculus.org>
parents:
166
diff
changeset
|
371 |
return(err); |
183
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
372 |
} /* fnameToFSSpecNoAlias */ |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
373 |
|
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
374 |
|
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
375 |
static OSErr fnameToFSSpec(const char *fname, FSSpec *spec) |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
376 |
{ |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
377 |
Boolean alias = 0; |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
378 |
Boolean folder = 0; |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
379 |
OSErr err = fnameToFSSpecNoAlias(fname, spec); |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
380 |
|
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
381 |
if (err == dirNFErr) /* might be an alias in the middle of the path. */ |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
382 |
{ |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
383 |
/* |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
384 |
* Has to be at least two ':' chars, or we wouldn't get a |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
385 |
* dir-not-found condition. (no ':' means it was just a volume, |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
386 |
* just one ':' means we would have gotten a fnfErr, if anything. |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
387 |
*/ |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
388 |
char *ptr; |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
389 |
char *start; |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
390 |
char *path = alloca(strlen(fname) + 1); |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
391 |
strcpy(path, fname); |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
392 |
ptr = strchr(path, ':'); |
362
ac8c846a0a66
Changed enumeration code to use __PHYSFS_addToLinkedStringList().
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
393 |
BAIL_IF_MACRO(!ptr, ERR_NO_SUCH_FILE, err); /* just in case */ |
183
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
394 |
ptr = strchr(ptr + 1, ':'); |
362
ac8c846a0a66
Changed enumeration code to use __PHYSFS_addToLinkedStringList().
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
395 |
BAIL_IF_MACRO(!ptr, ERR_NO_SUCH_FILE, err); /* just in case */ |
183
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
396 |
*ptr = '\0'; |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
397 |
err = fnameToFSSpecNoAlias(path, spec); /* get first dir. */ |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
398 |
BAIL_IF_MACRO(oserr(err) != noErr, NULL, err); |
183
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
399 |
start = ptr; |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
400 |
ptr = strchr(start + 1, ':'); |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
401 |
|
335 | 402 |
/* Now check each element of the path for aliases... */ |
183
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
403 |
do |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
404 |
{ |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
405 |
CInfoPBRec infoPB; |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
406 |
memset(&infoPB, '\0', sizeof (CInfoPBRec)); |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
407 |
infoPB.dirInfo.ioNamePtr = spec->name; |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
408 |
infoPB.dirInfo.ioVRefNum = spec->vRefNum; |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
409 |
infoPB.dirInfo.ioDrDirID = spec->parID; |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
410 |
infoPB.dirInfo.ioFDirIndex = 0; |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
411 |
err = PBGetCatInfoSync(&infoPB); |
335 | 412 |
if (err != noErr) /* not an alias, really just a bogus path. */ |
183
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
413 |
return(fnameToFSSpecNoAlias(fname, spec)); /* reset */ |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
414 |
|
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
415 |
if ((infoPB.dirInfo.ioFlAttrib & kioFlAttribDirMask) != 0) |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
416 |
spec->parID = infoPB.dirInfo.ioDrDirID; |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
417 |
|
335 | 418 |
if (ptr != NULL) /* terminate string after next element. */ |
183
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
419 |
*ptr = '\0'; |
335 | 420 |
|
183
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
421 |
*start = strlen(start + 1); /* make it a pstring. */ |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
422 |
err = FSMakeFSSpec(spec->vRefNum, spec->parID, |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
423 |
(const unsigned char *) start, spec); |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
424 |
if (err != noErr) /* not an alias, really a bogus path. */ |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
425 |
return(fnameToFSSpecNoAlias(fname, spec)); /* reset */ |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
426 |
|
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
427 |
err = ResolveAliasFileWithMountFlags(spec, 1, &folder, &alias, 0); |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
428 |
if (err != noErr) /* not an alias, really a bogus path. */ |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
429 |
return(fnameToFSSpecNoAlias(fname, spec)); /* reset */ |
335 | 430 |
|
431 |
start = ptr; /* move to the next element. */ |
|
183
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
432 |
if (ptr != NULL) |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
433 |
ptr = strchr(start + 1, ':'); |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
434 |
} while (start != NULL); |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
435 |
} /* if */ |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
436 |
|
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
437 |
else /* there's something there; make sure final file is not an alias. */ |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
438 |
{ |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
439 |
BAIL_IF_MACRO(oserr(err) != noErr, NULL, err); |
183
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
440 |
err = ResolveAliasFileWithMountFlags(spec, 1, &folder, &alias, 0); |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
441 |
BAIL_IF_MACRO(oserr(err) != noErr, NULL, err); |
183
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
442 |
} /* else */ |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
443 |
|
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
444 |
return(noErr); /* w00t. */ |
166
ed10fe7cb16e
More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
162
diff
changeset
|
445 |
} /* fnameToFSSpec */ |
ed10fe7cb16e
More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
162
diff
changeset
|
446 |
|
ed10fe7cb16e
More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
162
diff
changeset
|
447 |
|
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
448 |
int __PHYSFS_platformExists(const char *fname) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
449 |
{ |
166
ed10fe7cb16e
More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
162
diff
changeset
|
450 |
FSSpec spec; |
ed10fe7cb16e
More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
162
diff
changeset
|
451 |
return(fnameToFSSpec(fname, &spec) == noErr); |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
452 |
} /* __PHYSFS_platformExists */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
453 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
454 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
455 |
int __PHYSFS_platformIsSymLink(const char *fname) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
456 |
{ |
183
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
457 |
OSErr err; |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
458 |
FSSpec spec; |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
459 |
Boolean a = 0; |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
460 |
Boolean f = 0; |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
461 |
CInfoPBRec infoPB; |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
462 |
char *ptr; |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
463 |
char *dir = alloca(strlen(fname) + 1); |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
464 |
BAIL_IF_MACRO(dir == NULL, ERR_OUT_OF_MEMORY, 0); |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
465 |
strcpy(dir, fname); |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
466 |
ptr = strrchr(dir, ':'); |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
467 |
if (ptr == NULL) /* just a volume name? Can't be a symlink. */ |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
468 |
return(0); |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
469 |
|
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
470 |
/* resolve aliases up to the actual file... */ |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
471 |
*ptr = '\0'; |
393 | 472 |
BAIL_IF_MACRO(fnameToFSSpec(dir, &spec) != noErr, NULL, 0); |
183
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
473 |
|
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
474 |
*ptr = strlen(ptr + 1); /* ptr is now a pascal string. Yikes! */ |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
475 |
memset(&infoPB, '\0', sizeof (CInfoPBRec)); |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
476 |
infoPB.dirInfo.ioNamePtr = spec.name; |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
477 |
infoPB.dirInfo.ioVRefNum = spec.vRefNum; |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
478 |
infoPB.dirInfo.ioDrDirID = spec.parID; |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
479 |
infoPB.dirInfo.ioFDirIndex = 0; |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
480 |
BAIL_IF_MACRO(oserr(PBGetCatInfoSync(&infoPB)) != noErr, NULL, 0); |
183
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
481 |
|
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
482 |
err = FSMakeFSSpec(spec.vRefNum, infoPB.dirInfo.ioDrDirID, |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
483 |
(const unsigned char *) ptr, &spec); |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
484 |
BAIL_IF_MACRO(oserr(err) != noErr, NULL, 0); |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
485 |
BAIL_IF_MACRO(oserr(IsAliasFile(&spec, &a, &f)) != noErr, NULL, 0); |
183
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
486 |
return(a); |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
487 |
} /* __PHYSFS_platformIsSymlink */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
488 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
489 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
490 |
int __PHYSFS_platformIsDirectory(const char *fname) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
491 |
{ |
166
ed10fe7cb16e
More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
162
diff
changeset
|
492 |
FSSpec spec; |
ed10fe7cb16e
More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
162
diff
changeset
|
493 |
CInfoPBRec infoPB; |
169
34829282ffe8
Fixed isDirectory and enumarateFiles (had wrong param in PBGetCatInfoSync()).
Ryan C. Gordon <icculus@icculus.org>
parents:
166
diff
changeset
|
494 |
OSErr err; |
166
ed10fe7cb16e
More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
162
diff
changeset
|
495 |
|
393 | 496 |
BAIL_IF_MACRO(fnameToFSSpec(fname, &spec) != noErr, NULL, 0); |
166
ed10fe7cb16e
More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
162
diff
changeset
|
497 |
memset(&infoPB, '\0', sizeof (CInfoPBRec)); |
ed10fe7cb16e
More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
162
diff
changeset
|
498 |
infoPB.dirInfo.ioNamePtr = spec.name; /* put name in here. */ |
ed10fe7cb16e
More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
162
diff
changeset
|
499 |
infoPB.dirInfo.ioVRefNum = spec.vRefNum; /* ID of file's volume. */ |
169
34829282ffe8
Fixed isDirectory and enumarateFiles (had wrong param in PBGetCatInfoSync()).
Ryan C. Gordon <icculus@icculus.org>
parents:
166
diff
changeset
|
500 |
infoPB.dirInfo.ioDrDirID = spec.parID; /* ID of bin's dir. */ |
166
ed10fe7cb16e
More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
162
diff
changeset
|
501 |
infoPB.dirInfo.ioFDirIndex = 0; /* file (not parent) info. */ |
169
34829282ffe8
Fixed isDirectory and enumarateFiles (had wrong param in PBGetCatInfoSync()).
Ryan C. Gordon <icculus@icculus.org>
parents:
166
diff
changeset
|
502 |
err = PBGetCatInfoSync(&infoPB); |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
503 |
BAIL_IF_MACRO(oserr(err) != noErr, NULL, 0); |
166
ed10fe7cb16e
More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
162
diff
changeset
|
504 |
return((infoPB.dirInfo.ioFlAttrib & kioFlAttribDirMask) != 0); |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
505 |
} /* __PHYSFS_platformIsDirectory */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
506 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
507 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
508 |
char *__PHYSFS_platformCvtToDependent(const char *prepend, |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
509 |
const char *dirName, |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
510 |
const char *append) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
511 |
{ |
162
06ed1dc94f73
Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents:
158
diff
changeset
|
512 |
int len = ((prepend) ? strlen(prepend) : 0) + |
06ed1dc94f73
Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents:
158
diff
changeset
|
513 |
((append) ? strlen(append) : 0) + |
06ed1dc94f73
Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents:
158
diff
changeset
|
514 |
strlen(dirName) + 1; |
06ed1dc94f73
Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents:
158
diff
changeset
|
515 |
const char *src; |
06ed1dc94f73
Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents:
158
diff
changeset
|
516 |
char *dst; |
06ed1dc94f73
Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents:
158
diff
changeset
|
517 |
char *retval = malloc(len); |
06ed1dc94f73
Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents:
158
diff
changeset
|
518 |
BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL); |
06ed1dc94f73
Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents:
158
diff
changeset
|
519 |
|
06ed1dc94f73
Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents:
158
diff
changeset
|
520 |
if (prepend != NULL) |
06ed1dc94f73
Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents:
158
diff
changeset
|
521 |
{ |
06ed1dc94f73
Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents:
158
diff
changeset
|
522 |
strcpy(retval, prepend); |
06ed1dc94f73
Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents:
158
diff
changeset
|
523 |
dst = retval + strlen(retval); |
06ed1dc94f73
Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents:
158
diff
changeset
|
524 |
} /* if */ |
06ed1dc94f73
Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents:
158
diff
changeset
|
525 |
else |
06ed1dc94f73
Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents:
158
diff
changeset
|
526 |
{ |
06ed1dc94f73
Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents:
158
diff
changeset
|
527 |
*retval = '\0'; |
06ed1dc94f73
Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents:
158
diff
changeset
|
528 |
dst = retval; |
06ed1dc94f73
Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents:
158
diff
changeset
|
529 |
} /* else */ |
06ed1dc94f73
Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents:
158
diff
changeset
|
530 |
|
06ed1dc94f73
Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents:
158
diff
changeset
|
531 |
for (src = dirName; *src; src++, dst++) |
06ed1dc94f73
Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents:
158
diff
changeset
|
532 |
*dst = ((*src == '/') ? ':' : *src); |
06ed1dc94f73
Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents:
158
diff
changeset
|
533 |
|
06ed1dc94f73
Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents:
158
diff
changeset
|
534 |
*dst = '\0'; |
06ed1dc94f73
Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents:
158
diff
changeset
|
535 |
return(retval); |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
536 |
} /* __PHYSFS_platformCvtToDependent */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
537 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
538 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
539 |
void __PHYSFS_platformTimeslice(void) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
540 |
{ |
162
06ed1dc94f73
Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents:
158
diff
changeset
|
541 |
SystemTask(); |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
542 |
} /* __PHYSFS_platformTimeslice */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
543 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
544 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
545 |
LinkedStringList *__PHYSFS_platformEnumerateFiles(const char *dirname, |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
546 |
int omitSymLinks) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
547 |
{ |
362
ac8c846a0a66
Changed enumeration code to use __PHYSFS_addToLinkedStringList().
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
548 |
LinkedStringList *ret = NULL, *p = NULL; |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
549 |
UInt16 i; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
550 |
UInt16 max; |
166
ed10fe7cb16e
More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
162
diff
changeset
|
551 |
FSSpec spec; |
ed10fe7cb16e
More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
162
diff
changeset
|
552 |
CInfoPBRec infoPB; |
ed10fe7cb16e
More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
162
diff
changeset
|
553 |
Str255 str255; |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
554 |
long dirID; |
166
ed10fe7cb16e
More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
162
diff
changeset
|
555 |
|
393 | 556 |
BAIL_IF_MACRO(fnameToFSSpec(dirname, &spec) != noErr, NULL, 0); |
166
ed10fe7cb16e
More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
162
diff
changeset
|
557 |
|
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
558 |
/* get the dir ID of what we want to enumerate... */ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
559 |
memset(&infoPB, '\0', sizeof (CInfoPBRec)); |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
560 |
infoPB.dirInfo.ioNamePtr = spec.name; /* name of dir to enum. */ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
561 |
infoPB.dirInfo.ioVRefNum = spec.vRefNum; /* ID of file's volume. */ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
562 |
infoPB.dirInfo.ioDrDirID = spec.parID; /* ID of dir. */ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
563 |
infoPB.dirInfo.ioFDirIndex = 0; /* file (not parent) info. */ |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
564 |
BAIL_IF_MACRO(oserr(PBGetCatInfoSync(&infoPB)) != noErr, NULL, NULL); |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
565 |
|
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
566 |
if ((infoPB.dirInfo.ioFlAttrib & kioFlAttribDirMask) == 0) |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
567 |
BAIL_MACRO(ERR_NOT_A_DIR, NULL); |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
568 |
|
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
569 |
dirID = infoPB.dirInfo.ioDrDirID; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
570 |
max = infoPB.dirInfo.ioDrNmFls; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
571 |
|
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
572 |
for (i = 1; i <= max; i++) |
166
ed10fe7cb16e
More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
162
diff
changeset
|
573 |
{ |
183
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
574 |
FSSpec aliasspec; |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
575 |
Boolean alias = 0; |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
576 |
Boolean folder = 0; |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
577 |
|
166
ed10fe7cb16e
More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
162
diff
changeset
|
578 |
memset(&infoPB, '\0', sizeof (CInfoPBRec)); |
ed10fe7cb16e
More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
162
diff
changeset
|
579 |
str255[0] = 0; |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
580 |
infoPB.dirInfo.ioNamePtr = str255; /* store name in here. */ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
581 |
infoPB.dirInfo.ioVRefNum = spec.vRefNum; /* ID of dir's volume. */ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
582 |
infoPB.dirInfo.ioDrDirID = dirID; /* ID of dir. */ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
583 |
infoPB.dirInfo.ioFDirIndex = i; /* next file's info. */ |
166
ed10fe7cb16e
More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
162
diff
changeset
|
584 |
if (PBGetCatInfoSync(&infoPB) != noErr) |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
585 |
continue; /* skip this file. Oh well. */ |
166
ed10fe7cb16e
More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
162
diff
changeset
|
586 |
|
183
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
587 |
if (FSMakeFSSpec(spec.vRefNum, dirID, str255, &aliasspec) != noErr) |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
588 |
continue; /* skip it. */ |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
589 |
|
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
590 |
if (IsAliasFile(&aliasspec, &alias, &folder) != noErr) |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
591 |
continue; /* skip it. */ |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
592 |
|
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
593 |
if ((alias) && (omitSymLinks)) |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
594 |
continue; |
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
595 |
|
352d940a99d0
Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents:
173
diff
changeset
|
596 |
/* still here? Add it to the list. */ |
362
ac8c846a0a66
Changed enumeration code to use __PHYSFS_addToLinkedStringList().
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
597 |
ret = __PHYSFS_addToLinkedStringList(ret, &p, &str255[1], str255[0]); |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
598 |
} /* for */ |
166
ed10fe7cb16e
More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents:
162
diff
changeset
|
599 |
|
362
ac8c846a0a66
Changed enumeration code to use __PHYSFS_addToLinkedStringList().
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
600 |
return(ret); |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
601 |
} /* __PHYSFS_platformEnumerateFiles */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
602 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
603 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
604 |
char *__PHYSFS_platformCurrentDir(void) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
605 |
{ |
162
06ed1dc94f73
Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents:
158
diff
changeset
|
606 |
/* |
06ed1dc94f73
Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents:
158
diff
changeset
|
607 |
* I don't think MacOS has a concept of "current directory", beyond |
06ed1dc94f73
Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents:
158
diff
changeset
|
608 |
* what is grafted on by a given standard C library implementation, |
06ed1dc94f73
Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents:
158
diff
changeset
|
609 |
* so just return the base dir. |
06ed1dc94f73
Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents:
158
diff
changeset
|
610 |
* We don't use this for anything crucial at the moment anyhow. |
06ed1dc94f73
Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents:
158
diff
changeset
|
611 |
*/ |
06ed1dc94f73
Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents:
158
diff
changeset
|
612 |
return(__PHYSFS_platformCalcBaseDir(NULL)); |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
613 |
} /* __PHYSFS_platformCurrentDir */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
614 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
615 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
616 |
char *__PHYSFS_platformRealPath(const char *path) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
617 |
{ |
185
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
618 |
/* |
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
619 |
* fnameToFSSpec() will resolve any symlinks to get to the real |
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
620 |
* file's FSSpec, which, when converted, will contain the real |
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
621 |
* direct path to a given file. convFSSpecToPath() mallocs a |
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
622 |
* return value buffer. |
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
623 |
*/ |
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
624 |
|
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
625 |
FSSpec spec; |
393 | 626 |
BAIL_IF_MACRO(fnameToFSSpec(path, &spec) != noErr, NULL, NULL); |
185
4959e825c3ef
Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
Ryan C. Gordon <icculus@icculus.org>
parents:
183
diff
changeset
|
627 |
return(convFSSpecToPath(&spec, 1)); |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
628 |
} /* __PHYSFS_platformRealPath */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
629 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
630 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
631 |
int __PHYSFS_platformMkDir(const char *path) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
632 |
{ |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
633 |
SInt32 val = 0; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
634 |
FSSpec spec; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
635 |
OSErr err = fnameToFSSpec(path, &spec); |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
636 |
|
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
637 |
BAIL_IF_MACRO(err == noErr, ERR_FILE_EXISTS, 0); |
393 | 638 |
BAIL_IF_MACRO(err != fnfErr, NULL, 0); |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
639 |
|
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
640 |
err = DirCreate(spec.vRefNum, spec.parID, spec.name, &val); |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
641 |
BAIL_IF_MACRO(oserr(err) != noErr, NULL, 0); |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
642 |
return(1); |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
643 |
} /* __PHYSFS_platformMkDir */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
644 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
645 |
|
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
646 |
static SInt16 *macDoOpen(const char *fname, SInt8 perm, int createIfMissing) |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
647 |
{ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
648 |
int created = 0; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
649 |
SInt16 *retval = NULL; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
650 |
FSSpec spec; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
651 |
OSErr err = fnameToFSSpec(fname, &spec); |
393 | 652 |
BAIL_IF_MACRO((err != noErr) && (err != fnfErr), NULL, NULL); |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
653 |
if (err == fnfErr) |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
654 |
{ |
362
ac8c846a0a66
Changed enumeration code to use __PHYSFS_addToLinkedStringList().
Ryan C. Gordon <icculus@icculus.org>
parents:
335
diff
changeset
|
655 |
BAIL_IF_MACRO(!createIfMissing, ERR_NO_SUCH_FILE, NULL); |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
656 |
err = HCreate(spec.vRefNum, spec.parID, spec.name, |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
657 |
procInfo.processSignature, 'BINA'); |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
658 |
BAIL_IF_MACRO(oserr(err) != noErr, NULL, NULL); |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
659 |
created = 1; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
660 |
} /* if */ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
661 |
|
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
662 |
retval = (SInt16 *) malloc(sizeof (SInt16)); |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
663 |
if (retval == NULL) |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
664 |
{ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
665 |
if (created) |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
666 |
HDelete(spec.vRefNum, spec.parID, spec.name); |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
667 |
BAIL_MACRO(ERR_OUT_OF_MEMORY, NULL); |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
668 |
} /* if */ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
669 |
|
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
670 |
err = HOpenDF(spec.vRefNum, spec.parID, spec.name, perm, retval) |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
671 |
if (oserr(err) != noErr) |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
672 |
{ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
673 |
free(retval); |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
674 |
if (created) |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
675 |
HDelete(spec.vRefNum, spec.parID, spec.name); |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
676 |
return(NULL); |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
677 |
} /* if */ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
678 |
|
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
679 |
return(retval); |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
680 |
} /* macDoOpen */ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
681 |
|
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
682 |
|
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
683 |
void *__PHYSFS_platformOpenRead(const char *filename) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
684 |
{ |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
685 |
SInt16 *retval = macDoOpen(filename, fsRdPerm, 0); |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
686 |
if (retval != NULL) /* got a file; seek to start. */ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
687 |
{ |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
688 |
if (oserr(SetFPos(*retval, fsFromStart, 0)) != noErr) |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
689 |
{ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
690 |
FSClose(*retval); |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
691 |
return(NULL); |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
692 |
} /* if */ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
693 |
} /* if */ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
694 |
|
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
695 |
return((void *) retval); |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
696 |
} /* __PHYSFS_platformOpenRead */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
697 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
698 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
699 |
void *__PHYSFS_platformOpenWrite(const char *filename) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
700 |
{ |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
701 |
SInt16 *retval = macDoOpen(filename, fsRdWrPerm, 1); |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
702 |
if (retval != NULL) /* got a file; truncate it. */ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
703 |
{ |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
704 |
if ((oserr(SetEOF(*retval, 0)) != noErr) || |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
705 |
(oserr(SetFPos(*retval, fsFromStart, 0)) != noErr)) |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
706 |
{ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
707 |
FSClose(*retval); |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
708 |
return(NULL); |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
709 |
} /* if */ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
710 |
} /* if */ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
711 |
|
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
712 |
return((void *) retval); |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
713 |
} /* __PHYSFS_platformOpenWrite */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
714 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
715 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
716 |
void *__PHYSFS_platformOpenAppend(const char *filename) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
717 |
{ |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
718 |
SInt16 *retval = macDoOpen(filename, fsRdWrPerm, 1); |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
719 |
if (retval != NULL) /* got a file; seek to end. */ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
720 |
{ |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
721 |
if (oserr(SetFPos(*retval, fsFromLEOF, 0)) != noErr) |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
722 |
{ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
723 |
FSClose(*retval); |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
724 |
return(NULL); |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
725 |
} /* if */ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
726 |
} /* if */ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
727 |
|
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
728 |
return(retval); |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
729 |
} /* __PHYSFS_platformOpenAppend */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
730 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
731 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
732 |
PHYSFS_sint64 __PHYSFS_platformRead(void *opaque, void *buffer, |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
733 |
PHYSFS_uint32 size, PHYSFS_uint32 count) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
734 |
{ |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
735 |
SInt16 ref = *((SInt16 *) opaque); |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
736 |
SInt32 br; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
737 |
PHYSFS_uint32 i; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
738 |
|
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
739 |
for (i = 0; i < count; i++) |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
740 |
{ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
741 |
br = size; |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
742 |
BAIL_IF_MACRO(oserr(FSRead(ref, &br, buffer)) != noErr, NULL, i); |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
743 |
BAIL_IF_MACRO(br != size, NULL, i); /* !!! FIXME: seek back if only read part of an object! */ |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
744 |
buffer = ((PHYSFS_uint8 *) buffer) + size; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
745 |
} /* for */ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
746 |
|
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
747 |
return(count); |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
748 |
} /* __PHYSFS_platformRead */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
749 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
750 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
751 |
PHYSFS_sint64 __PHYSFS_platformWrite(void *opaque, const void *buffer, |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
752 |
PHYSFS_uint32 size, PHYSFS_uint32 count) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
753 |
{ |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
754 |
SInt16 ref = *((SInt16 *) opaque); |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
755 |
SInt32 bw; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
756 |
PHYSFS_uint32 i; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
757 |
|
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
758 |
for (i = 0; i < count; i++) |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
759 |
{ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
760 |
bw = size; |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
761 |
BAIL_IF_MACRO(oserr(FSWrite(ref, &bw, buffer)) != noErr, NULL, i); |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
762 |
BAIL_IF_MACRO(bw != size, NULL, i); /* !!! FIXME: seek back if only wrote part of an object! */ |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
763 |
buffer = ((PHYSFS_uint8 *) buffer) + size; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
764 |
} /* for */ |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
765 |
|
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
766 |
return(count); |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
767 |
} /* __PHYSFS_platformWrite */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
768 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
769 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
770 |
int __PHYSFS_platformSeek(void *opaque, PHYSFS_uint64 pos) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
771 |
{ |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
772 |
SInt16 ref = *((SInt16 *) opaque); |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
773 |
OSErr err = SetFPos(ref, fsFromStart, (SInt32) pos); |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
774 |
BAIL_IF_MACRO(oserr(err) != noErr, NULL, 0); |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
775 |
return(1); |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
776 |
} /* __PHYSFS_platformSeek */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
777 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
778 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
779 |
PHYSFS_sint64 __PHYSFS_platformTell(void *opaque) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
780 |
{ |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
781 |
SInt16 ref = *((SInt16 *) opaque); |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
782 |
SInt32 curPos; |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
783 |
BAIL_IF_MACRO(oserr(GetFPos(ref, &curPos)) != noErr, NULL, -1); |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
784 |
return((PHYSFS_sint64) curPos); |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
785 |
} /* __PHYSFS_platformTell */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
786 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
787 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
788 |
PHYSFS_sint64 __PHYSFS_platformFileLength(void *opaque) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
789 |
{ |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
790 |
SInt16 ref = *((SInt16 *) opaque); |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
791 |
SInt32 eofPos; |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
792 |
BAIL_IF_MACRO(oserr(GetEOF(ref, &eofPos)) != noErr, NULL, -1); |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
793 |
return((PHYSFS_sint64) eofPos); |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
794 |
} /* __PHYSFS_platformFileLength */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
795 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
796 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
797 |
int __PHYSFS_platformEOF(void *opaque) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
798 |
{ |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
799 |
SInt16 ref = *((SInt16 *) opaque); |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
800 |
SInt32 eofPos, curPos; |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
801 |
BAIL_IF_MACRO(oserr(GetEOF(ref, &eofPos)) != noErr, NULL, 1); |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
802 |
BAIL_IF_MACRO(oserr(GetFPos(ref, &curPos)) != noErr, NULL, 1); |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
803 |
return(curPos >= eofPos); |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
804 |
} /* __PHYSFS_platformEOF */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
805 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
806 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
807 |
int __PHYSFS_platformFlush(void *opaque) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
808 |
{ |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
809 |
SInt16 ref = *((SInt16 *) opaque); |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
810 |
ParamBlockRec pb; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
811 |
memset(&pb, '\0', sizeof (ParamBlockRec)); |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
812 |
pb.ioParam.ioRefNum = ref; |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
813 |
BAIL_IF_MACRO(oserr(PBFlushFileSync(&pb)) != noErr, NULL, 0); |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
814 |
return(1); |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
815 |
} /* __PHYSFS_platformFlush */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
816 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
817 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
818 |
int __PHYSFS_platformClose(void *opaque) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
819 |
{ |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
820 |
SInt16 ref = *((SInt16 *) opaque); |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
821 |
SInt16 vRefNum; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
822 |
Str63 volName; |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
823 |
int flushVol = 0; |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
824 |
|
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
825 |
if (GetVRefNum(ref, &vRefNum) == noErr) |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
826 |
{ |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
827 |
HParamBlockRec hpbr; |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
828 |
memset(&hpbr, '\0', sizeof (HParamBlockRec)); |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
829 |
hpbr.volumeParam.ioNamePtr = volName; |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
830 |
hpbr.volumeParam.ioVRefNum = vRefNum; |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
831 |
hpbr.volumeParam.ioVolIndex = 0; |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
832 |
if (PBHGetVInfoSync(&hpbr) == noErr) |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
833 |
flushVol = 1; |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
834 |
} /* if */ |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
835 |
|
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
836 |
BAIL_IF_MACRO(oserr(FSClose(ref)) != noErr, NULL, 0); |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
837 |
free(opaque); |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
838 |
|
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
839 |
if (flushVol) |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
840 |
FlushVol(volName, vRefNum); /* update catalog info, etc. */ |
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
841 |
|
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
842 |
return(1); |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
843 |
} /* __PHYSFS_platformClose */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
844 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
845 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
846 |
int __PHYSFS_platformDelete(const char *path) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
847 |
{ |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
848 |
FSSpec spec; |
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
849 |
OSErr err; |
393 | 850 |
BAIL_IF_MACRO(fnameToFSSpec(path, &spec) != noErr, NULL, 0); |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
851 |
err = HDelete(spec.vRefNum, spec.parID, spec.name); |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
852 |
BAIL_IF_MACRO(oserr(err) != noErr, NULL, 0); |
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
853 |
return(1); |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
854 |
} /* __PHYSFS_platformDelete */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
855 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
856 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
857 |
void *__PHYSFS_platformCreateMutex(void) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
858 |
{ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
859 |
return((void *) 0x0001); /* no mutexes on MacOS Classic. */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
860 |
} /* __PHYSFS_platformCreateMutex */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
861 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
862 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
863 |
void __PHYSFS_platformDestroyMutex(void *mutex) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
864 |
{ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
865 |
/* no mutexes on MacOS Classic. */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
866 |
} /* __PHYSFS_platformDestroyMutex */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
867 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
868 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
869 |
int __PHYSFS_platformGrabMutex(void *mutex) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
870 |
{ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
871 |
return(1); /* no mutexes on MacOS Classic. */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
872 |
} /* __PHYSFS_platformGrabMutex */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
873 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
874 |
|
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
875 |
void __PHYSFS_platformReleaseMutex(void *mutex) |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
876 |
{ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
877 |
/* no mutexes on MacOS Classic. */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
878 |
} /* __PHYSFS_platformReleaseMutex */ |
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
879 |
|
240
052041af9001
Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
880 |
|
052041af9001
Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
881 |
PHYSFS_sint64 __PHYSFS_platformGetLastModTime(const char *fname) |
052041af9001
Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
882 |
{ |
247
fd2af57f1e93
Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents:
240
diff
changeset
|
883 |
FSSpec spec; |
fd2af57f1e93
Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents:
240
diff
changeset
|
884 |
CInfoPBRec infoPB; |
fd2af57f1e93
Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents:
240
diff
changeset
|
885 |
UInt32 modDate; |
fd2af57f1e93
Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents:
240
diff
changeset
|
886 |
|
393 | 887 |
if (fnameToFSSpec(fname, &spec) != noErr) |
888 |
return(-1); /* fnameToFSSpec() sets physfs error message. */ |
|
247
fd2af57f1e93
Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents:
240
diff
changeset
|
889 |
|
fd2af57f1e93
Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents:
240
diff
changeset
|
890 |
memset(&infoPB, '\0', sizeof (CInfoPBRec)); |
fd2af57f1e93
Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents:
240
diff
changeset
|
891 |
infoPB.dirInfo.ioNamePtr = spec.name; |
fd2af57f1e93
Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents:
240
diff
changeset
|
892 |
infoPB.dirInfo.ioVRefNum = spec.vRefNum; |
fd2af57f1e93
Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents:
240
diff
changeset
|
893 |
infoPB.dirInfo.ioDrDirID = spec.parID; |
fd2af57f1e93
Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents:
240
diff
changeset
|
894 |
infoPB.dirInfo.ioFDirIndex = 0; |
424
a691527e9f6e
Now returns human-readable error messages when possible. Minor fix in
Ryan C. Gordon <icculus@icculus.org>
parents:
393
diff
changeset
|
895 |
BAIL_IF_MACRO(oserr(PBGetCatInfoSync(&infoPB)) != noErr, NULL, -1); |
247
fd2af57f1e93
Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents:
240
diff
changeset
|
896 |
|
fd2af57f1e93
Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents:
240
diff
changeset
|
897 |
modDate = ((infoPB.dirInfo.ioFlAttrib & kioFlAttribDirMask) != 0) ? |
fd2af57f1e93
Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents:
240
diff
changeset
|
898 |
infoPB.dirInfo.ioDrMdDat : infoPB.hFileInfo.ioFlMdDat; |
fd2af57f1e93
Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents:
240
diff
changeset
|
899 |
|
fd2af57f1e93
Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents:
240
diff
changeset
|
900 |
/* epoch is different on MacOS. They use Jan 1, 1904, apparently. */ |
fd2af57f1e93
Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents:
240
diff
changeset
|
901 |
/* subtract seconds between those epochs, counting leap years. */ |
fd2af57f1e93
Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents:
240
diff
changeset
|
902 |
modDate -= 2082844800; |
fd2af57f1e93
Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents:
240
diff
changeset
|
903 |
|
fd2af57f1e93
Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents:
240
diff
changeset
|
904 |
return((PHYSFS_sint64) modDate); |
240
052041af9001
Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
905 |
} /* __PHYSFS_platformGetLastModTime */ |
052041af9001
Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
906 |
|
173
72a59de5e6e5
Mostly implemented (fully implemented if you don't want aliases to work like symlinks).
Ryan C. Gordon <icculus@icculus.org>
parents:
169
diff
changeset
|
907 |
/* end of macclassic.c ... */ |
157
916ee05fe0db
Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
908 |