src/filesystem/unix/SDL_sysfilesystem.c
changeset 7715 24f652e130fa
parent 7714 1c227c5f5d8d
child 7717 0f48be750bba
--- a/src/filesystem/unix/SDL_sysfilesystem.c	Thu Aug 29 08:25:24 2013 -0700
+++ b/src/filesystem/unix/SDL_sysfilesystem.c	Thu Aug 29 08:25:54 2013 -0700
@@ -25,6 +25,8 @@
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 /* System dependent filesystem routines                                */
 
+#include <errno.h>
+#include <stdio.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <sys/stat.h>
@@ -190,11 +192,17 @@
     for (ptr = retval+1; *ptr; ptr++) {
         if (*ptr == '/') {
             *ptr = '\0';
-            mkdir(retval, 0700);
+            if (mkdir(retval, 0700) != 0 && errno != EEXIST)
+                goto error;
             *ptr = '/';
         }
     }
-    mkdir(retval, 0700);
+    if (mkdir(retval, 0700) != 0 && errno != EEXIST) {
+error:
+        SDL_SetError("Couldn't create directory '%s': ", retval, strerror(errno));
+        SDL_free(retval);
+        return NULL;
+    }
 
     return retval;
 }