From f35189266fe581282eff611013a7a9b034da660e Mon Sep 17 00:00:00 2001 From: Bobby Smith <33353403+bslenul@users.noreply.github.com> Date: Fri, 26 Jan 2024 17:22:23 +0100 Subject: [PATCH] Improvements to firmware checks when "System Files are in Content Directory" is enabled --- intl/msg_hash_us.h | 8 ++++++++ menu/menu_displaylist.c | 39 ++++++++++++++++++++++++++++++++++++--- msg_hash.h | 2 ++ runloop.c | 7 ++++++- 4 files changed, 52 insertions(+), 4 deletions(-) diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index e299152890d..59c167352e2 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -527,6 +527,14 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_CORE_INFO_FIRMWARE, "Firmware" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CORE_INFO_FIRMWARE_IN_CONTENT_DIRECTORY, + "(!) Note: 'System Files are in Content Directory' is currently enabled." + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CORE_INFO_FIRMWARE_PATH, + "(!) Looking in: '%s'" + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_MISSING_REQUIRED, "Missing, Required:" diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index ae81c446da0..cf2cd71c723 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -709,11 +709,25 @@ static int menu_displaylist_parse_core_info( if (core_info->firmware_count > 0) { core_info_ctx_firmware_t firmware_info; - bool update_missing_firmware = false; - bool set_missing_firmware = false; + content_state_t *p_content = content_state_get_ptr(); + bool update_missing_firmware = false; + bool set_missing_firmware = false; + bool systemfiles_in_content_dir = settings->bools.systemfiles_in_content_dir; + bool content_is_inited = p_content->flags & CONTENT_ST_FLAG_IS_INITED; firmware_info.path = core_info->path; - firmware_info.directory.system = settings->paths.directory_system; + + /* If 'System Files are in Content Directory' is enabled and content is inited, + * adjust the path to check for firmware files */ + if (systemfiles_in_content_dir && content_is_inited) + { + char tmp_path[PATH_MAX_LENGTH]; + strlcpy(tmp_path, path_get(RARCH_PATH_CONTENT), sizeof(tmp_path)); + path_basedir(tmp_path); + firmware_info.directory.system = tmp_path; + } + else + firmware_info.directory.system = settings->paths.directory_system; update_missing_firmware = core_info_list_update_missing_firmware(&firmware_info, &set_missing_firmware); @@ -740,6 +754,25 @@ static int menu_displaylist_parse_core_info( MENU_ENUM_LABEL_CORE_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, 0, 0, NULL)) count++; + /* If 'System Files are in Content Directory' is enabled, let's add a note about it. */ + if (systemfiles_in_content_dir) + { + len = strlcpy(tmp, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_FIRMWARE_IN_CONTENT_DIRECTORY), + sizeof(tmp)); + if (menu_entries_append(list, tmp, "", + MENU_ENUM_LABEL_CORE_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, 0, 0, NULL)) + count++; + } + + /* Show the path that was checked */ + len = snprintf(tmp, sizeof(tmp), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_FIRMWARE_PATH), + firmware_info.directory.system); + if (menu_entries_append(list, tmp, "", + MENU_ENUM_LABEL_CORE_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, 0, 0, NULL)) + count++; + len = strlcpy(tmp, "(!) ", sizeof(tmp)); /* FIXME: This looks hacky and probably diff --git a/msg_hash.h b/msg_hash.h index 76c3a185b08..b56852f3222 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -3366,6 +3366,8 @@ enum msg_hash_enums MENU_ENUM_LABEL_VALUE_CORE_INFO_LICENSES, MENU_ENUM_LABEL_VALUE_CORE_INFO_SUPPORTED_EXTENSIONS, MENU_ENUM_LABEL_VALUE_CORE_INFO_FIRMWARE, + MENU_ENUM_LABEL_VALUE_CORE_INFO_FIRMWARE_IN_CONTENT_DIRECTORY, + MENU_ENUM_LABEL_VALUE_CORE_INFO_FIRMWARE_PATH, MENU_ENUM_LABEL_VALUE_CORE_INFO_REQUIRED_HW_API, MENU_ENUM_LABEL_VALUE_CORE_INFO_SAVESTATE_SUPPORT_LEVEL, diff --git a/runloop.c b/runloop.c index 5d781aca91d..f4f41a545ca 100644 --- a/runloop.c +++ b/runloop.c @@ -1979,12 +1979,17 @@ bool runloop_environment_cb(unsigned cmd, void *data) strlcpy(tmp_path, fullpath, sizeof(tmp_path)); path_basedir(tmp_path); + + /* Removes trailing slash */ + if (tmp_path[strlen(tmp_path) - 1] == PATH_DEFAULT_SLASH_C()) + tmp_path[strlen(tmp_path) - 1] = '\0'; + dir_set(RARCH_DIR_SYSTEM, tmp_path); } *(const char**)data = dir_get_ptr(RARCH_DIR_SYSTEM); RARCH_LOG("[Environ]: SYSTEM_DIRECTORY: \"%s\".\n", - dir_system); + *(const char**)data); } else {