mirror of
https://github.com/libsdl-org/SDL.git
synced 2024-11-23 19:03:27 +08:00
emscripten: Create directory recursively in GetPrefPath
This commit is contained in:
parent
fa367cdd5c
commit
1a48ca666f
@ -44,6 +44,7 @@ SDL_GetPrefPath(const char *org, const char *app)
|
|||||||
{
|
{
|
||||||
const char *append = "/libsdl/";
|
const char *append = "/libsdl/";
|
||||||
char *retval;
|
char *retval;
|
||||||
|
char *ptr = NULL;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
|
|
||||||
if (!app) {
|
if (!app) {
|
||||||
@ -67,7 +68,17 @@ SDL_GetPrefPath(const char *org, const char *app)
|
|||||||
SDL_snprintf(retval, len, "%s%s/", append, app);
|
SDL_snprintf(retval, len, "%s%s/", append, app);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (ptr = retval+1; *ptr; ptr++) {
|
||||||
|
if (*ptr == '/') {
|
||||||
|
*ptr = '\0';
|
||||||
|
if (mkdir(retval, 0700) != 0 && errno != EEXIST)
|
||||||
|
goto error;
|
||||||
|
*ptr = '/';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (mkdir(retval, 0700) != 0 && errno != EEXIST) {
|
if (mkdir(retval, 0700) != 0 && errno != EEXIST) {
|
||||||
|
error:
|
||||||
SDL_SetError("Couldn't create directory '%s': '%s'", retval, strerror(errno));
|
SDL_SetError("Couldn't create directory '%s': '%s'", retval, strerror(errno));
|
||||||
SDL_free(retval);
|
SDL_free(retval);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user