From c492e46d96e7f2f660090790e97a2468cdde4c85 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Thu, 19 Dec 2024 20:51:33 +0100 Subject: [PATCH] Change function signature of fill_pathname_parent_dir --- libretro-common/file/file_path.c | 17 ++++++++--------- libretro-common/include/file/file_path.h | 10 +++++----- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/libretro-common/file/file_path.c b/libretro-common/file/file_path.c index 28b3d6746d..9b3a464984 100644 --- a/libretro-common/file/file_path.c +++ b/libretro-common/file/file_path.c @@ -451,17 +451,18 @@ void fill_pathname_basedir(char *s, const char *in_path, size_t len) /** * fill_pathname_parent_dir_name: - * @s : output directory + * @s : output string * @in_dir : input directory - * @len : size of output directory + * @len : size of @s * * Copies only the parent directory name of @in_dir into @s. * The two buffers must not overlap. Removes trailing '/'. * - * @return true on success, false if a slash was not found in the path. + * @return Length of the string copied into @s **/ -bool fill_pathname_parent_dir_name(char *s, const char *in_dir, size_t len) +size_t fill_pathname_parent_dir_name(char *s, const char *in_dir, size_t len) { + size_t _len = 0; char *tmp = strdup(in_dir); const char *slash = strrchr(tmp, '/'); const char *backslash = strrchr(tmp, '\\'); @@ -493,15 +494,13 @@ bool fill_pathname_parent_dir_name(char *s, const char *in_dir, size_t len) { /* If path starts with an slash, eliminate it. */ if (path_is_absolute(in_dir)) - strlcpy(s, in_dir + 1, len); + _len = strlcpy(s, in_dir + 1, len); else - strlcpy(s, in_dir, len); - free(tmp); - return true; + _len = strlcpy(s, in_dir, len); } free(tmp); - return false; + return _len; } /** diff --git a/libretro-common/include/file/file_path.h b/libretro-common/include/file/file_path.h index 581e46a716..6190f15c2c 100644 --- a/libretro-common/include/file/file_path.h +++ b/libretro-common/include/file/file_path.h @@ -408,9 +408,9 @@ void fill_pathname_basedir(char *out_path, const char *in_path, size_t size); /** * fill_pathname_parent_dir_name: - * @out_dir : output directory + * @s : output string * @in_dir : input directory - * @size : size of output directory + * @len : size of @s * * Copies only the parent directory name of @in_dir into @out_dir. * The two buffers must not overlap. Removes trailing '/'. @@ -420,10 +420,10 @@ void fill_pathname_basedir(char *out_path, const char *in_path, size_t size); * - Calls find_last_slash() x times * - Can call strlcpy * - * @return true on success, false if a slash was not found in the path. + * @return Length of the string copied into @s **/ -bool fill_pathname_parent_dir_name(char *out_dir, - const char *in_dir, size_t size); +size_t fill_pathname_parent_dir_name(char *s, + const char *in_dir, size_t len); /** * fill_pathname_parent_dir: