From b7926605f4e47ae79491ea60b7695640c5eaaa43 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Mon, 11 Jul 2022 21:40:09 +0200 Subject: [PATCH] Remove fill_short_pathname_representation --- gfx/gfx_thumbnail_path.c | 5 ++-- libretro-common/file/file_path.c | 30 +----------------------- libretro-common/include/file/file_path.h | 18 -------------- manual_content_scan.c | 4 ++-- menu/cbs/menu_cbs_ok.c | 9 ++++--- menu/drivers/xmb.c | 2 +- menu/menu_displaylist.c | 12 +++++----- menu/menu_setting.c | 6 +++-- playlist.c | 6 +++-- tasks/task_database.c | 8 +++---- 10 files changed, 31 insertions(+), 69 deletions(-) diff --git a/gfx/gfx_thumbnail_path.c b/gfx/gfx_thumbnail_path.c index 49def50daa..f6473c2b4d 100644 --- a/gfx/gfx_thumbnail_path.c +++ b/gfx/gfx_thumbnail_path.c @@ -493,8 +493,9 @@ bool gfx_thumbnail_set_content_playlist( strlcpy(path_data->content_label, content_label, sizeof(path_data->content_label)); else - fill_short_pathname_representation(path_data->content_label, - content_path, sizeof(path_data->content_label)); + fill_pathname(path_data->content_label, + path_basename(content_path), + "", sizeof(path_data->content_label)); /* Determine content image name */ fill_content_img(path_data); diff --git a/libretro-common/file/file_path.c b/libretro-common/file/file_path.c index ec6106f1cc..3313af04e3 100644 --- a/libretro-common/file/file_path.c +++ b/libretro-common/file/file_path.c @@ -963,34 +963,6 @@ size_t fill_pathname_join_delim(char *out_path, const char *dir, return copied; } -/** - * fill_short_pathname_representation: - * @out_rep : output representation - * @in_path : input path - * @size : size of output representation - * - * Generates a short representation of path. It should only - * be used for displaying the result; the output representation is not - * binding in any meaningful way (for a normal path, this is the same as basename) - * In case of more complex URLs, this should cut everything except for - * the main image file. - * - * E.g.: "/path/to/game.img" -> game.img - * "/path/to/myarchive.7z#folder/to/game.img" -> game.img - */ -size_t fill_short_pathname_representation(char* out_rep, - const char *in_path, size_t size) -{ - char path_short[NAME_MAX_LENGTH]; - - path_short[0] = '\0'; - - fill_pathname(path_short, path_basename(in_path), "", - sizeof(path_short)); - - return strlcpy(out_rep, path_short, size); -} - void fill_pathname_expand_special(char *out_path, const char *in_path, size_t size) { @@ -1133,7 +1105,7 @@ void pathname_conform_slashes_to_os(char *path) *p = PATH_DEFAULT_SLASH_C(); } -/* Change all shashes to forward so they are more portable between windows and linux */ +/* Change all shashes to forward so they are more portable between Windows and Linux */ void pathname_make_slashes_portable(char *path) { /* Conform slashes to os standard so we get proper matching */ diff --git a/libretro-common/include/file/file_path.h b/libretro-common/include/file/file_path.h index 16404fe0e9..de9c8cca10 100644 --- a/libretro-common/include/file/file_path.h +++ b/libretro-common/include/file/file_path.h @@ -406,24 +406,6 @@ size_t fill_pathname_join_concat_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); -/** - * fill_short_pathname_representation: - * @out_rep : output representation - * @in_path : input path - * @size : size of output representation - * - * Generates a short representation of path. It should only - * be used for displaying the result; the output representation is not - * binding in any meaningful way (for a normal path, this is the same as basename) - * In case of more complex URLs, this should cut everything except for - * the main image file. - * - * E.g.: "/path/to/game.img" -> game.img - * "/path/to/myarchive.7z#folder/to/game.img" -> game.img - */ -size_t fill_short_pathname_representation(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); diff --git a/manual_content_scan.c b/manual_content_scan.c index cb394b34a2..a0da613110 100644 --- a/manual_content_scan.c +++ b/manual_content_scan.c @@ -1312,8 +1312,8 @@ static bool manual_content_scan_get_playlist_content_label( /* In most cases, content label is just the * filename without extension */ - fill_short_pathname_representation( - content_label, content_path, len); + fill_pathname(content_label, path_basename(content_path), + "", len); if (string_is_empty(content_label)) return false; diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index bd1dca9853..b267f79322 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -5441,8 +5441,9 @@ static int action_ok_add_to_favorites(const char *path, /* Label is empty - use file name instead */ if (string_is_empty(content_label)) - fill_short_pathname_representation(content_label, - content_path, sizeof(content_label)); + fill_pathname(content_label, + path_basename(content_path), "", + sizeof(content_label)); /* > core_path + core_name */ if (system) @@ -5579,7 +5580,9 @@ static int action_ok_add_to_favorites_playlist(const char *path, /* Label is empty - use file name instead */ char fallback_content_label[PATH_MAX_LENGTH]; fallback_content_label[0] = '\0'; - fill_short_pathname_representation(fallback_content_label, entry->path, sizeof(fallback_content_label)); + fill_pathname(fallback_content_label, + path_basename(entry->path), "", + sizeof(fallback_content_label)); string_list_append(str_list, fallback_content_label, attr); } diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 4af29ba974..2668a84736 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -3283,7 +3283,7 @@ static int xmb_draw_item( entry_path[0] = '\0'; strlcpy(entry_path, entry.path, sizeof(entry_path)); - fill_short_pathname_representation(entry_path, entry_path, + fill_pathname(entry_path, path_basename(entry_path), "", sizeof(entry_path)); if (!string_is_empty(entry_path)) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 1562fc5cf5..fe4c8fb8a5 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -2210,7 +2210,9 @@ static int menu_displaylist_parse_playlist(menu_displaylist_info_t *info, * no further action is necessary */ if (string_is_empty(entry->label)) - fill_short_pathname_representation(menu_entry_label, entry->path, sizeof(menu_entry_label)); + fill_pathname(menu_entry_label, + path_basename(entry->path), + "", sizeof(menu_entry_label)); else strlcpy(menu_entry_label, entry->label, sizeof(menu_entry_label)); @@ -2411,11 +2413,10 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, database_info_build_query_enum(query, sizeof(query), DATABASE_QUERY_ENTRY, info->path_b); - db_info = database_info_list_new(info->path, query); - if (!db_info) + if (!(db_info = database_info_list_new(info->path, query))) goto error; - fill_short_pathname_representation(path_base, info->path, + fill_pathname(path_base, path_basename(info->path), "", sizeof(path_base)); path_remove_extension(path_base); @@ -2427,9 +2428,8 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, sizeof(path_playlist)); playlist_config_set_path(&playlist_config, path_playlist); - playlist = playlist_init(&playlist_config); - if (playlist) + if ((playlist = playlist_init(&playlist_config))) strlcpy(menu->db_playlist_file, path_playlist, sizeof(menu->db_playlist_file)); diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 02502e50f8..384a80d99c 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -1292,7 +1292,8 @@ static void setting_get_string_representation_st_path(rarch_setting_t *setting, char *s, size_t len) { if (setting) - fill_short_pathname_representation(s, setting->value.target.string, len); + fill_pathname(s, path_basename(setting->value.target.string), + "", len); } static void setting_get_string_representation_st_string(rarch_setting_t *setting, @@ -3069,7 +3070,8 @@ static void setting_get_string_representation_video_filter(rarch_setting_t *sett if (!setting) return; - fill_short_pathname_representation(s, setting->value.target.string, len); + fill_pathname(s, path_basename(setting->value.target.string), + "", len); } static void setting_get_string_representation_state_slot(rarch_setting_t *setting, diff --git a/playlist.c b/playlist.c index 02e9e1b3b3..4d5e514116 100644 --- a/playlist.c +++ b/playlist.c @@ -2984,7 +2984,8 @@ static int playlist_qsort_func(const struct playlist_entry *a, goto end; if (!string_is_empty(a->path)) - fill_short_pathname_representation(a_fallback_label, a->path, PATH_MAX_LENGTH * sizeof(char)); + fill_pathname(a_fallback_label, path_basename(a->path), + "", PATH_MAX_LENGTH * sizeof(char)); /* If filename is also empty, use core name * instead -> this matches the behaviour of * menu_displaylist_parse_playlist() */ @@ -3007,7 +3008,8 @@ static int playlist_qsort_func(const struct playlist_entry *a, goto end; if (!string_is_empty(b->path)) - fill_short_pathname_representation(b_fallback_label, b->path, PATH_MAX_LENGTH * sizeof(char)); + fill_pathname(b_fallback_label, path_basename(b->path), "", + PATH_MAX_LENGTH * sizeof(char)); else if (!string_is_empty(b->core_name)) strlcpy(b_fallback_label, b->core_name, PATH_MAX_LENGTH * sizeof(char)); diff --git a/tasks/task_database.c b/tasks/task_database.c index 3be2170db3..23fe7fbc76 100644 --- a/tasks/task_database.c +++ b/tasks/task_database.c @@ -756,8 +756,8 @@ static int database_info_list_iterate_found_match( db_playlist_base_str[0] = '\0'; entry_path_str[0] = '\0'; - fill_short_pathname_representation(db_playlist_base_str, - db_path, str_len); + fill_pathname(db_playlist_base_str, + path_basename(db_path), "", str_len); path_remove_extension(db_playlist_base_str); strlcat(db_playlist_base_str, ".lpl", str_len); @@ -1012,8 +1012,8 @@ static int task_database_iterate_playlist_lutro( game_title[0] = '\0'; - fill_short_pathname_representation(game_title, - path, sizeof(game_title)); + fill_pathname(game_title, + path_basename(path), "", sizeof(game_title)); path_remove_extension(game_title); /* the push function reads our entry as const,