summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/filesystem.c31
-rw-r--r--src/filesystem.h8
-rw-r--r--src/state.c17
3 files changed, 10 insertions, 46 deletions
diff --git a/src/filesystem.c b/src/filesystem.c
index ec13df3..548111f 100644
--- a/src/filesystem.c
+++ b/src/filesystem.c
@@ -356,34 +356,3 @@ lilv_create_temporary_directory(const char* pattern)
return result;
}
-
-int
-lilv_create_directories(const char* dir_path)
-{
- char* path = lilv_strdup(dir_path);
- const size_t path_len = strlen(path);
- size_t i = 1;
-
-#ifdef _WIN32
- if (is_windows_path(dir_path)) {
- i = 3;
- }
-#endif
-
- char prev = path[0];
- for (; i <= path_len; ++i) {
- const char c = path[i];
- 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);
- return errno;
- }
- path[i] = c;
- }
- prev = c;
- }
-
- free(path);
- return 0;
-}
diff --git a/src/filesystem.h b/src/filesystem.h
index a1b8fd7..157b072 100644
--- a/src/filesystem.h
+++ b/src/filesystem.h
@@ -112,11 +112,3 @@ lilv_create_temporary_directory_in(const char* pattern, const char* parent);
*/
char*
lilv_create_temporary_directory(const char* pattern);
-
-/**
- Create the directory `dir_path` and any parent directories if necessary.
-
- @return Zero on success, or an `errno` error code.
-*/
-int
-lilv_create_directories(const char* dir_path);
diff --git a/src/state.c b/src/state.c
index bf112b4..bce4eaa 100644
--- a/src/state.c
+++ b/src/state.c
@@ -11,6 +11,7 @@
#include "zix/allocator.h"
#include "zix/filesystem.h"
#include "zix/path.h"
+#include "zix/status.h"
#include "zix/tree.h"
#include "lv2/atom/atom.h"
@@ -251,7 +252,7 @@ static char*
make_path(LV2_State_Make_Path_Handle handle, const char* path)
{
LilvState* state = (LilvState*)handle;
- lilv_create_directories(state->dir);
+ zix_create_directories(NULL, state->dir);
return zix_path_join(NULL, state->dir, path);
}
@@ -287,10 +288,11 @@ abstract_path(LV2_State_Map_Path_Handle handle, const char* abs_path)
// File created by plugin earlier
path = lilv_path_relative_to(real_path, state->scratch_dir);
if (state->copy_dir) {
- int st = lilv_create_directories(state->copy_dir);
+ ZixStatus st = zix_create_directories(NULL, state->copy_dir);
if (st) {
- LILV_ERRORF(
- "Error creating directory %s (%s)\n", state->copy_dir, strerror(st));
+ LILV_ERRORF("Error creating directory %s (%s)\n",
+ state->copy_dir,
+ zix_strerror(st));
}
char* cpath = zix_path_join(NULL, state->copy_dir, path);
@@ -298,8 +300,9 @@ abstract_path(LV2_State_Map_Path_Handle handle, const char* abs_path)
if (!copy || !zix_file_equals(NULL, real_path, copy)) {
// No recent enough copy, make a new one
free(copy);
- copy = lilv_find_free_path(cpath, path_exists, NULL);
- if ((st = lilv_copy_file(real_path, copy))) {
+ copy = lilv_find_free_path(cpath, path_exists, NULL);
+ int rc = 0;
+ if ((rc = lilv_copy_file(real_path, copy))) {
LILV_ERRORF("Error copying state file %s (%s)\n", copy, strerror(st));
}
}
@@ -1223,7 +1226,7 @@ lilv_state_save(LilvWorld* world,
const char* dir,
const char* filename)
{
- if (!filename || !dir || lilv_create_directories(dir)) {
+ if (!filename || !dir || zix_create_directories(NULL, dir)) {
return 1;
}