diff --git a/frontend/frontend.c b/frontend/frontend.c index c6bc35299e..88b7e3db15 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -55,15 +55,7 @@ int main(int argc, char *argv[]) // If we started a ROM directly from command line, // push it to ROM history. if (!g_extern.libretro_dummy) - { - // g_extern.fullpath can be relative here. - if (*g_extern.fullpath) - path_resolve_realpath(g_extern.fullpath, sizeof(g_extern.fullpath)); - - menu_rom_history_push(*g_extern.fullpath ? g_extern.fullpath : NULL, - g_settings.libretro, - g_extern.system.info.library_name); - } + menu_rom_history_push_current(); for (;;) { diff --git a/frontend/menu/menu_common.c b/frontend/menu/menu_common.c index 84ca48a36b..3c4bda8332 100644 --- a/frontend/menu/menu_common.c +++ b/frontend/menu/menu_common.c @@ -371,6 +371,21 @@ void menu_rom_history_push(const char *path, rom_history_push(rgui->history, path, core_path, core_name); } +void menu_rom_history_push_current(void) +{ + // g_extern.fullpath can be relative here. + // Ensure we're pushing absolute path. + + char tmp[PATH_MAX]; + strlcpy(tmp, g_extern.fullpath, sizeof(tmp)); + if (*tmp) + path_resolve_realpath(tmp, sizeof(tmp)); + + menu_rom_history_push(*tmp ? tmp : NULL, + g_settings.libretro, + g_extern.system.info.library_name); +} + void load_menu_game_prepare(void) { if (*g_extern.fullpath || rgui->load_no_rom) diff --git a/frontend/menu/menu_common.h b/frontend/menu/menu_common.h index 123329874d..6d72f4e721 100644 --- a/frontend/menu/menu_common.h +++ b/frontend/menu/menu_common.h @@ -284,6 +284,7 @@ bool load_menu_game(void); void load_menu_game_history(unsigned game_index); void menu_rom_history_push(const char *path, const char *core_path, const char *core_name); +void menu_rom_history_push_current(void); #ifdef __cplusplus }