summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-08-04 16:22:16 +0200
committerDavid Robillard <d@drobilla.net>2020-08-06 17:34:42 +0200
commitbfe42327cab38b3e47a3b2afec53ea8edd4b1531 (patch)
tree2b29c7ccbaa5f4c8f0ded43caae90ad6d04baf27 /src
parent18c8af55e63653c74d58137cd12434f1213f4230 (diff)
downloadlilv-bfe42327cab38b3e47a3b2afec53ea8edd4b1531.tar.gz
lilv-bfe42327cab38b3e47a3b2afec53ea8edd4b1531.tar.bz2
lilv-bfe42327cab38b3e47a3b2afec53ea8edd4b1531.zip
Remove lilv_dir_path()
This function was weird. Instead, to make a directory path with trailing separator, join nothing as in Python.
Diffstat (limited to 'src')
-rw-r--r--src/filesystem.c21
-rw-r--r--src/filesystem.h4
-rw-r--r--src/state.c6
3 files changed, 4 insertions, 27 deletions
diff --git a/src/filesystem.c b/src/filesystem.c
index 45ece12..a12dcba 100644
--- a/src/filesystem.c
+++ b/src/filesystem.c
@@ -170,7 +170,7 @@ char*
lilv_path_join(const char* a, const char* b)
{
if (!a) {
- return lilv_strdup(b);
+ return (b && b[0]) ? lilv_strdup(b) : NULL;
}
const size_t a_len = strlen(a);
@@ -188,25 +188,6 @@ lilv_path_join(const char* a, const char* b)
}
char*
-lilv_dir_path(const char* path)
-{
- if (!path) {
- return NULL;
- }
-
- const size_t len = strlen(path);
-
- if (lilv_is_dir_sep(path[len - 1])) {
- return lilv_strdup(path);
- }
-
- char* dir_path = (char*)calloc(len + 2, 1);
- memcpy(dir_path, path, len);
- dir_path[len] = LILV_DIR_SEP[0];
- return dir_path;
-}
-
-char*
lilv_path_canonical(const char* path)
{
if (!path) {
diff --git a/src/filesystem.h b/src/filesystem.h
index eb00e60..1b29d42 100644
--- a/src/filesystem.h
+++ b/src/filesystem.h
@@ -56,10 +56,6 @@ lilv_path_parent(const char* path);
char*
lilv_path_join(const char* a, const char* b);
-/// Return `path` normalized to have a trailing directory separator
-char*
-lilv_dir_path(const char* path);
-
/**
Return `path` as a canonicalized absolute path.
diff --git a/src/state.c b/src/state.c
index 85e8d0f..2b7cde9 100644
--- a/src/state.c
+++ b/src/state.c
@@ -539,7 +539,7 @@ set_state_dir_from_model(LilvState* state, const SordNode* graph)
const char* uri = (const char*)sord_node_get_string(graph);
char* path = lilv_file_uri_parse(uri, NULL);
- state->dir = lilv_dir_path(path);
+ state->dir = lilv_path_join(path, NULL);
free(path);
}
assert(!state->dir || lilv_path_is_absolute(state->dir));
@@ -559,7 +559,7 @@ new_state_from_model(LilvWorld* world,
// Allocate state
LilvState* const state = (LilvState*)calloc(1, sizeof(LilvState));
- state->dir = lilv_dir_path(dir);
+ state->dir = lilv_path_join(dir, NULL);
state->atom_Path = map->map(map->handle, LV2_ATOM__Path);
state->uri = lilv_node_new_from_node(world, node);
@@ -727,7 +727,7 @@ lilv_state_new_from_file(LilvWorld* world,
char* dirname = lilv_path_parent(path);
char* real_path = lilv_path_canonical(dirname);
- char* dir_path = lilv_dir_path(real_path);
+ char* dir_path = lilv_path_join(real_path, NULL);
LilvState* state =
new_state_from_model(world, map, model, subject_node, dir_path);
free(dir_path);