diff options
-rw-r--r-- | src/filesystem.c | 10 | ||||
-rw-r--r-- | src/filesystem.h | 6 | ||||
-rw-r--r-- | src/state.c | 14 | ||||
-rw-r--r-- | src/util.c | 2 | ||||
-rw-r--r-- | test/lilv_test_utils.c | 6 | ||||
-rw-r--r-- | test/test_state.c | 6 | ||||
-rw-r--r-- | test/test_string.c | 16 | ||||
-rw-r--r-- | test/test_util.c | 2 |
8 files changed, 31 insertions, 31 deletions
diff --git a/src/filesystem.c b/src/filesystem.c index dbb528f..45ece12 100644 --- a/src/filesystem.c +++ b/src/filesystem.c @@ -149,7 +149,7 @@ lilv_path_relative_to(const char* path, const char* base) } char* -lilv_dirname(const char* path) +lilv_path_parent(const char* path) { const char* s = path + strlen(path) - 1; // Last character for (; s > path && lilv_is_dir_sep(*s); --s) {} // Last non-slash @@ -207,7 +207,7 @@ lilv_dir_path(const char* path) } char* -lilv_realpath(const char* path) +lilv_path_canonical(const char* path) { if (!path) { return NULL; @@ -325,7 +325,7 @@ lilv_dir_for_each(const char* path, } int -lilv_mkdir_p(const char* dir_path) +lilv_create_directories(const char* dir_path) { char* path = lilv_strdup(dir_path); const size_t path_len = strlen(path); @@ -373,8 +373,8 @@ lilv_file_equals(const char* a_path, const char* b_path) bool match = false; FILE* a_file = NULL; FILE* b_file = NULL; - char* const a_real = lilv_realpath(a_path); - char* const b_real = lilv_realpath(b_path); + char* const a_real = lilv_path_canonical(a_path); + char* const b_real = lilv_path_canonical(b_path); if (!strcmp(a_real, b_real)) { match = true; // Real paths match } else if (lilv_file_size(a_path) != lilv_file_size(b_path)) { diff --git a/src/filesystem.h b/src/filesystem.h index de06214..eb00e60 100644 --- a/src/filesystem.h +++ b/src/filesystem.h @@ -50,7 +50,7 @@ lilv_path_relative_to(const char* path, const char* base); Returns the root path if `path` is the root path. */ char* -lilv_dirname(const char* path); +lilv_path_parent(const char* path); /// Join path `a` and path `b` with a single directory separator between them char* @@ -67,7 +67,7 @@ lilv_dir_path(const char* path); directory separators. */ char* -lilv_realpath(const char* path); +lilv_path_canonical(const char* path); /// Return true iff `path` points to an existing file system entry bool @@ -122,7 +122,7 @@ lilv_dir_for_each(const char* path, @return Zero on success, or an `errno` error code. */ int -lilv_mkdir_p(const char* dir_path); +lilv_create_directories(const char* dir_path); /// Return true iff the given paths point to files with identical contents bool diff --git a/src/state.c b/src/state.c index 749316c..85e8d0f 100644 --- a/src/state.c +++ b/src/state.c @@ -244,7 +244,7 @@ static char* make_path(LV2_State_Make_Path_Handle handle, const char* path) { LilvState* state = (LilvState*)handle; - lilv_mkdir_p(state->dir); + lilv_create_directories(state->dir); return lilv_path_join(state->dir, path); } @@ -255,7 +255,7 @@ abstract_path(LV2_State_Map_Path_Handle handle, { LilvState* state = (LilvState*)handle; char* path = NULL; - char* real_path = lilv_realpath(abs_path); + char* real_path = lilv_path_canonical(abs_path); const PathMap key = { real_path, NULL }; ZixTreeIter* iter = NULL; @@ -273,7 +273,7 @@ abstract_path(LV2_State_Map_Path_Handle handle, // File created by plugin earlier path = lilv_path_relative_to(real_path, state->scratch_dir); if (state->copy_dir) { - int st = lilv_mkdir_p(state->copy_dir); + int st = lilv_create_directories(state->copy_dir); if (st) { LILV_ERRORF("Error creating directory %s (%s)\n", state->copy_dir, strerror(st)); @@ -725,8 +725,8 @@ lilv_state_new_from_file(LilvWorld* world, ? subject->node : sord_node_from_serd_node(world->world, env, &node, NULL, NULL); - char* dirname = lilv_dirname(path); - char* real_path = lilv_realpath(dirname); + char* dirname = lilv_path_parent(path); + char* real_path = lilv_path_canonical(dirname); char* dir_path = lilv_dir_path(real_path); LilvState* state = new_state_from_model(world, map, model, subject_node, dir_path); @@ -966,7 +966,7 @@ link_exists(const char* path, const void* data) if (!lilv_path_exists(path)) { return false; } - char* real_path = lilv_realpath(path); + char* real_path = lilv_path_canonical(path); bool matches = !strcmp(real_path, target); free(real_path); return !matches; @@ -1174,7 +1174,7 @@ lilv_state_save(LilvWorld* world, const char* dir, const char* filename) { - if (!filename || !dir || lilv_mkdir_p(dir)) { + if (!filename || !dir || lilv_create_directories(dir)) { return 1; } @@ -264,7 +264,7 @@ update_latest(const char* path, const char* name, void* data) char* lilv_get_latest_copy(const char* path, const char* copy_path) { - char* copy_dir = lilv_dirname(copy_path); + char* copy_dir = lilv_path_parent(copy_path); Latest latest = { lilv_strjoin(copy_path, ".%u", NULL), 0, NULL }; struct stat st; diff --git a/test/lilv_test_utils.c b/test/lilv_test_utils.c index 8c617b0..def3eca 100644 --- a/test/lilv_test_utils.c +++ b/test/lilv_test_utils.c @@ -53,7 +53,7 @@ lilv_test_env_new(void) env->plugin2_uri = lilv_new_uri(world, "http://example.org/foobar"); // Set custom LV2_PATH in build directory to only use test data - char* test_path = lilv_realpath(LILV_TEST_DIR); + char* test_path = lilv_path_canonical(LILV_TEST_DIR); char* lv2_path = lilv_strjoin(test_path, "/test_lv2_path", NULL); LilvNode* path = lilv_new_string(world, lv2_path); lilv_world_set_option(world, LILV_OPTION_LV2_PATH, path); @@ -83,12 +83,12 @@ create_bundle(LilvTestEnv* env, const char* manifest, const char* plugin) { static const char* const bundle_path = "/test_lv2_path/lilv-test.lv2"; - char* const test_path = lilv_realpath(LILV_TEST_DIR); + char* const test_path = lilv_path_canonical(LILV_TEST_DIR); env->test_bundle_path = lilv_strjoin(test_path, bundle_path, NULL); lilv_free(test_path); } - if (lilv_mkdir_p(env->test_bundle_path)) { + if (lilv_create_directories(env->test_bundle_path)) { fprintf(stderr, "Failed to create directory '%s' (%s)\n", env->test_bundle_path, diff --git a/test/test_state.c b/test/test_state.c index 178732f..acca4e9 100644 --- a/test/test_state.c +++ b/test/test_state.c @@ -175,7 +175,7 @@ main(void) assert(in == 1.0); assert(out == 1.0); - temp_dir = lilv_realpath("temp"); + temp_dir = lilv_path_canonical("temp"); const char* scratch_dir = NULL; char* copy_dir = NULL; @@ -369,9 +369,9 @@ main(void) mkdir("temp", 0700); scratch_dir = temp_dir; mkdir("files", 0700); - copy_dir = lilv_realpath("files"); + copy_dir = lilv_path_canonical("files"); mkdir("links", 0700); - link_dir = lilv_realpath("links"); + link_dir = lilv_path_canonical("links"); LV2_State_Make_Path make_path = {NULL, lilv_make_path}; LV2_Feature make_path_feature = {LV2_STATE__makePath, &make_path}; diff --git a/test/test_string.c b/test/test_string.c index 0bad915..d782c08 100644 --- a/test/test_string.c +++ b/test/test_string.c @@ -36,21 +36,21 @@ main(void) { char* s = NULL; - assert(!strcmp((s = lilv_dirname("/foo/bar")), "/foo")); + assert(!strcmp((s = lilv_path_parent("/foo/bar")), "/foo")); free(s); - assert(!strcmp((s = lilv_dirname("/foo/bar/")), "/foo")); + assert(!strcmp((s = lilv_path_parent("/foo/bar/")), "/foo")); free(s); - assert(!strcmp((s = lilv_dirname("/foo///bar/")), "/foo")); + assert(!strcmp((s = lilv_path_parent("/foo///bar/")), "/foo")); free(s); - assert(!strcmp((s = lilv_dirname("/foo///bar//")), "/foo")); + assert(!strcmp((s = lilv_path_parent("/foo///bar//")), "/foo")); free(s); - assert(!strcmp((s = lilv_dirname("foo")), ".")); + assert(!strcmp((s = lilv_path_parent("foo")), ".")); free(s); - assert(!strcmp((s = lilv_dirname("/foo")), "/")); + assert(!strcmp((s = lilv_path_parent("/foo")), "/")); free(s); - assert(!strcmp((s = lilv_dirname("/")), "/")); + assert(!strcmp((s = lilv_path_parent("/")), "/")); free(s); - assert(!strcmp((s = lilv_dirname("//")), "/")); + assert(!strcmp((s = lilv_path_parent("//")), "/")); free(s); assert(!strcmp((s = lilv_path_relative_to("/a/b", "/a/")), "b")); free(s); diff --git a/test/test_util.c b/test/test_util.c index fb41ca4..9055e88 100644 --- a/test/test_util.c +++ b/test/test_util.c @@ -37,7 +37,7 @@ int main(void) { - assert(!lilv_realpath(NULL)); + assert(!lilv_path_canonical(NULL)); char a_path[16]; char b_path[16]; |