1
0
mirror of https://github.com/libretro/RetroArch synced 2024-07-08 12:15:49 +00:00

Fix incorrect file names for remap files when the content path doesn't have a preceding slash. (#13385)

This commit is contained in:
Manuel Alfayate Corchete 2021-12-20 22:24:19 +00:00 committed by GitHub
parent 77e202fbf7
commit e5215d9e29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -407,15 +407,29 @@ bool fill_pathname_parent_dir_name(char *out_dir,
last = find_last_slash(temp);
}
/* Cut the last part of the string (the filename) after the slash,
leaving the directory name (or nested directory names) only. */
if (last)
*last = '\0';
/* Point in_dir to the address of the last slash. */
in_dir = find_last_slash(temp);
/* If find_last_slash returns NULL, it means there was no slash in temp,
so use temp as-is. */
if (!in_dir)
in_dir = temp;
success = in_dir && in_dir[1];
if (success)
strlcpy(out_dir, in_dir + 1, size);
{
/* If path starts with an slash, eliminate it. */
if (path_is_absolute(in_dir))
strlcpy(out_dir, in_dir + 1, size);
else
strlcpy(out_dir, in_dir, size);
}
free(temp);
return success;