From e0582935e737dccc0528f113b35296f39f360b06 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 18 Aug 2018 09:52:47 +0200 Subject: Fix creating directories across drives on Windows --- NEWS | 6 ++++++ src/util.c | 19 +++++++++++++++++-- wscript | 2 +- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index e545386..31421f5 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,9 @@ +lilv (0.24.5) unstable; + + * Fix creating directories across drives on Windows + + -- David Robillard Sat, 18 Aug 2018 09:52:17 +0200 + lilv (0.24.4) stable; * Fix saving state when broken links are encountered diff --git a/src/util.c b/src/util.c index 4973181..98e89d8 100644 --- a/src/util.c +++ b/src/util.c @@ -333,6 +333,13 @@ lilv_copy_file(const char* src, const char* dst) return st; } +static inline bool +is_windows_path(const char* path) +{ + return (isalpha(path[0]) && (path[1] == ':' || path[1] == '|') && + (path[2] == '/' || path[2] == '\\')); +} + bool lilv_path_is_absolute(const char* path) { @@ -341,7 +348,7 @@ lilv_path_is_absolute(const char* path) } #ifdef _WIN32 - if (isalpha(path[0]) && path[1] == ':' && lilv_is_dir_sep(path[2])) { + if (is_windows_path(path)) { return true; } #endif @@ -572,7 +579,15 @@ lilv_mkdir_p(const char* dir_path) { char* path = lilv_strdup(dir_path); const size_t path_len = strlen(path); - for (size_t i = 1; i <= path_len; ++i) { + size_t i = 1; + +#ifdef _WIN32 + if (is_windows_path(dir_path)) { + i = 3; + } +#endif + + for (; i <= path_len; ++i) { if (path[i] == LILV_DIR_SEP[0] || path[i] == '\0') { path[i] = '\0'; if (mkdir(path, 0755) && errno != EEXIST) { diff --git a/wscript b/wscript index 9f31202..57ef231 100644 --- a/wscript +++ b/wscript @@ -12,7 +12,7 @@ import waflib.Logs as Logs # major increment <=> incompatible changes # minor increment <=> compatible changes (additions) # micro increment <=> no interface changes -LILV_VERSION = '0.24.4' +LILV_VERSION = '0.24.5' LILV_MAJOR_VERSION = '0' # Mandatory waf variables -- cgit v1.2.1