Skip to content

Commit 3572461

Browse files
authored
Improvements to firmware checks when "System Files are in Content Directory" is enabled (#16170)
1 parent 00d01c8 commit 3572461

4 files changed

Lines changed: 62 additions & 4 deletions

File tree

intl/msg_hash_us.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,14 @@ MSG_HASH(
527527
MENU_ENUM_LABEL_VALUE_CORE_INFO_FIRMWARE,
528528
"Firmware"
529529
)
530+
MSG_HASH(
531+
MENU_ENUM_LABEL_VALUE_CORE_INFO_FIRMWARE_IN_CONTENT_DIRECTORY,
532+
"- Note: 'System Files are in Content Directory' is currently enabled."
533+
)
534+
MSG_HASH(
535+
MENU_ENUM_LABEL_VALUE_CORE_INFO_FIRMWARE_PATH,
536+
"- Looking in: '%s'"
537+
)
530538
MSG_HASH(
531539
MENU_ENUM_LABEL_VALUE_MISSING_REQUIRED,
532540
"Missing, Required:"

menu/menu_displaylist.c

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -709,11 +709,33 @@ static int menu_displaylist_parse_core_info(
709709
if (core_info->firmware_count > 0)
710710
{
711711
core_info_ctx_firmware_t firmware_info;
712-
bool update_missing_firmware = false;
713-
bool set_missing_firmware = false;
712+
uint8_t flags = content_get_flags();
713+
bool update_missing_firmware = false;
714+
bool set_missing_firmware = false;
715+
bool systemfiles_in_content_dir = settings->bools.systemfiles_in_content_dir;
716+
bool content_is_inited = flags & CONTENT_ST_FLAG_IS_INITED;
717+
char tmp_path[PATH_MAX_LENGTH];
714718

715719
firmware_info.path = core_info->path;
716-
firmware_info.directory.system = settings->paths.directory_system;
720+
721+
/* If 'System Files are in Content Directory' is enabled and content is inited,
722+
* adjust the path to check for firmware files */
723+
if (systemfiles_in_content_dir && content_is_inited)
724+
{
725+
size_t len;
726+
727+
strlcpy(tmp_path, path_get(RARCH_PATH_CONTENT), sizeof(tmp_path));
728+
path_basedir(tmp_path);
729+
730+
/* Removes trailing slash, doesn't really matter but it's more consistent with how
731+
* the path is stored and displayed without 'System Files are in Content Directory' */
732+
len = strlen(tmp_path);
733+
if (tmp_path[len - 1] == PATH_DEFAULT_SLASH_C())
734+
tmp_path[len - 1] = '\0';
735+
firmware_info.directory.system = tmp_path;
736+
}
737+
else
738+
firmware_info.directory.system = settings->paths.directory_system;
717739

718740
update_missing_firmware = core_info_list_update_missing_firmware(&firmware_info, &set_missing_firmware);
719741

@@ -740,6 +762,25 @@ static int menu_displaylist_parse_core_info(
740762
MENU_ENUM_LABEL_CORE_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, 0, 0, NULL))
741763
count++;
742764

765+
/* If 'System Files are in Content Directory' is enabled, let's add a note about it. */
766+
if (systemfiles_in_content_dir)
767+
{
768+
len = strlcpy(tmp,
769+
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_FIRMWARE_IN_CONTENT_DIRECTORY),
770+
sizeof(tmp));
771+
if (menu_entries_append(list, tmp, "",
772+
MENU_ENUM_LABEL_CORE_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, 0, 0, NULL))
773+
count++;
774+
}
775+
776+
/* Show the path that was checked */
777+
len = snprintf(tmp, sizeof(tmp),
778+
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_FIRMWARE_PATH),
779+
firmware_info.directory.system);
780+
if (menu_entries_append(list, tmp, "",
781+
MENU_ENUM_LABEL_CORE_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, 0, 0, NULL))
782+
count++;
783+
743784
len = strlcpy(tmp, "(!) ", sizeof(tmp));
744785

745786
/* FIXME: This looks hacky and probably

msg_hash.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3366,6 +3366,8 @@ enum msg_hash_enums
33663366
MENU_ENUM_LABEL_VALUE_CORE_INFO_LICENSES,
33673367
MENU_ENUM_LABEL_VALUE_CORE_INFO_SUPPORTED_EXTENSIONS,
33683368
MENU_ENUM_LABEL_VALUE_CORE_INFO_FIRMWARE,
3369+
MENU_ENUM_LABEL_VALUE_CORE_INFO_FIRMWARE_IN_CONTENT_DIRECTORY,
3370+
MENU_ENUM_LABEL_VALUE_CORE_INFO_FIRMWARE_PATH,
33693371
MENU_ENUM_LABEL_VALUE_CORE_INFO_REQUIRED_HW_API,
33703372

33713373
MENU_ENUM_LABEL_VALUE_CORE_INFO_SAVESTATE_SUPPORT_LEVEL,

runloop.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1971,6 +1971,7 @@ bool runloop_environment_cb(unsigned cmd, void *data)
19711971

19721972
if (!string_is_empty(fullpath))
19731973
{
1974+
size_t len;
19741975
char tmp_path[PATH_MAX_LENGTH];
19751976

19761977
if (string_is_empty(dir_system))
@@ -1979,12 +1980,18 @@ bool runloop_environment_cb(unsigned cmd, void *data)
19791980

19801981
strlcpy(tmp_path, fullpath, sizeof(tmp_path));
19811982
path_basedir(tmp_path);
1983+
1984+
/* Removes trailing slash */
1985+
len = strlen(tmp_path);
1986+
if (tmp_path[len - 1] == PATH_DEFAULT_SLASH_C())
1987+
tmp_path[len - 1] = '\0';
1988+
19821989
dir_set(RARCH_DIR_SYSTEM, tmp_path);
19831990
}
19841991

19851992
*(const char**)data = dir_get_ptr(RARCH_DIR_SYSTEM);
19861993
RARCH_LOG("[Environ]: SYSTEM_DIRECTORY: \"%s\".\n",
1987-
dir_system);
1994+
*(const char**)data);
19881995
}
19891996
else
19901997
{

0 commit comments

Comments
 (0)