Minor cleanups.

This commit is contained in:
Ryan C. Gordon 2002-07-25 21:52:07 +00:00
parent 2b0cecee7c
commit 69859a7bd9
4 changed files with 21 additions and 18 deletions

View File

@ -501,6 +501,10 @@ static int GRP_isSymLink(DirHandle *h, const char *name)
static PHYSFS_sint64 GRP_getLastModTime(DirHandle *h, const char *name) static PHYSFS_sint64 GRP_getLastModTime(DirHandle *h, const char *name)
{ {
GRPinfo *info = ((GRPinfo *) h->opaque);
if (grp_find_entry(info, name) == NULL)
return(-1); /* no such entry. */
/* Just return the time of the GRP itself in the physical filesystem. */ /* Just return the time of the GRP itself in the physical filesystem. */
return(((GRPinfo *) h->opaque)->last_mod_time); return(((GRPinfo *) h->opaque)->last_mod_time);
} /* GRP_getLastModTime */ } /* GRP_getLastModTime */

View File

@ -1210,7 +1210,7 @@ int PHYSFS_isDirectory(const char *fname)
DirHandle *h = i->dirHandle; DirHandle *h = i->dirHandle;
if (__PHYSFS_verifySecurity(h, fname)) if (__PHYSFS_verifySecurity(h, fname))
{ {
if (!h->funcs->exists(h, fname)) /* !!! FIXME: Let archivers figure this out. */ if (!h->funcs->exists(h, fname))
__PHYSFS_setError(ERR_NO_SUCH_FILE); __PHYSFS_setError(ERR_NO_SUCH_FILE);
else else
{ {

View File

@ -35,8 +35,6 @@
const char *__PHYSFS_platformDirSeparator = "/"; const char *__PHYSFS_platformDirSeparator = "/";
#define get_error_str(x) strerror(x)
int __PHYSFS_platformInit(void) int __PHYSFS_platformInit(void)
{ {
@ -82,11 +80,11 @@ static char *getMountPoint(const char *devname)
BPath path; BPath path;
status_t rc; status_t rc;
rc = vol.GetRootDirectory(&directory); rc = vol.GetRootDirectory(&directory);
BAIL_IF_MACRO(rc < B_OK, get_error_str(rc), NULL); BAIL_IF_MACRO(rc < B_OK, strerror(rc), NULL);
rc = directory.GetEntry(&entry); rc = directory.GetEntry(&entry);
BAIL_IF_MACRO(rc < B_OK, get_error_str(rc), NULL); BAIL_IF_MACRO(rc < B_OK, strerror(rc), NULL);
rc = entry.GetPath(&path); rc = entry.GetPath(&path);
BAIL_IF_MACRO(rc < B_OK, get_error_str(rc), NULL); BAIL_IF_MACRO(rc < B_OK, strerror(rc), NULL);
const char *str = path.Path(); const char *str = path.Path();
BAIL_IF_MACRO(str == NULL, ERR_OS_ERROR, NULL); /* ?! */ BAIL_IF_MACRO(str == NULL, ERR_OS_ERROR, NULL); /* ?! */
char *retval = (char *) malloc(strlen(str) + 1); char *retval = (char *) malloc(strlen(str) + 1);
@ -188,7 +186,7 @@ char *__PHYSFS_platformCalcBaseDir(const char *argv0)
BRoster roster; BRoster roster;
app_info info; app_info info;
status_t rc = roster.GetRunningAppInfo(getTeamID(), &info); status_t rc = roster.GetRunningAppInfo(getTeamID(), &info);
BAIL_IF_MACRO(rc < B_OK, get_error_str(rc), NULL); BAIL_IF_MACRO(rc < B_OK, strerror(rc), NULL);
BEntry entry(&(info.ref), true); BEntry entry(&(info.ref), true);
BPath path; BPath path;
rc = entry.GetPath(&path); /* (path) now has binary's path. */ rc = entry.GetPath(&path); /* (path) now has binary's path. */
@ -246,7 +244,7 @@ void *__PHYSFS_platformCreateMutex(void)
if (rc < B_OK) if (rc < B_OK)
{ {
free(retval); free(retval);
BAIL_MACRO(get_error_str(rc), NULL); BAIL_MACRO(strerror(rc), NULL);
} // if } // if
*retval = rc; *retval = rc;
@ -264,7 +262,7 @@ void __PHYSFS_platformDestroyMutex(void *mutex)
int __PHYSFS_platformGrabMutex(void *mutex) int __PHYSFS_platformGrabMutex(void *mutex)
{ {
status_t rc = acquire_sem(*((sem_id *) mutex)); status_t rc = acquire_sem(*((sem_id *) mutex));
BAIL_IF_MACRO(rc < B_OK, get_error_str(rc), 0); BAIL_IF_MACRO(rc < B_OK, strerror(rc), 0);
return(1); return(1);
} /* __PHYSFS_platformGrabMutex */ } /* __PHYSFS_platformGrabMutex */

View File

@ -382,7 +382,7 @@ int __PHYSFS_platformIsSymLink(const char *fname)
/* resolve aliases up to the actual file... */ /* resolve aliases up to the actual file... */
*ptr = '\0'; *ptr = '\0';
BAIL_IF_MACRO(fnameToFSSpec(dir, &spec) != noErr, ERR_OS_ERROR, 0); BAIL_IF_MACRO(fnameToFSSpec(dir, &spec) != noErr, NULL, 0);
*ptr = strlen(ptr + 1); /* ptr is now a pascal string. Yikes! */ *ptr = strlen(ptr + 1); /* ptr is now a pascal string. Yikes! */
memset(&infoPB, '\0', sizeof (CInfoPBRec)); memset(&infoPB, '\0', sizeof (CInfoPBRec));
@ -406,7 +406,7 @@ int __PHYSFS_platformIsDirectory(const char *fname)
CInfoPBRec infoPB; CInfoPBRec infoPB;
OSErr err; OSErr err;
BAIL_IF_MACRO(fnameToFSSpec(fname, &spec) != noErr, ERR_OS_ERROR, 0); BAIL_IF_MACRO(fnameToFSSpec(fname, &spec) != noErr, NULL, 0);
memset(&infoPB, '\0', sizeof (CInfoPBRec)); memset(&infoPB, '\0', sizeof (CInfoPBRec));
infoPB.dirInfo.ioNamePtr = spec.name; /* put name in here. */ infoPB.dirInfo.ioNamePtr = spec.name; /* put name in here. */
infoPB.dirInfo.ioVRefNum = spec.vRefNum; /* ID of file's volume. */ infoPB.dirInfo.ioVRefNum = spec.vRefNum; /* ID of file's volume. */
@ -466,7 +466,7 @@ LinkedStringList *__PHYSFS_platformEnumerateFiles(const char *dirname,
Str255 str255; Str255 str255;
long dirID; long dirID;
BAIL_IF_MACRO(fnameToFSSpec(dirname, &spec) != noErr, ERR_OS_ERROR, 0); BAIL_IF_MACRO(fnameToFSSpec(dirname, &spec) != noErr, NULL, 0);
/* get the dir ID of what we want to enumerate... */ /* get the dir ID of what we want to enumerate... */
memset(&infoPB, '\0', sizeof (CInfoPBRec)); memset(&infoPB, '\0', sizeof (CInfoPBRec));
@ -536,7 +536,7 @@ char *__PHYSFS_platformRealPath(const char *path)
*/ */
FSSpec spec; FSSpec spec;
BAIL_IF_MACRO(fnameToFSSpec(path, &spec) != noErr, ERR_OS_ERROR, NULL); BAIL_IF_MACRO(fnameToFSSpec(path, &spec) != noErr, NULL, NULL);
return(convFSSpecToPath(&spec, 1)); return(convFSSpecToPath(&spec, 1));
} /* __PHYSFS_platformRealPath */ } /* __PHYSFS_platformRealPath */
@ -548,7 +548,7 @@ int __PHYSFS_platformMkDir(const char *path)
OSErr err = fnameToFSSpec(path, &spec); OSErr err = fnameToFSSpec(path, &spec);
BAIL_IF_MACRO(err == noErr, ERR_FILE_EXISTS, 0); BAIL_IF_MACRO(err == noErr, ERR_FILE_EXISTS, 0);
BAIL_IF_MACRO(err != fnfErr, ERR_OS_ERROR, 0); BAIL_IF_MACRO(err != fnfErr, NULL, 0);
err = DirCreate(spec.vRefNum, spec.parID, spec.name, &val); err = DirCreate(spec.vRefNum, spec.parID, spec.name, &val);
BAIL_IF_MACRO(err != noErr, ERR_OS_ERROR, 0); BAIL_IF_MACRO(err != noErr, ERR_OS_ERROR, 0);
@ -562,7 +562,7 @@ static SInt16 *macDoOpen(const char *fname, SInt8 perm, int createIfMissing)
SInt16 *retval = NULL; SInt16 *retval = NULL;
FSSpec spec; FSSpec spec;
OSErr err = fnameToFSSpec(fname, &spec); OSErr err = fnameToFSSpec(fname, &spec);
BAIL_IF_MACRO((err != noErr) && (err != fnfErr), ERR_OS_ERROR, NULL); BAIL_IF_MACRO((err != noErr) && (err != fnfErr), NULL, NULL);
if (err == fnfErr) if (err == fnfErr)
{ {
BAIL_IF_MACRO(!createIfMissing, ERR_NO_SUCH_FILE, NULL); BAIL_IF_MACRO(!createIfMissing, ERR_NO_SUCH_FILE, NULL);
@ -754,7 +754,7 @@ int __PHYSFS_platformDelete(const char *path)
{ {
FSSpec spec; FSSpec spec;
OSErr err; OSErr err;
BAIL_IF_MACRO(fnameToFSSpec(path, &spec) != noErr, ERR_OS_ERROR, 0); BAIL_IF_MACRO(fnameToFSSpec(path, &spec) != noErr, NULL, 0);
err = HDelete(spec.vRefNum, spec.parID, spec.name); err = HDelete(spec.vRefNum, spec.parID, spec.name);
BAIL_IF_MACRO(err != noErr, ERR_OS_ERROR, 0); BAIL_IF_MACRO(err != noErr, ERR_OS_ERROR, 0);
return(1); return(1);
@ -791,7 +791,8 @@ PHYSFS_sint64 __PHYSFS_platformGetLastModTime(const char *fname)
CInfoPBRec infoPB; CInfoPBRec infoPB;
UInt32 modDate; UInt32 modDate;
BAIL_IF_MACRO(fnameToFSSpec(fname, &spec) != noErr, ERR_OS_ERROR, -1); if (fnameToFSSpec(fname, &spec) != noErr)
return(-1); /* fnameToFSSpec() sets physfs error message. */
memset(&infoPB, '\0', sizeof (CInfoPBRec)); memset(&infoPB, '\0', sizeof (CInfoPBRec));
infoPB.dirInfo.ioNamePtr = spec.name; infoPB.dirInfo.ioNamePtr = spec.name;