Minor cleanups.
This commit is contained in:
parent
2b0cecee7c
commit
69859a7bd9
|
@ -501,6 +501,10 @@ static int GRP_isSymLink(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. */
|
||||
return(((GRPinfo *) h->opaque)->last_mod_time);
|
||||
} /* GRP_getLastModTime */
|
||||
|
|
2
physfs.c
2
physfs.c
|
@ -1210,7 +1210,7 @@ int PHYSFS_isDirectory(const char *fname)
|
|||
DirHandle *h = i->dirHandle;
|
||||
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);
|
||||
else
|
||||
{
|
||||
|
|
|
@ -35,8 +35,6 @@
|
|||
|
||||
const char *__PHYSFS_platformDirSeparator = "/";
|
||||
|
||||
#define get_error_str(x) strerror(x)
|
||||
|
||||
|
||||
int __PHYSFS_platformInit(void)
|
||||
{
|
||||
|
@ -82,11 +80,11 @@ static char *getMountPoint(const char *devname)
|
|||
BPath path;
|
||||
status_t rc;
|
||||
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);
|
||||
BAIL_IF_MACRO(rc < B_OK, get_error_str(rc), NULL);
|
||||
BAIL_IF_MACRO(rc < B_OK, strerror(rc), NULL);
|
||||
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();
|
||||
BAIL_IF_MACRO(str == NULL, ERR_OS_ERROR, NULL); /* ?! */
|
||||
char *retval = (char *) malloc(strlen(str) + 1);
|
||||
|
@ -188,7 +186,7 @@ char *__PHYSFS_platformCalcBaseDir(const char *argv0)
|
|||
BRoster roster;
|
||||
app_info 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);
|
||||
BPath path;
|
||||
rc = entry.GetPath(&path); /* (path) now has binary's path. */
|
||||
|
@ -246,7 +244,7 @@ void *__PHYSFS_platformCreateMutex(void)
|
|||
if (rc < B_OK)
|
||||
{
|
||||
free(retval);
|
||||
BAIL_MACRO(get_error_str(rc), NULL);
|
||||
BAIL_MACRO(strerror(rc), NULL);
|
||||
} // if
|
||||
|
||||
*retval = rc;
|
||||
|
@ -264,7 +262,7 @@ void __PHYSFS_platformDestroyMutex(void *mutex)
|
|||
int __PHYSFS_platformGrabMutex(void *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);
|
||||
} /* __PHYSFS_platformGrabMutex */
|
||||
|
||||
|
|
|
@ -382,7 +382,7 @@ int __PHYSFS_platformIsSymLink(const char *fname)
|
|||
|
||||
/* resolve aliases up to the actual file... */
|
||||
*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! */
|
||||
memset(&infoPB, '\0', sizeof (CInfoPBRec));
|
||||
|
@ -406,7 +406,7 @@ int __PHYSFS_platformIsDirectory(const char *fname)
|
|||
CInfoPBRec infoPB;
|
||||
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));
|
||||
infoPB.dirInfo.ioNamePtr = spec.name; /* put name in here. */
|
||||
infoPB.dirInfo.ioVRefNum = spec.vRefNum; /* ID of file's volume. */
|
||||
|
@ -466,7 +466,7 @@ LinkedStringList *__PHYSFS_platformEnumerateFiles(const char *dirname,
|
|||
Str255 str255;
|
||||
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... */
|
||||
memset(&infoPB, '\0', sizeof (CInfoPBRec));
|
||||
|
@ -536,7 +536,7 @@ char *__PHYSFS_platformRealPath(const char *path)
|
|||
*/
|
||||
|
||||
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));
|
||||
} /* __PHYSFS_platformRealPath */
|
||||
|
||||
|
@ -548,7 +548,7 @@ int __PHYSFS_platformMkDir(const char *path)
|
|||
OSErr err = fnameToFSSpec(path, &spec);
|
||||
|
||||
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);
|
||||
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;
|
||||
FSSpec 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)
|
||||
{
|
||||
BAIL_IF_MACRO(!createIfMissing, ERR_NO_SUCH_FILE, NULL);
|
||||
|
@ -734,7 +734,7 @@ int __PHYSFS_platformClose(void *opaque)
|
|||
HParamBlockRec hpbr;
|
||||
Str63 volName;
|
||||
|
||||
BAIL_IF_MACRO(GetVRefNum (ref, &vRefNum) != noErr, ERR_OS_ERROR, 0);
|
||||
BAIL_IF_MACRO(GetVRefNum(ref, &vRefNum) != noErr, ERR_OS_ERROR, 0);
|
||||
|
||||
memset(&hpbr, '\0', sizeof (HParamBlockRec));
|
||||
hpbr.volumeParam.ioNamePtr = volName;
|
||||
|
@ -754,7 +754,7 @@ int __PHYSFS_platformDelete(const char *path)
|
|||
{
|
||||
FSSpec spec;
|
||||
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);
|
||||
BAIL_IF_MACRO(err != noErr, ERR_OS_ERROR, 0);
|
||||
return(1);
|
||||
|
@ -791,7 +791,8 @@ PHYSFS_sint64 __PHYSFS_platformGetLastModTime(const char *fname)
|
|||
CInfoPBRec infoPB;
|
||||
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));
|
||||
infoPB.dirInfo.ioNamePtr = spec.name;
|
||||
|
|
Loading…
Reference in New Issue