Skip to content

Commit

Permalink
Improvements to firmware checks when "System Files are in Content Dir…
Browse files Browse the repository at this point in the history
…ectory" is enabled
  • Loading branch information
bslenul committed Jan 26, 2024
1 parent 4c69431 commit f351892
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 4 deletions.
8 changes: 8 additions & 0 deletions intl/msg_hash_us.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:"
Expand Down
39 changes: 36 additions & 3 deletions menu/menu_displaylist.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions msg_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion runloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit f351892

Please sign in to comment.