platform/macclassic.c
author Ryan C. Gordon <icculus@icculus.org>
Tue, 23 Jul 2002 07:46:36 +0000
changeset 362 ac8c846a0a66
parent 335 1d4720c018c3
child 393 468f75bf4d7d
permissions -rw-r--r--
Changed enumeration code to use __PHYSFS_addToLinkedStringList().
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
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
    63
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
    64
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
    65
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    66
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
    67
{
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
    68
    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
    69
    ProcessSerialNumber psn;
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
    70
    BAIL_IF_MACRO(GetCurrentProcess(&psn) != noErr, ERR_OS_ERROR, 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
    71
    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
    72
    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
    73
    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
    74
    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
    75
    err = GetProcessInformation(&psn, &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
    76
    BAIL_IF_MACRO(err != noErr, ERR_OS_ERROR, 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
    77
    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
    78
} /* __PHYSFS_platformInit */
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    79
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    80
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    81
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
    82
{
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    83
    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
    84
} /* __PHYSFS_platformDeinit */
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    85
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    86
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
    87
/* 
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
    88
 * 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
    89
 *  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
    90
 */
157
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    91
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
    92
{
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
    93
    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
    94
    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
    95
    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
    96
    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
    97
    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
    98
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
    99
    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
   100
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
   101
    *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
   102
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
   103
    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
   104
    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
   105
    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
   106
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
   107
    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
   108
    {
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
   109
        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
   110
        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
   111
        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
   112
        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
   113
        {
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
   114
            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
   115
            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
   116
            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
   117
            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
   118
            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
   119
            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
   120
            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
   121
            {
316
29a4d12d1dc6 Fixed buffer overflow in CD-ROM detection code.
Ryan C. Gordon <icculus@icculus.org>
parents: 247
diff changeset
   122
                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
   123
                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
   124
                {
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
   125
                    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
   126
                    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
   127
                    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
   128
                    {
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
   129
                        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
   130
                        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
   131
                        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
   132
                        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
   133
                    } /* 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
   134
                } /* 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
   135
            } /* 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
   136
        } /* 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
   137
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
   138
        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
   139
    } /* 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
   140
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
   141
    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
   142
    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
   143
} /* __PHYSFS_platformDetectAvailableCDs */
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   144
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   145
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
   146
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
   147
{
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   148
    char *ptr;
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   149
    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
   150
    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
   151
    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
   152
    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
   153
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
   154
    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
   155
    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
   156
157
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   157
    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
   158
    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
   159
    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
   160
    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
   161
    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
   162
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   163
    /* 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
   164
    do
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   165
    {
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   166
        /* 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
   167
        infoPB.dirInfo.ioDrDirID = infoPB.dirInfo.ioDrParID;
166
ed10fe7cb16e More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents: 162
diff changeset
   168
        if (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
   169
        {
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   170
            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
   171
                free(retval);
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   172
            BAIL_MACRO(ERR_OS_ERROR, NULL);
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   173
        } /* 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
   174
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
   175
        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
   176
157
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   177
        /* 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
   178
        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
   179
        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
   180
        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
   181
        {
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   182
            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
   183
                free(retval);
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   184
            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
   185
        } /* if */
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   186
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   187
        /* 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
   188
        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
   189
        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
   190
        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
   191
        {
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   192
            strcat(ptr, ":");
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   193
            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
   194
            free(retval);
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   195
        } /* if */
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   196
        retval = ptr;
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   197
    } 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
   198
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   199
    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
   200
} /* 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
   201
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
   202
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
   203
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
   204
{
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
   205
    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
   206
    
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
   207
    /* 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
   208
    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
   209
    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
   210
} /* __PHYSFS_platformCalcBaseDir */
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   211
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   212
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   213
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
   214
{
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   215
    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
   216
    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
   217
    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
   218
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
   219
    /* 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
   220
    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
   221
    /* apparently, -16096 specifies the username. */
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
   222
    strHandle = GetString(-16096);
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
   223
    UseResFile(origResourceFile);
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
   224
    BAIL_IF_MACRO(strHandle == NULL, ERR_OS_ERROR, NULL);
157
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   225
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
   226
    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
   227
    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
   228
    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
   229
    {
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
   230
        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
   231
        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
   232
    } /* 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
   233
    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
   234
    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
   235
    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
   236
157
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   237
    return(retval);
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   238
} /* __PHYSFS_platformGetUserName */
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   239
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   240
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   241
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
   242
{
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
   243
#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
   244
    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
   245
#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
   246
    /* (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
   247
    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
   248
#endif
157
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   249
} /* __PHYSFS_platformGetUserDir */
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   250
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   251
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   252
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
   253
{
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   254
    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
   255
} /* __PHYSFS_platformGetThreadID */
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
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   258
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
   259
{
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   260
    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
   261
    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
   262
} /* __PHYSFS_platformStricmp */
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   263
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   264
183
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   265
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
   266
{
169
34829282ffe8 Fixed isDirectory and enumarateFiles (had wrong param in PBGetCatInfoSync()).
Ryan C. Gordon <icculus@icculus.org>
parents: 166
diff changeset
   267
    OSErr err;
166
ed10fe7cb16e More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents: 162
diff changeset
   268
    Str255 str255;
335
1d4720c018c3 FIXME cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents: 316
diff changeset
   269
    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
   270
    int len = strlen(fname) + ((needColon) ? 1 : 0);
166
ed10fe7cb16e More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents: 162
diff changeset
   271
    if (len > 255)
ed10fe7cb16e More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents: 162
diff changeset
   272
        return(bdNamErr);
ed10fe7cb16e More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents: 162
diff changeset
   273
ed10fe7cb16e More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents: 162
diff changeset
   274
    /* !!! FIXME: What happens with relative pathnames? */
ed10fe7cb16e More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents: 162
diff changeset
   275
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
   276
    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
   277
    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
   278
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
   279
    /* 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
   280
    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
   281
        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
   282
169
34829282ffe8 Fixed isDirectory and enumarateFiles (had wrong param in PBGetCatInfoSync()).
Ryan C. Gordon <icculus@icculus.org>
parents: 166
diff changeset
   283
    err = FSMakeFSSpec(0, 0, str255, spec);
34829282ffe8 Fixed isDirectory and enumarateFiles (had wrong param in PBGetCatInfoSync()).
Ryan C. Gordon <icculus@icculus.org>
parents: 166
diff changeset
   284
    return(err);
183
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   285
} /* fnameToFSSpecNoAlias */
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   286
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   287
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   288
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
   289
{
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   290
    Boolean alias = 0;
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   291
    Boolean folder = 0;
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   292
    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
   293
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   294
    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
   295
    {
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   296
        /* 
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   297
         * 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
   298
         *  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
   299
         *  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
   300
         */
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   301
        char *ptr;
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   302
        char *start;
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   303
        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
   304
        strcpy(path, fname);
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   305
        ptr = strchr(path, ':');
362
ac8c846a0a66 Changed enumeration code to use __PHYSFS_addToLinkedStringList().
Ryan C. Gordon <icculus@icculus.org>
parents: 335
diff changeset
   306
        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
   307
        ptr = strchr(ptr + 1, ':');
362
ac8c846a0a66 Changed enumeration code to use __PHYSFS_addToLinkedStringList().
Ryan C. Gordon <icculus@icculus.org>
parents: 335
diff changeset
   308
        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
   309
        *ptr = '\0';
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   310
        err = fnameToFSSpecNoAlias(path, spec); /* get first dir. */
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   311
        BAIL_IF_MACRO(err != noErr, ERR_OS_ERROR, err);
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   312
        start = ptr;
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   313
        ptr = strchr(start + 1, ':');
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   314
335
1d4720c018c3 FIXME cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents: 316
diff changeset
   315
        /* 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
   316
        do
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   317
        {
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   318
            CInfoPBRec infoPB;
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   319
            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
   320
            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
   321
            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
   322
            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
   323
            infoPB.dirInfo.ioFDirIndex = 0;
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   324
            err = PBGetCatInfoSync(&infoPB);
335
1d4720c018c3 FIXME cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents: 316
diff changeset
   325
            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
   326
                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
   327
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   328
            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
   329
                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
   330
335
1d4720c018c3 FIXME cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents: 316
diff changeset
   331
            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
   332
                *ptr = '\0';
335
1d4720c018c3 FIXME cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents: 316
diff changeset
   333
183
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   334
            *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
   335
            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
   336
                               (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
   337
            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
   338
                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
   339
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   340
            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
   341
            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
   342
                return(fnameToFSSpecNoAlias(fname, spec)); /* reset */
335
1d4720c018c3 FIXME cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents: 316
diff changeset
   343
1d4720c018c3 FIXME cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents: 316
diff changeset
   344
            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
   345
            if (ptr != NULL)
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   346
                ptr = strchr(start + 1, ':');                
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   347
        } while (start != NULL);
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   348
    } /* if */
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   349
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   350
    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
   351
    {
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   352
        BAIL_IF_MACRO(err != noErr, ERR_OS_ERROR, err);
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   353
        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
   354
        BAIL_IF_MACRO(err != noErr, ERR_OS_ERROR, err);
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   355
    } /* else */
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   356
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   357
    return(noErr);  /* w00t. */
166
ed10fe7cb16e More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents: 162
diff changeset
   358
} /* fnameToFSSpec */
ed10fe7cb16e More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents: 162
diff changeset
   359
ed10fe7cb16e More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents: 162
diff changeset
   360
157
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   361
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
   362
{
166
ed10fe7cb16e More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents: 162
diff changeset
   363
    FSSpec spec;
ed10fe7cb16e More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents: 162
diff changeset
   364
    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
   365
} /* __PHYSFS_platformExists */
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   366
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   367
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   368
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
   369
{
183
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   370
    OSErr err;
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   371
    FSSpec spec;
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   372
    Boolean a = 0;
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   373
    Boolean f = 0;
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   374
    CInfoPBRec infoPB;
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   375
    char *ptr;
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   376
    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
   377
    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
   378
    strcpy(dir, fname);
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   379
    ptr = strrchr(dir, ':');
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   380
    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
   381
        return(0);
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
    /* 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
   384
    *ptr = '\0';
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   385
    BAIL_IF_MACRO(fnameToFSSpec(dir, &spec) != noErr, ERR_OS_ERROR, 0);
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   386
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   387
    *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
   388
    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
   389
    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
   390
    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
   391
    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
   392
    infoPB.dirInfo.ioFDirIndex = 0;
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   393
    BAIL_IF_MACRO(PBGetCatInfoSync(&infoPB) != noErr, ERR_OS_ERROR, 0);
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   394
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   395
    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
   396
                       (const unsigned char *) ptr, &spec);
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   397
    BAIL_IF_MACRO(err != noErr, ERR_OS_ERROR, 0);
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   398
    BAIL_IF_MACRO(IsAliasFile(&spec, &a, &f) != noErr, ERR_OS_ERROR, 0);
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   399
    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
   400
} /* __PHYSFS_platformIsSymlink */
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   401
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   402
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   403
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
   404
{
166
ed10fe7cb16e More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents: 162
diff changeset
   405
    FSSpec spec;
ed10fe7cb16e More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents: 162
diff changeset
   406
    CInfoPBRec infoPB;
169
34829282ffe8 Fixed isDirectory and enumarateFiles (had wrong param in PBGetCatInfoSync()).
Ryan C. Gordon <icculus@icculus.org>
parents: 166
diff changeset
   407
    OSErr err;
166
ed10fe7cb16e More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents: 162
diff changeset
   408
ed10fe7cb16e More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents: 162
diff changeset
   409
    BAIL_IF_MACRO(fnameToFSSpec(fname, &spec) != noErr, ERR_OS_ERROR, 0);
ed10fe7cb16e More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents: 162
diff changeset
   410
    memset(&infoPB, '\0', sizeof (CInfoPBRec));
ed10fe7cb16e More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents: 162
diff changeset
   411
    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
   412
    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
   413
    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
   414
    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
   415
    err = PBGetCatInfoSync(&infoPB);
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
   416
    BAIL_IF_MACRO(err != noErr, ERR_OS_ERROR, 0);
166
ed10fe7cb16e More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents: 162
diff changeset
   417
    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
   418
} /* __PHYSFS_platformIsDirectory */
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   419
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   420
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   421
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
   422
                                      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
   423
                                      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
   424
{
162
06ed1dc94f73 Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents: 158
diff changeset
   425
    int len = ((prepend) ? strlen(prepend) : 0) +
06ed1dc94f73 Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents: 158
diff changeset
   426
              ((append) ? strlen(append) : 0) +
06ed1dc94f73 Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents: 158
diff changeset
   427
              strlen(dirName) + 1;
06ed1dc94f73 Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents: 158
diff changeset
   428
    const char *src;
06ed1dc94f73 Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents: 158
diff changeset
   429
    char *dst;
06ed1dc94f73 Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents: 158
diff changeset
   430
    char *retval = malloc(len);
06ed1dc94f73 Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents: 158
diff changeset
   431
    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
   432
06ed1dc94f73 Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents: 158
diff changeset
   433
    if (prepend != NULL)
06ed1dc94f73 Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents: 158
diff changeset
   434
    {
06ed1dc94f73 Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents: 158
diff changeset
   435
        strcpy(retval, prepend);
06ed1dc94f73 Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents: 158
diff changeset
   436
        dst = retval + strlen(retval);
06ed1dc94f73 Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents: 158
diff changeset
   437
    } /* if */
06ed1dc94f73 Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents: 158
diff changeset
   438
    else
06ed1dc94f73 Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents: 158
diff changeset
   439
    {
06ed1dc94f73 Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents: 158
diff changeset
   440
        *retval = '\0';
06ed1dc94f73 Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents: 158
diff changeset
   441
        dst = retval;
06ed1dc94f73 Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents: 158
diff changeset
   442
    } /* else */
06ed1dc94f73 Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents: 158
diff changeset
   443
06ed1dc94f73 Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents: 158
diff changeset
   444
    for (src = dirName; *src; src++, dst++)
06ed1dc94f73 Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents: 158
diff changeset
   445
        *dst = ((*src == '/') ? ':' : *src);
06ed1dc94f73 Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents: 158
diff changeset
   446
06ed1dc94f73 Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents: 158
diff changeset
   447
    *dst = '\0';
06ed1dc94f73 Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents: 158
diff changeset
   448
    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
   449
} /* __PHYSFS_platformCvtToDependent */
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   450
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   451
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   452
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
   453
{
162
06ed1dc94f73 Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents: 158
diff changeset
   454
    SystemTask();
157
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   455
} /* __PHYSFS_platformTimeslice */
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   456
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   457
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   458
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
   459
                                                  int omitSymLinks)
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   460
{
362
ac8c846a0a66 Changed enumeration code to use __PHYSFS_addToLinkedStringList().
Ryan C. Gordon <icculus@icculus.org>
parents: 335
diff changeset
   461
    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
   462
    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
   463
    UInt16 max;
166
ed10fe7cb16e More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents: 162
diff changeset
   464
    FSSpec spec;
ed10fe7cb16e More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents: 162
diff changeset
   465
    CInfoPBRec infoPB;
ed10fe7cb16e More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents: 162
diff changeset
   466
    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
   467
    long dirID;
166
ed10fe7cb16e More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents: 162
diff changeset
   468
ed10fe7cb16e More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents: 162
diff changeset
   469
    BAIL_IF_MACRO(fnameToFSSpec(dirname, &spec) != noErr, ERR_OS_ERROR, 0);
ed10fe7cb16e More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents: 162
diff changeset
   470
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
   471
    /* 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
   472
    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
   473
    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
   474
    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
   475
    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
   476
    infoPB.dirInfo.ioFDirIndex = 0;           /* file (not parent) info. */
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
   477
    BAIL_IF_MACRO(PBGetCatInfoSync(&infoPB) != noErr, ERR_OS_ERROR, 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
   478
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
   479
    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
   480
        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
   481
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
   482
    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
   483
    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
   484
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
   485
    for (i = 1; i <= max; i++)
166
ed10fe7cb16e More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents: 162
diff changeset
   486
    {
183
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   487
        FSSpec aliasspec;
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   488
        Boolean alias = 0;
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   489
        Boolean folder = 0;
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   490
166
ed10fe7cb16e More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents: 162
diff changeset
   491
        memset(&infoPB, '\0', sizeof (CInfoPBRec));
ed10fe7cb16e More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents: 162
diff changeset
   492
        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
   493
        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
   494
        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
   495
        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
   496
        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
   497
        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
   498
            continue;  /* skip this file. Oh well. */
166
ed10fe7cb16e More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents: 162
diff changeset
   499
183
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   500
        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
   501
            continue;  /* skip it. */
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   502
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   503
        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
   504
            continue;  /* skip it. */
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   505
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   506
        if ((alias) && (omitSymLinks))
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   507
            continue;
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   508
352d940a99d0 Now handles Finder aliases as if they were symlinks.
Ryan C. Gordon <icculus@icculus.org>
parents: 173
diff changeset
   509
        /* 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
   510
        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
   511
    } /* for */
166
ed10fe7cb16e More work. More to go.
Ryan C. Gordon <icculus@icculus.org>
parents: 162
diff changeset
   512
362
ac8c846a0a66 Changed enumeration code to use __PHYSFS_addToLinkedStringList().
Ryan C. Gordon <icculus@icculus.org>
parents: 335
diff changeset
   513
    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
   514
} /* __PHYSFS_platformEnumerateFiles */
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   515
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   516
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   517
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
   518
{
162
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
     * 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
   521
     *  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
   522
     *  so just return the base dir.
06ed1dc94f73 Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents: 158
diff changeset
   523
     * 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
   524
     */
06ed1dc94f73 Implemented platformTimeslice, platformGetCurrentDir, and platformCvtToDependent.
Ryan C. Gordon <icculus@icculus.org>
parents: 158
diff changeset
   525
    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
   526
} /* __PHYSFS_platformCurrentDir */
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   527
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   528
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   529
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
   530
{
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
   531
    /*
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
   532
     * 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
   533
     *  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
   534
     *  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
   535
     *  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
   536
     */
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
   537
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
   538
    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
   539
    BAIL_IF_MACRO(fnameToFSSpec(path, &spec) != noErr, ERR_OS_ERROR, 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
   540
    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
   541
} /* __PHYSFS_platformRealPath */
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   542
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
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
   545
{
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
   546
    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
   547
    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
   548
    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
   549
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
    BAIL_IF_MACRO(err == noErr, ERR_FILE_EXISTS, 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
   551
    BAIL_IF_MACRO(err != fnfErr, ERR_OS_ERROR, 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
   552
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
   553
    err = DirCreate(spec.vRefNum, spec.parID, spec.name, &val);
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
    BAIL_IF_MACRO(err != noErr, ERR_OS_ERROR, 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
   555
    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
   556
} /* __PHYSFS_platformMkDir */
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   557
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   558
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
   559
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
   560
{
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
    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
   562
    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
   563
    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
   564
    OSErr err = fnameToFSSpec(fname, &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
   565
    BAIL_IF_MACRO((err != noErr) && (err != fnfErr), ERR_OS_ERROR, 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
   566
    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
   567
    {
362
ac8c846a0a66 Changed enumeration code to use __PHYSFS_addToLinkedStringList().
Ryan C. Gordon <icculus@icculus.org>
parents: 335
diff changeset
   568
        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
   569
        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
   570
                      procInfo.processSignature, 'BINA');
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
        BAIL_IF_MACRO(err != noErr, ERR_OS_ERROR, 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
   572
        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
   573
    } /* 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
   574
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
   575
    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
   576
    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
   577
    {
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
   578
        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
   579
            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
   580
        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
   581
    } /* 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
   582
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
    if (HOpenDF(spec.vRefNum, spec.parID, spec.name, perm, retval) != 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
   584
    {
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
        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
   586
        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
   587
            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
   588
        BAIL_MACRO(ERR_OS_ERROR, 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
   589
    } /* 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
   590
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
   591
    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
   592
} /* 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
   593
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
   594
157
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   595
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
   596
{
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
   597
    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
   598
    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
   599
    {
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
   600
        if (SetFPos(*retval, fsFromStart, 0) != 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
   601
        {
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
   602
            FSClose(*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
   603
            BAIL_MACRO(ERR_OS_ERROR, 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
   604
        } /* 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
   605
    } /* 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
   606
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
   607
    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
   608
} /* __PHYSFS_platformOpenRead */
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   609
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   610
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   611
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
   612
{
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
   613
    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
   614
    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
   615
    {
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
   616
        if ((SetEOF(*retval, 0) != 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
   617
            (SetFPos(*retval, fsFromStart, 0) != 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
   618
        {
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
   619
            FSClose(*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
   620
            BAIL_MACRO(ERR_OS_ERROR, 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
   621
        } /* 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
   622
    } /* 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
   623
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
   624
    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
   625
} /* __PHYSFS_platformOpenWrite */
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   626
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   627
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   628
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
   629
{
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
   630
    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
   631
    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
   632
    {
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
        if (SetFPos(*retval, fsFromLEOF, 0) != 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
   634
        {
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
            FSClose(*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
   636
            BAIL_MACRO(ERR_OS_ERROR, 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
   637
        } /* 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
   638
    } /* 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
   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
    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
   641
} /* __PHYSFS_platformOpenAppend */
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   642
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   643
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   644
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
   645
                                    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
   646
{
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
   647
    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
   648
    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
   649
    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
   650
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
    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
   652
    {
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
        br = 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
   654
        BAIL_IF_MACRO(FSRead(ref, &br, buffer) != noErr, ERR_OS_ERROR, 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
   655
        BAIL_IF_MACRO(br != size, ERR_OS_ERROR, 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
   656
        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
   657
    } /* 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
   658
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
    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
   660
} /* __PHYSFS_platformRead */
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   661
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   662
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   663
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
   664
                                     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
   665
{
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
   666
    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
   667
    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
   668
    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
   669
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
   670
    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
   671
    {
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
        bw = 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
   673
        BAIL_IF_MACRO(FSWrite(ref, &bw, buffer) != noErr, ERR_OS_ERROR, 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
   674
        BAIL_IF_MACRO(bw != size, ERR_OS_ERROR, 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
   675
        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
   676
    } /* 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
   677
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
    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
   679
} /* __PHYSFS_platformWrite */
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   680
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   681
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   682
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
   683
{
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
   684
    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
   685
    OSErr err = SetFPos(ref, fsFromStart, (SInt32) pos);
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
    BAIL_IF_MACRO(err != noErr, ERR_OS_ERROR, 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
   687
    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
   688
} /* __PHYSFS_platformSeek */
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   689
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   690
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   691
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
   692
{
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
   693
    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
   694
    SInt32 curPos;
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
    BAIL_IF_MACRO(GetFPos(ref, &curPos) != noErr, ERR_OS_ERROR, -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
   696
    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
   697
} /* __PHYSFS_platformTell */
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
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   700
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
   701
{
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
   702
    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
   703
    SInt32 eofPos;
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
   704
    BAIL_IF_MACRO(GetEOF(ref, &eofPos) != noErr, ERR_OS_ERROR, -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
   705
    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
   706
} /* __PHYSFS_platformFileLength */
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   707
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   708
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   709
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
   710
{
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
   711
    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
   712
    SInt32 eofPos, curPos;
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
   713
    BAIL_IF_MACRO(GetEOF(ref, &eofPos) != noErr, ERR_OS_ERROR, 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
   714
    BAIL_IF_MACRO(GetFPos(ref, &curPos) != noErr, ERR_OS_ERROR, 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
   715
    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
   716
} /* __PHYSFS_platformEOF */
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   717
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   718
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   719
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
   720
{
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
   721
    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
   722
    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
   723
    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
   724
    pb.ioParam.ioRefNum = ref;
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
    BAIL_IF_MACRO(PBFlushFileSync(&pb) != noErr, ERR_OS_ERROR, 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
   726
    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
   727
} /* __PHYSFS_platformFlush */
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   728
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   729
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   730
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
   731
{
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
   732
    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
   733
    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
   734
    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
   735
    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
   736
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
    BAIL_IF_MACRO(GetVRefNum (ref, &vRefNum) != noErr, ERR_OS_ERROR, 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
   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
    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
   740
    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
   741
    hpbr.volumeParam.ioVRefNum = 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
   742
    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
   743
    BAIL_IF_MACRO(PBHGetVInfoSync(&hpbr) != noErr, ERR_OS_ERROR, 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
   744
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
    BAIL_IF_MACRO(FSClose(ref) != noErr, ERR_OS_ERROR, 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
   746
    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
   747
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
   748
    FlushVol(volName, 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
   749
    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
   750
} /* __PHYSFS_platformClose */
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   751
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   752
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   753
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
   754
{
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
   755
    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
   756
    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
   757
    BAIL_IF_MACRO(fnameToFSSpec(path, &spec) != noErr, ERR_OS_ERROR, 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
   758
    err = 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
   759
    BAIL_IF_MACRO(err != noErr, ERR_OS_ERROR, 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
   760
    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
   761
} /* __PHYSFS_platformDelete */
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   762
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   763
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   764
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
   765
{
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   766
    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
   767
} /* __PHYSFS_platformCreateMutex */
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
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
   771
{
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   772
    /* 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
   773
} /* __PHYSFS_platformDestroyMutex */
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   774
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   775
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   776
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
   777
{
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   778
    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
   779
} /* __PHYSFS_platformGrabMutex */
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   780
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   781
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   782
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
   783
{
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   784
    /* 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
   785
} /* __PHYSFS_platformReleaseMutex */
916ee05fe0db Initial add. Not nearly complete, but enough to get through PHYSFS_init().
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   786
240
052041af9001 Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   787
052041af9001 Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   788
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
   789
{
247
fd2af57f1e93 Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents: 240
diff changeset
   790
    FSSpec spec;
fd2af57f1e93 Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents: 240
diff changeset
   791
    CInfoPBRec infoPB;
fd2af57f1e93 Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents: 240
diff changeset
   792
    UInt32 modDate;
fd2af57f1e93 Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents: 240
diff changeset
   793
fd2af57f1e93 Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents: 240
diff changeset
   794
    BAIL_IF_MACRO(fnameToFSSpec(fname, &spec) != noErr, ERR_OS_ERROR, -1);
fd2af57f1e93 Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents: 240
diff changeset
   795
fd2af57f1e93 Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents: 240
diff changeset
   796
    memset(&infoPB, '\0', sizeof (CInfoPBRec));
fd2af57f1e93 Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents: 240
diff changeset
   797
    infoPB.dirInfo.ioNamePtr = spec.name;
fd2af57f1e93 Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents: 240
diff changeset
   798
    infoPB.dirInfo.ioVRefNum = spec.vRefNum;
fd2af57f1e93 Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents: 240
diff changeset
   799
    infoPB.dirInfo.ioDrDirID = spec.parID;
fd2af57f1e93 Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents: 240
diff changeset
   800
    infoPB.dirInfo.ioFDirIndex = 0;
fd2af57f1e93 Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents: 240
diff changeset
   801
    BAIL_IF_MACRO(PBGetCatInfoSync(&infoPB) != noErr, ERR_OS_ERROR, -1);
fd2af57f1e93 Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents: 240
diff changeset
   802
fd2af57f1e93 Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents: 240
diff changeset
   803
    modDate = ((infoPB.dirInfo.ioFlAttrib & kioFlAttribDirMask) != 0) ?
fd2af57f1e93 Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents: 240
diff changeset
   804
                   infoPB.dirInfo.ioDrMdDat : infoPB.hFileInfo.ioFlMdDat;
fd2af57f1e93 Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents: 240
diff changeset
   805
fd2af57f1e93 Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents: 240
diff changeset
   806
    /* 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
   807
    /*  subtract seconds between those epochs, counting leap years.   */
fd2af57f1e93 Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents: 240
diff changeset
   808
    modDate -= 2082844800;
fd2af57f1e93 Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents: 240
diff changeset
   809
fd2af57f1e93 Implemented __PHYSFS_platformGetLastModTime().
Ryan C. Gordon <icculus@icculus.org>
parents: 240
diff changeset
   810
    return((PHYSFS_sint64) modDate);
240
052041af9001 Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   811
} /* __PHYSFS_platformGetLastModTime */
052041af9001 Added PHYSFS_getLastModTime() API. (Thanks, John Hall!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
   812
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
   813
/* 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
   814