Minor cleanups.
authorRyan C. Gordon <icculus@icculus.org>
Thu, 25 Jul 2002 21:52:07 +0000
changeset 393 468f75bf4d7d
parent 392 bcc8e4dca868
child 394 22dfc50a0b64
Minor cleanups.
archivers/grp.c
physfs.c
platform/beos.cpp
platform/macclassic.c
--- a/archivers/grp.c	Thu Jul 25 17:42:21 2002 +0000
+++ b/archivers/grp.c	Thu Jul 25 21:52:07 2002 +0000
@@ -501,6 +501,10 @@
 
 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 */
--- a/physfs.c	Thu Jul 25 17:42:21 2002 +0000
+++ b/physfs.c	Thu Jul 25 21:52:07 2002 +0000
@@ -1210,7 +1210,7 @@
         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
             {
--- a/platform/beos.cpp	Thu Jul 25 17:42:21 2002 +0000
+++ b/platform/beos.cpp	Thu Jul 25 21:52:07 2002 +0000
@@ -35,8 +35,6 @@
 
 const char *__PHYSFS_platformDirSeparator = "/";
 
-#define get_error_str(x) strerror(x)
-
 
 int __PHYSFS_platformInit(void)
 {
@@ -82,11 +80,11 @@
             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 @@
     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 @@
     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 @@
 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 */
 
--- a/platform/macclassic.c	Thu Jul 25 17:42:21 2002 +0000
+++ b/platform/macclassic.c	Thu Jul 25 21:52:07 2002 +0000
@@ -382,7 +382,7 @@
 
     /* 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 @@
     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 @@
     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 @@
      */
 
     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 @@
     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 @@
     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 @@
     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 @@
 {
     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 @@
     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;