diff options
author | David Robillard <d@drobilla.net> | 2022-06-17 21:06:20 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-07-08 21:14:03 -0400 |
commit | 3a0f283e843fa5eb4542a2d154c897f86765fed8 (patch) | |
tree | 89209255d49c0c46759e79fef4f1bcd3295d8c06 /src | |
parent | 2a46565bdfa4d546b428601a19a6669151ebcbce (diff) | |
download | lilv-3a0f283e843fa5eb4542a2d154c897f86765fed8.tar.gz lilv-3a0f283e843fa5eb4542a2d154c897f86765fed8.tar.bz2 lilv-3a0f283e843fa5eb4542a2d154c897f86765fed8.zip |
Fix lilv_create_directories() when path has a trailing separator
Diffstat (limited to 'src')
-rw-r--r-- | src/filesystem.c | 4 |
1 files changed, 3 insertions, 1 deletions
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); |