From 86c9a43b08014bf75c6a53be7e4bad556d6275ff Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Thu, 16 Jan 2025 21:09:19 +0100 Subject: [PATCH] Use path_get_extension_mutable --- libretro-common/file/file_path.c | 6 +++--- menu/menu_displaylist.c | 2 +- runloop.c | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/libretro-common/file/file_path.c b/libretro-common/file/file_path.c index 897d97c619d..ad484a4b84f 100644 --- a/libretro-common/file/file_path.c +++ b/libretro-common/file/file_path.c @@ -255,7 +255,8 @@ const char *path_get_extension(const char *path) char *path_get_extension_mutable(const char *path) { char *ext = NULL; - if (!string_is_empty(path) && ((ext = (char*)strrchr(path_basename(path), '.')))) + if ( !string_is_empty(path) + && ((ext = (char*)strrchr(path_basename(path), '.')))) return ext; return NULL; } @@ -276,8 +277,7 @@ char *path_get_extension_mutable(const char *path) **/ char *path_remove_extension(char *s) { - char *last = !string_is_empty(s) - ? (char*)strrchr(path_basename(s), '.') : NULL; + char *last = path_get_extension_mutable(s); if (!last) return NULL; if (*last) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index ccf102220ce..9fb01dc3427 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -5145,7 +5145,7 @@ static unsigned menu_displaylist_parse_content_information( settings->paths.path_content_database, db_name, sizeof(db_path)); - last = (char*)strrchr(path_basename(db_path), '.'); + last = path_get_extension_mutable(db_path); if (*last) { last[0] = '.'; diff --git a/runloop.c b/runloop.c index f8bc9104de8..cf7878eace0 100644 --- a/runloop.c +++ b/runloop.c @@ -7856,7 +7856,8 @@ void runloop_path_set_basename(const char *path) */ path_basedir_wrapper(runloop_st->runtime_content_path_basename); if (!string_is_empty(runloop_st->runtime_content_path_basename)) - fill_pathname_dir(runloop_st->runtime_content_path_basename, path, "", sizeof(runloop_st->runtime_content_path_basename)); + fill_pathname_dir(runloop_st->runtime_content_path_basename, path, + "", sizeof(runloop_st->runtime_content_path_basename)); #endif if ((dst = strrchr(runloop_st->runtime_content_path_basename, '.')))