Christoph Mallon: Report an error, if creating the directories in SDL_GetPrefPath() failed.
authorSam Lantinga <slouken@libsdl.org>
Thu, 29 Aug 2013 08:25:54 -0700
changeset 771524f652e130fa
parent 7714 1c227c5f5d8d
child 7716 be4cda94bce2
Christoph Mallon: Report an error, if creating the directories in SDL_GetPrefPath() failed.
src/filesystem/unix/SDL_sysfilesystem.c
     1.1 --- a/src/filesystem/unix/SDL_sysfilesystem.c	Thu Aug 29 08:25:24 2013 -0700
     1.2 +++ b/src/filesystem/unix/SDL_sysfilesystem.c	Thu Aug 29 08:25:54 2013 -0700
     1.3 @@ -25,6 +25,8 @@
     1.4  /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
     1.5  /* System dependent filesystem routines                                */
     1.6  
     1.7 +#include <errno.h>
     1.8 +#include <stdio.h>
     1.9  #include <unistd.h>
    1.10  #include <stdlib.h>
    1.11  #include <sys/stat.h>
    1.12 @@ -190,11 +192,17 @@
    1.13      for (ptr = retval+1; *ptr; ptr++) {
    1.14          if (*ptr == '/') {
    1.15              *ptr = '\0';
    1.16 -            mkdir(retval, 0700);
    1.17 +            if (mkdir(retval, 0700) != 0 && errno != EEXIST)
    1.18 +                goto error;
    1.19              *ptr = '/';
    1.20          }
    1.21      }
    1.22 -    mkdir(retval, 0700);
    1.23 +    if (mkdir(retval, 0700) != 0 && errno != EEXIST) {
    1.24 +error:
    1.25 +        SDL_SetError("Couldn't create directory '%s': ", retval, strerror(errno));
    1.26 +        SDL_free(retval);
    1.27 +        return NULL;
    1.28 +    }
    1.29  
    1.30      return retval;
    1.31  }