From d706c9c5bf009cffbcc822ba2386e88f0701b566 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Mon, 11 Jul 2022 19:56:46 +0200 Subject: [PATCH] Start deprecating trivial functions in file_path.c --- cheat_manager.c | 9 ++-- configuration.c | 27 +++++----- core_updater_list.c | 3 +- input/input_driver.c | 21 +++++--- libretro-common/file/file_path.c | 63 ++++++++++++------------ libretro-common/include/file/file_path.h | 31 ++++++------ menu/drivers/ozone.c | 12 +++-- menu/drivers/xmb.c | 16 ++++-- menu/menu_displaylist.c | 6 ++- menu/menu_explore.c | 5 +- tasks/task_database.c | 6 ++- 11 files changed, 114 insertions(+), 85 deletions(-) diff --git a/cheat_manager.c b/cheat_manager.c index cc6da51643..bd75ff62e1 100644 --- a/cheat_manager.c +++ b/cheat_manager.c @@ -172,10 +172,11 @@ bool cheat_manager_save( if (!cheat_database) strlcpy(cheats_file, path, sizeof(cheats_file)); else - fill_pathname_join_concat(cheats_file, - cheat_database, path, - ".cht", - sizeof(cheats_file)); + { + fill_pathname_join(cheats_file, + cheat_database, path, sizeof(cheats_file)); + strlcat(cheats_file, ".cht", sizeof(cheats_file)); + } if (!overwrite) conf = config_file_new_from_path_to_string(cheats_file); diff --git a/configuration.c b/configuration.c index 35abb50e43..6cf0778bb1 100644 --- a/configuration.c +++ b/configuration.c @@ -4265,8 +4265,9 @@ static void save_keybind_joykey(config_file_t *conf, key[0] = '\0'; - fill_pathname_join_delim_concat(key, prefix, - base, '_', "_btn", sizeof(key)); + fill_pathname_join_delim(key, prefix, + base, '_', sizeof(key)); + strlcat(key, "_btn", sizeof(key)); if (bind->joykey == NO_BTN) { @@ -4288,12 +4289,10 @@ static void save_keybind_axis(config_file_t *conf, unsigned axis = 0; char dir = '\0'; - key[0] = '\0'; + key[0] = '\0'; - fill_pathname_join_delim_concat(key, - prefix, base, '_', - "_axis", - sizeof(key)); + fill_pathname_join_delim(key, prefix, base, '_', sizeof(key)); + strlcat(key, "_axis", sizeof(key)); if (bind->joyaxis == AXIS_NONE) { @@ -4331,8 +4330,9 @@ static void save_keybind_mbutton(config_file_t *conf, key[0] = '\0'; - fill_pathname_join_delim_concat(key, prefix, - base, '_', "_mbtn", sizeof(key)); + fill_pathname_join_delim(key, prefix, + base, '_', sizeof(key)); + strlcat(key, "_mbtn", sizeof(key)); switch (bind->mbutton) { @@ -4529,11 +4529,12 @@ bool config_save_autoconf_profile(const fill_pathname_join(buf, autoconf_dir, joypad_driver, sizeof(buf)); if (path_is_directory(buf)) - fill_pathname_join_concat(autoconf_file, buf, - sanitised_name, ".cfg", sizeof(autoconf_file)); + fill_pathname_join(autoconf_file, buf, + sanitised_name, sizeof(autoconf_file)); else - fill_pathname_join_concat(autoconf_file, autoconf_dir, - sanitised_name, ".cfg", sizeof(autoconf_file)); + fill_pathname_join(autoconf_file, autoconf_dir, + sanitised_name, sizeof(autoconf_file)); + strlcat(autoconf_file, ".cfg", sizeof(autoconf_file)); /* Open config file */ if ( !(conf = config_file_new_from_path_to_string(autoconf_file)) diff --git a/core_updater_list.c b/core_updater_list.c index 2f78f5ca29..98a3441ff6 100644 --- a/core_updater_list.c +++ b/core_updater_list.c @@ -486,11 +486,12 @@ static bool core_updater_list_set_paths( entry->local_core_path = strdup(local_core_path); /* local_info_path */ - fill_pathname_join_noext( + fill_pathname_join( local_info_path, path_libretro_info, filename_str, sizeof(local_info_path)); + path_remove_extension(local_info_path); if (is_archive) path_remove_extension(local_info_path); diff --git a/input/input_driver.c b/input/input_driver.c index eaaa9a81f6..a311b1858b 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -2230,8 +2230,11 @@ void input_config_get_bind_string_joykey( if (bind->joykey_label && !string_is_empty(bind->joykey_label) && input_descriptor_label_show) - fill_pathname_join_delim_concat(buf, prefix, - bind->joykey_label, ' ', " (hat)", size); + { + fill_pathname_join_delim(buf, prefix, + bind->joykey_label, ' ', size); + strlcat(buf, " (hat)", size); + } else { const char *dir = "?"; @@ -2263,8 +2266,11 @@ void input_config_get_bind_string_joykey( if (bind->joykey_label && !string_is_empty(bind->joykey_label) && input_descriptor_label_show) - fill_pathname_join_delim_concat(buf, prefix, - bind->joykey_label, ' ', " (btn)", size); + { + fill_pathname_join_delim(buf, prefix, + bind->joykey_label, ' ', size); + strlcat(buf, " (btn)", size); + } else snprintf(buf, size, "%s%u (%s)", prefix, (unsigned)bind->joykey, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE)); @@ -2279,8 +2285,11 @@ void input_config_get_bind_string_joyaxis( if (bind->joyaxis_label && !string_is_empty(bind->joyaxis_label) && input_descriptor_label_show) - fill_pathname_join_delim_concat(buf, prefix, - bind->joyaxis_label, ' ', " (axis)", size); + { + fill_pathname_join_delim(buf, prefix, + bind->joyaxis_label, ' ', size); + strlcat(buf, " (axis)", size); + } else { unsigned axis = 0; diff --git a/libretro-common/file/file_path.c b/libretro-common/file/file_path.c index 4200a088ac..8d63334566 100644 --- a/libretro-common/file/file_path.c +++ b/libretro-common/file/file_path.c @@ -964,22 +964,6 @@ size_t fill_pathname_join_concat_noext(char *out_path, return strlcat(out_path, concat, size); } -size_t fill_pathname_join_concat(char *out_path, - const char *dir, const char *path, - const char *concat, - size_t size) -{ - fill_pathname_join(out_path, dir, path, size); - return strlcat(out_path, concat, size); -} - -void fill_pathname_join_noext(char *out_path, - const char *dir, const char *path, size_t size) -{ - fill_pathname_join(out_path, dir, path, size); - path_remove_extension(out_path); -} - /** * fill_pathname_join_delim: * @out_path : output path @@ -1009,14 +993,6 @@ size_t fill_pathname_join_delim(char *out_path, const char *dir, return copied; } -size_t fill_pathname_join_delim_concat(char *out_path, const char *dir, - const char *path, const char delim, const char *concat, - size_t size) -{ - fill_pathname_join_delim(out_path, dir, path, delim, size); - return strlcat(out_path, concat, size); -} - /** * fill_short_pathname_representation: * @out_rep : output representation @@ -1045,13 +1021,6 @@ size_t fill_short_pathname_representation(char* out_rep, return strlcpy(out_rep, path_short, size); } -void fill_short_pathname_representation_noext(char* out_rep, - const char *in_path, size_t size) -{ - fill_short_pathname_representation(out_rep, in_path, size); - path_remove_extension(out_rep); -} - void fill_pathname_expand_special(char *out_path, const char *in_path, size_t size) { @@ -1444,3 +1413,35 @@ bool is_path_accessible_using_standard_io(const char *path) return true; #endif } + +/* Deprecated functions */ +size_t fill_pathname_join_concat(char *out_path, + const char *dir, const char *path, + const char *concat, + size_t size) +{ + fill_pathname_join(out_path, dir, path, size); + return strlcat(out_path, concat, size); +} + +void fill_pathname_join_noext(char *out_path, + const char *dir, const char *path, size_t size) +{ + fill_pathname_join(out_path, dir, path, size); + path_remove_extension(out_path); +} + +size_t fill_pathname_join_delim_concat(char *out_path, const char *dir, + const char *path, const char delim, const char *concat, + size_t size) +{ + fill_pathname_join_delim(out_path, dir, path, delim, size); + return strlcat(out_path, concat, size); +} + +void fill_short_pathname_representation_noext(char* out_rep, + const char *in_path, size_t size) +{ + fill_short_pathname_representation(out_rep, in_path, size); + path_remove_extension(out_rep); +} diff --git a/libretro-common/include/file/file_path.h b/libretro-common/include/file/file_path.h index 7ae66a9d03..b76d8ff15d 100644 --- a/libretro-common/include/file/file_path.h +++ b/libretro-common/include/file/file_path.h @@ -412,14 +412,6 @@ size_t fill_pathname_join_concat_noext(char *out_path, const char *concat, size_t size); -size_t fill_pathname_join_concat(char *out_path, - const char *dir, const char *path, - const char *concat, - size_t size); - -void fill_pathname_join_noext(char *out_path, - const char *dir, const char *path, size_t size); - /** * fill_pathname_join_delim: * @out_path : output path @@ -434,10 +426,6 @@ void fill_pathname_join_noext(char *out_path, size_t fill_pathname_join_delim(char *out_path, const char *dir, const char *path, const char delim, size_t size); -size_t fill_pathname_join_delim_concat(char *out_path, const char *dir, - const char *path, const char delim, const char *concat, - size_t size); - /** * fill_short_pathname_representation: * @out_rep : output representation @@ -456,9 +444,6 @@ size_t fill_pathname_join_delim_concat(char *out_path, const char *dir, size_t fill_short_pathname_representation(char* out_rep, const char *in_path, size_t size); -void fill_short_pathname_representation_noext(char* out_rep, - const char *in_path, size_t size); - void fill_pathname_expand_special(char *out_path, const char *in_path, size_t size); @@ -555,6 +540,22 @@ int32_t path_get_size(const char *path); bool is_path_accessible_using_standard_io(const char *path); +/* Deprecated functions */ +size_t fill_pathname_join_concat(char *out_path, + const char *dir, const char *path, + const char *concat, + size_t size); + +void fill_pathname_join_noext(char *out_path, + const char *dir, const char *path, size_t size); + +void fill_short_pathname_representation_noext(char* out_rep, + const char *in_path, size_t size); + +size_t fill_pathname_join_delim_concat(char *out_path, const char *dir, + const char *path, const char delim, const char *concat, + size_t size); + RETRO_END_DECLS #endif diff --git a/menu/drivers/ozone.c b/menu/drivers/ozone.c index 4994a81595..7b39cf57bc 100644 --- a/menu/drivers/ozone.c +++ b/menu/drivers/ozone.c @@ -4379,13 +4379,17 @@ static void ozone_context_reset_horizontal_list(ozone_handle_t *ozone) fill_pathname_base_noext(sysname, path, sizeof(sysname)); - fill_pathname_join_concat(texturepath, icons_path, sysname, - ".png", sizeof(texturepath)); + fill_pathname_join(texturepath, icons_path, sysname, + sizeof(texturepath)); + strlcat(texturepath, ".png", sizeof(texturepath)); /* If the playlist icon doesn't exist return default */ if (!path_is_valid(texturepath)) - fill_pathname_join_concat(texturepath, icons_path, "default", - ".png", sizeof(texturepath)); + { + fill_pathname_join(texturepath, icons_path, "default", + sizeof(texturepath)); + strlcat(texturepath, ".png", sizeof(texturepath)); + } ti.width = 0; ti.height = 0; diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 1a738e80fd..6cb66fd647 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -1093,11 +1093,12 @@ static char* xmb_path_dynamic_wallpaper(xmb_handle_t *xmb) if (tmp) { - fill_pathname_join_noext( + fill_pathname_join( path, dir_dynamic_wallpapers, tmp, sizeof(path)); + path_remove_extension(path); free(tmp); } @@ -2265,14 +2266,19 @@ static void xmb_context_reset_horizontal_list( fill_pathname_application_special(iconpath, sizeof(iconpath), APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS); - fill_pathname_join_concat(texturepath, iconpath, sysname, - FILE_PATH_PNG_EXTENSION, sizeof(texturepath)); + fill_pathname_join(texturepath, iconpath, sysname, + sizeof(texturepath)); + strlcat(texturepath, FILE_PATH_PNG_EXTENSION, sizeof(texturepath)); /* If the playlist icon doesn't exist return default */ if (!path_is_valid(texturepath)) - fill_pathname_join_concat(texturepath, iconpath, "default", - FILE_PATH_PNG_EXTENSION, sizeof(texturepath)); + { + fill_pathname_join(texturepath, iconpath, "default", + sizeof(texturepath)); + strlcat(texturepath, FILE_PATH_PNG_EXTENSION, + sizeof(texturepath)); + } ti.width = 0; ti.height = 0; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 015c5e8f2a..660d670cb6 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -2414,8 +2414,9 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, if (!db_info) goto error; - fill_short_pathname_representation_noext(path_base, info->path, + fill_short_pathname_representation(path_base, info->path, sizeof(path_base)); + path_remove_extension(path_base); menu_driver_set_thumbnail_system(path_base, sizeof(path_base)); @@ -4715,10 +4716,11 @@ static unsigned menu_displaylist_parse_content_information( db_path[0] = '\0'; - fill_pathname_join_noext(db_path, + fill_pathname_join(db_path, settings->paths.path_content_database, db_name, sizeof(db_path)); + path_remove_extension(db_path); strlcat(db_path, ".rdb", sizeof(db_path)); if (path_is_valid(db_path)) diff --git a/menu/menu_explore.c b/menu/menu_explore.c index 5762e1607a..4f75e2a89c 100644 --- a/menu/menu_explore.c +++ b/menu/menu_explore.c @@ -528,14 +528,15 @@ explore_state_t *menu_explore_build_list(const char *directory_playlist, newrdb.playlist_crcs = NULL; newrdb.playlist_names = NULL; - systemname_len = db_ext - db_name; + systemname_len = db_ext - db_name; if (systemname_len >= sizeof(newrdb.systemname)) systemname_len = sizeof(newrdb.systemname)-1; memcpy(newrdb.systemname, db_name, systemname_len); newrdb.systemname[systemname_len] = '\0'; - fill_pathname_join_noext( + fill_pathname_join( tmp, directory_database, db_name, sizeof(tmp)); + path_remove_extension(tmp); strlcat(tmp, ".rdb", sizeof(tmp)); if (libretrodb_open(tmp, newrdb.handle) != 0) diff --git a/tasks/task_database.c b/tasks/task_database.c index 3da62f1613..3be2170db3 100644 --- a/tasks/task_database.c +++ b/tasks/task_database.c @@ -756,8 +756,9 @@ static int database_info_list_iterate_found_match( db_playlist_base_str[0] = '\0'; entry_path_str[0] = '\0'; - fill_short_pathname_representation_noext(db_playlist_base_str, + fill_short_pathname_representation(db_playlist_base_str, db_path, str_len); + path_remove_extension(db_playlist_base_str); strlcat(db_playlist_base_str, ".lpl", str_len); @@ -1011,8 +1012,9 @@ static int task_database_iterate_playlist_lutro( game_title[0] = '\0'; - fill_short_pathname_representation_noext(game_title, + fill_short_pathname_representation(game_title, path, sizeof(game_title)); + path_remove_extension(game_title); /* the push function reads our entry as const, * so these casts are safe */