summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS1
-rw-r--r--src/util.c19
2 files changed, 18 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 5f02a5c..9b3b6e4 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
lilv (0.24.5) unstable;
* Fix GCC8 warnings
+ * Fix creating directories across drives on Windows
-- David Robillard <d@drobilla.net> Tue, 04 Sep 2018 21:02:19 +0200
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) {