src/filesystem/unix/SDL_sysfilesystem.c
changeset 7715 24f652e130fa
parent 7714 1c227c5f5d8d
child 7717 0f48be750bba
equal deleted inserted replaced
7714:1c227c5f5d8d 7715:24f652e130fa
    23 #ifdef SDL_FILESYSTEM_UNIX
    23 #ifdef SDL_FILESYSTEM_UNIX
    24 
    24 
    25 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
    25 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
    26 /* System dependent filesystem routines                                */
    26 /* System dependent filesystem routines                                */
    27 
    27 
       
    28 #include <errno.h>
       
    29 #include <stdio.h>
    28 #include <unistd.h>
    30 #include <unistd.h>
    29 #include <stdlib.h>
    31 #include <stdlib.h>
    30 #include <sys/stat.h>
    32 #include <sys/stat.h>
    31 #include <sys/types.h>
    33 #include <sys/types.h>
    32 #include <limits.h>
    34 #include <limits.h>
   188     SDL_snprintf(retval, len, "%s%s%s/", envr, append, app);
   190     SDL_snprintf(retval, len, "%s%s%s/", envr, append, app);
   189 
   191 
   190     for (ptr = retval+1; *ptr; ptr++) {
   192     for (ptr = retval+1; *ptr; ptr++) {
   191         if (*ptr == '/') {
   193         if (*ptr == '/') {
   192             *ptr = '\0';
   194             *ptr = '\0';
   193             mkdir(retval, 0700);
   195             if (mkdir(retval, 0700) != 0 && errno != EEXIST)
       
   196                 goto error;
   194             *ptr = '/';
   197             *ptr = '/';
   195         }
   198         }
   196     }
   199     }
   197     mkdir(retval, 0700);
   200     if (mkdir(retval, 0700) != 0 && errno != EEXIST) {
       
   201 error:
       
   202         SDL_SetError("Couldn't create directory '%s': ", retval, strerror(errno));
       
   203         SDL_free(retval);
       
   204         return NULL;
       
   205     }
   198 
   206 
   199     return retval;
   207     return retval;
   200 }
   208 }
   201 
   209 
   202 #endif /* SDL_FILESYSTEM_UNIX */
   210 #endif /* SDL_FILESYSTEM_UNIX */