From 3a0f283e843fa5eb4542a2d154c897f86765fed8 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 17 Jun 2022 21:06:20 -0400 Subject: Fix lilv_create_directories() when path has a trailing separator --- src/filesystem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/filesystem.c b/src/filesystem.c index e4fe13f..308c690 100644 --- a/src/filesystem.c +++ b/src/filesystem.c @@ -487,9 +487,10 @@ lilv_create_directories(const char* dir_path) } #endif + char prev = path[0]; for (; i <= path_len; ++i) { const char c = path[i]; - if (c == LILV_DIR_SEP[0] || c == '/' || c == '\0') { + if (lilv_is_dir_sep(c) || (c == '\0' && !lilv_is_dir_sep(prev))) { path[i] = '\0'; if (mkdir(path, 0755) && (errno != EEXIST || !lilv_is_directory(path))) { free(path); @@ -497,6 +498,7 @@ lilv_create_directories(const char* dir_path) } path[i] = c; } + prev = c; } free(path); -- cgit v1.2.1