Reports trouble setting the write dir in PHYSFS_setSaneConfig().
authorRyan C. Gordon <icculus@icculus.org>
Fri, 15 Mar 2002 14:53:23 +0000
changeset 122 402ee2bf165c
parent 121 86deec2e27d9
child 123 53305c50c541
Reports trouble setting the write dir in PHYSFS_setSaneConfig().
physfs.c
--- a/physfs.c	Fri Mar 15 14:52:57 2002 +0000
+++ b/physfs.c	Fri Mar 15 14:53:23 2002 +0000
@@ -652,17 +652,26 @@
 
     if (!PHYSFS_setWriteDir(str))
     {
+        int no_write = 0;
+        sprintf(str, ".%s/%s", organization, appName);
         if ( (PHYSFS_setWriteDir(userdir)) &&
-             (PHYSFS_mkdir(str + strlen(userdir))) )
+             (PHYSFS_mkdir(str)) )
         {
-            PHYSFS_setWriteDir(str);
+            sprintf(str, "%s.%s%s%s", userdir, organization, dirsep, appName);
+            if (!PHYSFS_setWriteDir(str))
+                no_write = 1;
         } /* if */
         else
         {
-            PHYSFS_setWriteDir(NULL);
+                no_write = 1;
+        } /* else */
+
+        if (no_write)
+        {
+            PHYSFS_setWriteDir(NULL);   /* just in case. */
             free(str);
-            BAIL_IF_MACRO(1, ERR_CANT_SET_WRITE_DIR, 0);
-        } /* else */
+            BAIL_MACRO(ERR_CANT_SET_WRITE_DIR, 0);
+        } /* if */
     } /* if */
 
     /* Put write dir first in search path... */