Fixed __PHYSFS_platformRealPath(), and changed userdir behaviour. We're now feature-complete on the Mac, as far as I can tell.
This commit is contained in:
parent
fb712cbeff
commit
f56737b579
|
@ -139,22 +139,22 @@ char **__PHYSFS_platformDetectAvailableCDs(void)
|
||||||
} /* __PHYSFS_platformDetectAvailableCDs */
|
} /* __PHYSFS_platformDetectAvailableCDs */
|
||||||
|
|
||||||
|
|
||||||
char *__PHYSFS_platformCalcBaseDir(const char *argv0)
|
static char *convFSSpecToPath(FSSpec *spec, int includeFile)
|
||||||
{
|
{
|
||||||
char *ptr;
|
char *ptr;
|
||||||
char *retval = NULL;
|
char *retval = NULL;
|
||||||
UInt32 retLength = 0;
|
UInt32 retLength = 0;
|
||||||
CInfoPBRec infoPB;
|
CInfoPBRec infoPB;
|
||||||
Str255 str255;
|
Str255 str255;
|
||||||
FSSpec spec;
|
|
||||||
|
str255[0] = spec->name[0];
|
||||||
/* Get the name of the binary's parent directory. */
|
memcpy(&str255[1], &spec->name[1], str255[0]);
|
||||||
memcpy(&spec, &procfsspec, sizeof (FSSpec));
|
|
||||||
memset(&infoPB, '\0', sizeof (CInfoPBRec));
|
memset(&infoPB, '\0', sizeof (CInfoPBRec));
|
||||||
infoPB.dirInfo.ioNamePtr = str255; /* put name in here. */
|
infoPB.dirInfo.ioNamePtr = str255; /* put name in here. */
|
||||||
infoPB.dirInfo.ioVRefNum = spec.vRefNum; /* ID of bin's volume. */
|
infoPB.dirInfo.ioVRefNum = spec->vRefNum; /* ID of bin's volume. */
|
||||||
infoPB.dirInfo.ioDrParID = spec.parID; /* ID of bin's dir. */
|
infoPB.dirInfo.ioDrParID = spec->parID; /* ID of bin's dir. */
|
||||||
infoPB.dirInfo.ioFDirIndex = -1; /* get dir (not file) info. */
|
infoPB.dirInfo.ioFDirIndex = (includeFile) ? 0 : -1;
|
||||||
|
|
||||||
/* walk the tree back to the root dir (volume), building path string... */
|
/* walk the tree back to the root dir (volume), building path string... */
|
||||||
do
|
do
|
||||||
|
@ -167,7 +167,9 @@ char *__PHYSFS_platformCalcBaseDir(const char *argv0)
|
||||||
free(retval);
|
free(retval);
|
||||||
BAIL_MACRO(ERR_OS_ERROR, NULL);
|
BAIL_MACRO(ERR_OS_ERROR, NULL);
|
||||||
} /* if */
|
} /* if */
|
||||||
|
|
||||||
|
infoPB.dirInfo.ioFDirIndex = -1; /* look at parent dir next time. */
|
||||||
|
|
||||||
/* allocate more space for the retval... */
|
/* allocate more space for the retval... */
|
||||||
retLength += str255[0] + 1; /* + 1 for a ':' or null char... */
|
retLength += str255[0] + 1; /* + 1 for a ':' or null char... */
|
||||||
ptr = (char *) malloc(retLength);
|
ptr = (char *) malloc(retLength);
|
||||||
|
@ -191,6 +193,16 @@ char *__PHYSFS_platformCalcBaseDir(const char *argv0)
|
||||||
} while (infoPB.dirInfo.ioDrDirID != fsRtDirID);
|
} while (infoPB.dirInfo.ioDrDirID != fsRtDirID);
|
||||||
|
|
||||||
return(retval);
|
return(retval);
|
||||||
|
} /* convFSSpecToPath */
|
||||||
|
|
||||||
|
|
||||||
|
char *__PHYSFS_platformCalcBaseDir(const char *argv0)
|
||||||
|
{
|
||||||
|
FSSpec spec;
|
||||||
|
|
||||||
|
/* Get the name of the binary's parent directory. */
|
||||||
|
FSMakeFSSpec(procfsspec.vRefNum, procfsspec.parID, procfsspec.name, &spec);
|
||||||
|
return(convFSSpecToPath(&spec, 0));
|
||||||
} /* __PHYSFS_platformCalcBaseDir */
|
} /* __PHYSFS_platformCalcBaseDir */
|
||||||
|
|
||||||
|
|
||||||
|
@ -224,7 +236,12 @@ char *__PHYSFS_platformGetUserName(void)
|
||||||
|
|
||||||
char *__PHYSFS_platformGetUserDir(void)
|
char *__PHYSFS_platformGetUserDir(void)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
return(NULL); /* bah...use default behaviour, I guess. */
|
return(NULL); /* bah...use default behaviour, I guess. */
|
||||||
|
#else
|
||||||
|
/* (Hmm. Default behaviour is broken in the base library. :) ) */
|
||||||
|
return(__PHYSFS_platformCalcBaseDir(NULL));
|
||||||
|
#endif
|
||||||
} /* __PHYSFS_platformGetUserDir */
|
} /* __PHYSFS_platformGetUserDir */
|
||||||
|
|
||||||
|
|
||||||
|
@ -528,10 +545,16 @@ char *__PHYSFS_platformCurrentDir(void)
|
||||||
|
|
||||||
char *__PHYSFS_platformRealPath(const char *path)
|
char *__PHYSFS_platformRealPath(const char *path)
|
||||||
{
|
{
|
||||||
/* !!! FIXME: This isn't nearly right. */
|
/*
|
||||||
char *retval = (char *) malloc(strlen(path) + 1);
|
* fnameToFSSpec() will resolve any symlinks to get to the real
|
||||||
strcpy(retval, path);
|
* file's FSSpec, which, when converted, will contain the real
|
||||||
return(retval);
|
* direct path to a given file. convFSSpecToPath() mallocs a
|
||||||
|
* return value buffer.
|
||||||
|
*/
|
||||||
|
|
||||||
|
FSSpec spec;
|
||||||
|
BAIL_IF_MACRO(fnameToFSSpec(path, &spec) != noErr, ERR_OS_ERROR, NULL);
|
||||||
|
return(convFSSpecToPath(&spec, 1));
|
||||||
} /* __PHYSFS_platformRealPath */
|
} /* __PHYSFS_platformRealPath */
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue