From f573626144b6a53ca241c3d5d4ac636f55d649d9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 23 Apr 2019 23:21:16 +0200 Subject: [PATCH] Simplify path_parent_dir --- libretro-common/file/file_path.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libretro-common/file/file_path.c b/libretro-common/file/file_path.c index 72e02e1abf..ba9bde3af6 100644 --- a/libretro-common/file/file_path.c +++ b/libretro-common/file/file_path.c @@ -647,13 +647,15 @@ void path_basedir(char *path) **/ void path_parent_dir(char *path) { - bool path_was_absolute = path_is_absolute(path); - size_t len = strlen(path); + size_t len = strlen(path); if (len && path_char_is_slash(path[len - 1])) { + bool path_was_absolute = path_is_absolute(path); + path[len - 1] = '\0'; - if (path_was_absolute && find_last_slash(path) == NULL) + + if (path_was_absolute && !find_last_slash(path)) { /* We removed the only slash from what used to be an absolute path. * On Linux, this goes from "/" to an empty string and everything works fine, @@ -965,7 +967,7 @@ void fill_pathname_expand_special(char *out_path, retro_assert(src_size < size); out_path += src_size; - size -= src_size; + size -= src_size; } in_path += 2;