Fall back to global system dir if content path is empty when 'System Files are in Content Directory' is enabled (#16175)

This commit is contained in:
Bobby Smith 2024-02-01 18:42:05 +01:00 committed by GitHub
parent 633dad5d6b
commit 9e6b790f19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 9 deletions

View File

@ -727,12 +727,22 @@ static int menu_displaylist_parse_core_info(
strlcpy(tmp_path, path_get(RARCH_PATH_CONTENT), sizeof(tmp_path));
path_basedir(tmp_path);
/* Removes trailing slash, doesn't really matter but it's more consistent with how
* the path is stored and displayed without 'System Files are in Content Directory' */
len = strlen(tmp_path);
if (tmp_path[len - 1] == PATH_DEFAULT_SLASH_C())
tmp_path[len - 1] = '\0';
firmware_info.directory.system = tmp_path;
/* If content path is empty, fall back to global system dir path */
if (string_is_empty(tmp_path))
firmware_info.directory.system = settings->paths.directory_system;
else
{
size_t len = strlen(tmp_path);
/* Removes trailing slash (unless root dir), doesn't really matter
* but it's more consistent with how the path is stored and
* displayed without 'System Files are in Content Directory' */
if ( string_count_occurrences_single_character(tmp_path, PATH_DEFAULT_SLASH_C()) > 1
&& tmp_path[len - 1] == PATH_DEFAULT_SLASH_C())
tmp_path[len - 1] = '\0';
firmware_info.directory.system = tmp_path;
}
}
else
firmware_info.directory.system = settings->paths.directory_system;

View File

@ -1981,15 +1981,18 @@ bool runloop_environment_cb(unsigned cmd, void *data)
strlcpy(tmp_path, fullpath, sizeof(tmp_path));
path_basedir(tmp_path);
/* Removes trailing slash */
/* Removes trailing slash (unless root dir) */
len = strlen(tmp_path);
if (tmp_path[len - 1] == PATH_DEFAULT_SLASH_C())
if ( string_count_occurrences_single_character(tmp_path, PATH_DEFAULT_SLASH_C()) > 1
&& tmp_path[len - 1] == PATH_DEFAULT_SLASH_C())
tmp_path[len - 1] = '\0';
dir_set(RARCH_DIR_SYSTEM, tmp_path);
*(const char**)data = dir_get_ptr(RARCH_DIR_SYSTEM);
}
else /* If content path is empty, fall back to global system dir path */
*(const char**)data = dir_system;
*(const char**)data = dir_get_ptr(RARCH_DIR_SYSTEM);
RARCH_LOG("[Environ]: SYSTEM_DIRECTORY: \"%s\".\n",
*(const char**)data);
}