From 67c10169ee21b4a60129475c44a6d0248e02161b Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 29 Aug 2013 08:25:54 -0700 Subject: [PATCH] Christoph Mallon: Report an error, if creating the directories in SDL_GetPrefPath() failed. --- src/filesystem/unix/SDL_sysfilesystem.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/filesystem/unix/SDL_sysfilesystem.c b/src/filesystem/unix/SDL_sysfilesystem.c index 3be5eb7621fb7..f5517b8fbd2d5 100644 --- a/src/filesystem/unix/SDL_sysfilesystem.c +++ b/src/filesystem/unix/SDL_sysfilesystem.c @@ -25,6 +25,8 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* System dependent filesystem routines */ +#include +#include #include #include #include @@ -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; }