PHYSFS_setSaneConfig() fixes: set write dir correctly, and put it at start
authorRyan C. Gordon <icculus@icculus.org>
Wed, 26 Sep 2001 03:08:57 +0000
changeset 103 cb5f60383994
parent 102 58538e10e93c
child 104 01f40ec3c62f
PHYSFS_setSaneConfig() fixes: set write dir correctly, and put it at start of search path.
physfs.c
--- a/physfs.c	Wed Sep 26 01:45:37 2001 +0000
+++ b/physfs.c	Wed Sep 26 03:08:57 2001 +0000
@@ -652,17 +652,21 @@
 
     if (!PHYSFS_setWriteDir(str))
     {
-        if ( (!PHYSFS_setWriteDir(userdir)) ||
-             (!PHYSFS_mkdir(str + strlen(userdir))) )
+        if ( (PHYSFS_setWriteDir(userdir)) &&
+             (PHYSFS_mkdir(str + strlen(userdir))) )
+        {
+            PHYSFS_setWriteDir(str);
+        } /* if */
+        else
         {
             PHYSFS_setWriteDir(NULL);
             free(str);
             BAIL_IF_MACRO(1, ERR_CANT_SET_WRITE_DIR, 0);
-        } /* if */
+        } /* else */
     } /* if */
 
-        /* Put write dir related dirs on search path... */
-    PHYSFS_addToSearchPath(str, 1);
+    /* Put write dir first in search path... */
+    PHYSFS_addToSearchPath(str, 0);
     free(str);
 
         /* Put base path on search path... */