summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/filesystem.c36
-rw-r--r--src/filesystem.h17
-rw-r--r--src/state.c20
3 files changed, 15 insertions, 58 deletions
diff --git a/src/filesystem.c b/src/filesystem.c
deleted file mode 100644
index 945751f..0000000
--- a/src/filesystem.c
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2007-2021 David Robillard <d@drobilla.net>
-// SPDX-License-Identifier: ISC
-
-#include "filesystem.h"
-
-#include "zix/allocator.h"
-#include "zix/filesystem.h"
-#include "zix/path.h"
-
-#include <stdbool.h>
-#include <stdio.h>
-#include <string.h>
-
-bool
-lilv_path_is_child(const char* path, const char* dir)
-{
- if (path && dir) {
- const size_t path_len = strlen(path);
- const size_t dir_len = strlen(dir);
- return dir && path_len >= dir_len && !strncmp(path, dir, dir_len);
- }
- return false;
-}
-
-char*
-lilv_create_temporary_directory(const char* pattern)
-{
- char* const tmpdir = zix_temp_directory_path(NULL);
- char* const path_pattern = zix_path_join(NULL, tmpdir, pattern);
- char* const result = zix_create_temporary_directory(NULL, path_pattern);
-
- zix_free(NULL, path_pattern);
- zix_free(NULL, tmpdir);
-
- return result;
-}
diff --git a/src/filesystem.h b/src/filesystem.h
deleted file mode 100644
index acc8845..0000000
--- a/src/filesystem.h
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright 2007-2020 David Robillard <d@drobilla.net>
-// SPDX-License-Identifier: ISC
-
-#include <stdbool.h>
-
-/// Return true iff `path` is a child of `dir`
-bool
-lilv_path_is_child(const char* path, const char* dir);
-
-/**
- Create a unique temporary directory.
-
- This is like lilv_create_temporary_directory_in(), except it creates the
- directory in the system temporary directory.
-*/
-char*
-lilv_create_temporary_directory(const char* pattern);
diff --git a/src/state.c b/src/state.c
index 63b26e6..58aebf6 100644
--- a/src/state.c
+++ b/src/state.c
@@ -1,7 +1,6 @@
// Copyright 2007-2022 David Robillard <d@drobilla.net>
// SPDX-License-Identifier: ISC
-#include "filesystem.h"
#include "lilv_internal.h"
#include "lilv/lilv.h"
@@ -258,6 +257,17 @@ make_path(LV2_State_Make_Path_Handle handle, const char* path)
return zix_path_join(NULL, state->dir, path);
}
+static bool
+path_is_child(const char* path, const char* dir)
+{
+ if (path && dir) {
+ const size_t path_len = strlen(path);
+ const size_t dir_len = strlen(dir);
+ return dir && path_len >= dir_len && !strncmp(path, dir, dir_len);
+ }
+ return false;
+}
+
static char*
abstract_path(LV2_State_Map_Path_Handle handle, const char* abs_path)
{
@@ -282,10 +292,10 @@ abstract_path(LV2_State_Map_Path_Handle handle, const char* abs_path)
return lilv_strdup(pm->rel);
}
- if (lilv_path_is_child(real_path, state->dir)) {
+ if (path_is_child(real_path, state->dir)) {
// File in state directory (loaded, or created by plugin during save)
path = zix_path_lexically_relative(NULL, real_path, state->dir);
- } else if (lilv_path_is_child(real_path, state->scratch_dir)) {
+ } else if (path_is_child(real_path, state->scratch_dir)) {
// File created by plugin earlier
path = zix_path_lexically_relative(NULL, real_path, state->scratch_dir);
if (state->copy_dir) {
@@ -1193,11 +1203,11 @@ lilv_state_make_links(const LilvState* state, const char* dir)
const PathMap* const pm = (const PathMap*)zix_tree_get(i);
char* const path = zix_path_join(NULL, dir, pm->rel);
- if (lilv_path_is_child(pm->abs, state->copy_dir) &&
+ if (path_is_child(pm->abs, state->copy_dir) &&
strcmp(state->copy_dir, dir)) {
// Link directly to snapshot in the copy directory
maybe_symlink(pm->abs, path);
- } else if (!lilv_path_is_child(pm->abs, dir)) {
+ } else if (!path_is_child(pm->abs, dir)) {
const char* link_dir = state->link_dir ? state->link_dir : dir;
char* pat = zix_path_join(NULL, link_dir, pm->rel);