Merge commit '7d7c5b803cecdb87673b824103e4c1c0b3e29fac' into main
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
diff --git a/src/filesystem/ps2/SDL_sysfilesystem.c b/src/filesystem/ps2/SDL_sysfilesystem.c
index 191c962..21c24b6 100644
--- a/src/filesystem/ps2/SDL_sysfilesystem.c
+++ b/src/filesystem/ps2/SDL_sysfilesystem.c
@@ -47,6 +47,33 @@ SDL_GetBasePath(void)
return retval;
}
+/* Do a recursive mkdir of parents folders */
+static void recursive_mkdir(const char *dir) {
+ char tmp[FILENAME_MAX];
+ char *base = SDL_GetBasePath();
+ char *p = NULL;
+ size_t len;
+
+ snprintf(tmp, sizeof(tmp),"%s",dir);
+ len = strlen(tmp);
+ if (tmp[len - 1] == '/')
+ tmp[len - 1] = 0;
+
+ for (p = tmp + 1; *p; p++) {
+ if (*p == '/') {
+ *p = 0;
+ // Just creating subfolders from current path
+ if (strstr(tmp, base) != NULL)
+ mkdir(tmp, S_IRWXU);
+
+ *p = '/';
+ }
+ }
+
+ free(base);
+ mkdir(tmp, S_IRWXU);
+}
+
char *
SDL_GetPrefPath(const char *org, const char *app)
{
@@ -71,7 +98,7 @@ SDL_GetPrefPath(const char *org, const char *app)
}
free(base);
- mkdir(retval, 0x0755);
+ recursive_mkdir(retval);
return retval;
}