1
0
mirror of https://github.com/libretro/RetroArch synced 2025-02-26 15:39:55 +00:00

Merge pull request from jdgleaver/gekko-mkdir

Fix directory creation on GEKKO platforms when path contains a trailing slash
This commit is contained in:
Autechre 2020-10-05 14:19:37 +02:00 committed by GitHub
commit b55e3d5bff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 14 deletions

@ -197,20 +197,6 @@ bool path_mkdir(const char *dir)
return false;
}
#if defined(GEKKO)
{
size_t len = strlen(basedir);
/* path_parent_dir() keeps the trailing slash.
* On Wii, mkdir() fails if the path has a
* trailing slash...
* We must therefore remove it. */
if (len > 0)
if (basedir[len - 1] == '/')
basedir[len - 1] = '\0';
}
#endif
if (path_is_directory(basedir))
norecurse = true;
else

@ -1024,6 +1024,28 @@ int retro_vfs_mkdir_impl(const char *dir)
int ret = orbisMkdir(dir, 0755);
#elif defined(__QNX__)
int ret = mkdir(dir, 0777);
#elif defined(GEKKO)
/* On GEKKO platforms, mkdir() fails if
* the path has a trailing slash. We must
* therefore remove it. */
int ret = -1;
if (!string_is_empty(dir))
{
char *dir_buf = strdup(dir);
if (dir_buf)
{
size_t len = strlen(dir_buf);
if (len > 0)
if (dir_buf[len - 1] == '/')
dir_buf[len - 1] = '\0';
ret = mkdir(dir_buf, 0750);
free(dir_buf);
}
}
#else
int ret = mkdir(dir, 0750);
#endif