diff --git a/menu/menu_entries_cbs_ok.c b/menu/menu_entries_cbs_ok.c index 63bea8e3a2..c71ff28bc2 100644 --- a/menu/menu_entries_cbs_ok.c +++ b/menu/menu_entries_cbs_ok.c @@ -18,6 +18,7 @@ #include "menu_display.h" #include "menu_entries_cbs.h" #include "menu_setting.h" +#include "menu_entry.h" #include "menu_shader.h" #include "menu_navigation.h" @@ -786,29 +787,7 @@ static int action_ok_remap_file_save_game(const char *path, static int action_ok_path_use_directory(const char *path, const char *label, unsigned type, size_t idx) { - const char *menu_label = NULL; - const char *menu_path = NULL; - rarch_setting_t *setting = NULL; - menu_handle_t *menu = menu_driver_get_ptr(); - if (!menu) - return -1; - - menu_list_get_last_stack(menu->menu_list, - &menu_path, &menu_label, NULL); - - setting = menu_setting_find(menu_label); - - if (!setting) - return -1; - - if (setting->type != ST_DIR) - return -1; - - strlcpy(setting->value.string, menu_path, setting->size); - menu_setting_generic(setting); - menu_list_pop_stack_by_needle(menu->menu_list, setting->name); - - return 0; + return menu_entry_pathdir_set_value(0, NULL); } static int action_ok_core_deferred_set(const char *path, diff --git a/menu/menu_entry.c b/menu/menu_entry.c index ab597b0566..2ed2ce1eb1 100644 --- a/menu/menu_entry.c +++ b/menu/menu_entry.c @@ -301,10 +301,32 @@ void menu_entry_pathdir_get_value(uint32_t i, char *s, size_t len) strlcpy(s, entry.value, len); } -void menu_entry_pathdir_set_value(uint32_t i, const char *s) +int menu_entry_pathdir_set_value(uint32_t i, const char *s) { - rarch_setting_t *setting = menu_entry_get_setting(i); - setting_set_with_string_representation(setting, s); + const char *menu_label = NULL; + const char *menu_path = NULL; + rarch_setting_t *setting = NULL; + menu_list_t *menu_list = menu_list_get_ptr(); + + menu_list_get_last_stack(menu_list, + &menu_path, &menu_label, NULL); + + setting = menu_setting_find(menu_label); + + if (!setting) + return -1; + + if (setting->type != ST_DIR) + return -1; + + (void)s; + + strlcpy(setting->value.string, menu_path, setting->size); + menu_setting_generic(setting); + + menu_list_pop_stack_by_needle(menu_list, setting->name); + + return 0; } void menu_entry_pathdir_extensions(uint32_t i, char *s, size_t len) diff --git a/menu/menu_entry.h b/menu/menu_entry.h index 0122afc1ae..ae765848be 100644 --- a/menu/menu_entry.h +++ b/menu/menu_entry.h @@ -95,7 +95,7 @@ uint32_t menu_entry_pathdir_for_directory(uint32_t i); void menu_entry_pathdir_get_value(uint32_t i, char *s, size_t len); -void menu_entry_pathdir_set_value(uint32_t i, const char *s); +int menu_entry_pathdir_set_value(uint32_t i, const char *s); void menu_entry_pathdir_extensions(uint32_t i, char *s, size_t len);