Skip to content

Commit

Permalink
Christoph Mallon: Report an error, if creating the directories in SDL…
Browse files Browse the repository at this point in the history
…_GetPrefPath() failed.
  • Loading branch information
slouken committed Aug 29, 2013
1 parent db7c92b commit 67c1016
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/filesystem/unix/SDL_sysfilesystem.c
Expand Up @@ -25,6 +25,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* System dependent filesystem routines */

#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/stat.h>
Expand Down Expand Up @@ -190,11 +192,17 @@ SDL_GetPrefPath(const char *org, const char *app)
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;
}
Expand Down

0 comments on commit 67c1016

Please sign in to comment.