summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-08-18 09:52:47 +0200
committerDavid Robillard <d@drobilla.net>2018-09-15 18:52:30 +0200
commit13e80b05b7d57021b2ae70e08f252bcae2f53fd2 (patch)
treef9cdc78f703997e0c1c3e80279548f370a2c81ab
parente78eb603691b7546848e8b0fb36444292fd1550d (diff)
downloadlilv-13e80b05b7d57021b2ae70e08f252bcae2f53fd2.tar.gz
lilv-13e80b05b7d57021b2ae70e08f252bcae2f53fd2.tar.bz2
lilv-13e80b05b7d57021b2ae70e08f252bcae2f53fd2.zip
Fix creating directories across drives on Windows
-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) {