A couple of fixes.
authorRyan C. Gordon <icculus@icculus.org>
Wed, 18 May 2005 20:38:57 +0000
changeset 93 443f73ca45e2
parent 92 879a145aa111
child 94 71a8144a4f73
A couple of fixes.
mojopatch.c
platform_unix.c
--- a/mojopatch.c	Wed May 18 20:22:30 2005 +0000
+++ b/mojopatch.c	Wed May 18 20:38:57 2005 +0000
@@ -617,7 +617,7 @@
     if (*allowed_ver == '\0')  /* No specified version? Anything is okay. */
         return ISPATCHABLE_YES;
 
-    if (strcmp(allowed_ver, newver) == 0)  /* all patched up? */
+    if (strcmp(ver, newver) == 0)  /* all patched up? */
         return ISPATCHABLE_MATCHES;
 
     buf = (char *) alloca(strlen(allowed_ver) + 1);
@@ -2164,18 +2164,30 @@
     char cwd[MAX_PATH];
 
     if (getcwd(cwd, sizeof (cwd)) == NULL)
+    {
+        _fatal("Couldn't determine current working directory!");
         return(0);
+    } /* if */
 
     if (patchfiledir != NULL)
     {
         if (chdir(patchfiledir) == -1)
+        {
+            _fatal("Failed to change directory to \"%s\".", patchfiledir);
             return(0);
+        } /* if */
     } /* if */
 
     rc = spawn_script(name, cwd);
 
-    if (chdir(cwd) == -1)
-        return(0);
+    if (patchfiledir != NULL)
+    {
+        if (chdir(cwd) == -1)
+        {
+            _fatal("Failed to change directory to \"%s\".", cwd);
+            return(0);
+        } /* if */
+    } /* if */
 
     if (rc == SPAWN_FILENOTFOUND)
         return(1);  /* "success" */
@@ -2351,7 +2363,7 @@
     if (!info_only())
     {
         if (installed_patches == 0)
-            _fatal("Your installation has not been modified.");
+            _fatal("No patches were applied to your installation.");
         else if (!quietonsuccess)
             ui_success("Patching successful!");
     } /* if */
--- a/platform_unix.c	Wed May 18 20:22:30 2005 +0000
+++ b/platform_unix.c	Wed May 18 20:38:57 2005 +0000
@@ -366,18 +366,19 @@
     CFRelease(id);
     if (rc == noErr)
     {
-        Boolean b = CFURLGetFileSystemRepresentation(url, TRUE, buf, bufsize);
+        int b = (int) CFURLGetFileSystemRepresentation(url, TRUE, buf, bufsize);
+        if (b) b = 1;
         CFRelease(url);
-        if (1) //((b) && (strstr(buf, "/.Trash/")))
+        if ((b) && (strstr(buf, "/.Trash/")))
         {
             _fatal("It looks like your installation is in the Trash can."
                     " Please take it out of the trash first."
                     " If this is an old installation, please empty your"
                     " trash so we find the right one.");
-            b = 0;
+            b = -1;
         } /* if */
 
-        return(b != 0);
+        return(b);
     } /* if */
 
     return(0);
@@ -520,13 +521,20 @@
 
 SpawnResult spawn_xdelta(const char *cmdline)
 {
+    SpawnResult retval;
     const char *binname = "xdelta";
     char *cmd = alloca(strlen(cmdline) + strlen(basedir) + strlen(binname) + 5);
     if (!cmd)
         return(SPAWN_FAILED);
 
     sprintf(cmd, "\"%s/%s\" %s", basedir, binname, cmdline);
-    return(spawn_binary(cmd));
+    retval = spawn_binary(cmd);
+
+    /* !!! FIXME: xdelta returns an unexpected value when making a delta. */
+    /* !!! FIXME:  (we check the md5sums from all output anyhow. */
+    if (retval == SPAWN_RETURNBAD) retval = SPAWN_RETURNGOOD;
+
+    return(retval);
 } /* spawn_xdelta */