summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/filesystem.c12
-rw-r--r--src/filesystem.h4
-rw-r--r--src/state.c4
-rw-r--r--test/lilv_test_utils.c4
-rw-r--r--test/test_filesystem.c32
-rw-r--r--test/test_state.c24
-rw-r--r--test/test_util.c7
7 files changed, 36 insertions, 51 deletions
diff --git a/src/filesystem.c b/src/filesystem.c
index 48e046d..6958600 100644
--- a/src/filesystem.c
+++ b/src/filesystem.c
@@ -405,15 +405,3 @@ lilv_create_directories(const char* dir_path)
free(path);
return 0;
}
-
-int
-lilv_remove(const char* path)
-{
-#ifdef _WIN32
- if (lilv_is_directory(path)) {
- return !RemoveDirectory(path);
- }
-#endif
-
- return remove(path);
-}
diff --git a/src/filesystem.h b/src/filesystem.h
index e995cf4..9337a97 100644
--- a/src/filesystem.h
+++ b/src/filesystem.h
@@ -124,7 +124,3 @@ lilv_create_temporary_directory(const char* pattern);
*/
int
lilv_create_directories(const char* dir_path);
-
-/// Remove the file or empty directory at `path`
-int
-lilv_remove(const char* path);
diff --git a/src/state.c b/src/state.c
index 920d067..bf112b4 100644
--- a/src/state.c
+++ b/src/state.c
@@ -1305,7 +1305,7 @@ static void
try_unlink(const char* state_dir, const char* path)
{
if (!strncmp(state_dir, path, strlen(state_dir))) {
- if (zix_file_type(path) != ZIX_FILE_TYPE_NONE && lilv_remove(path)) {
+ if (zix_file_type(path) != ZIX_FILE_TYPE_NONE && zix_remove(path)) {
LILV_ERRORF("Failed to remove %s (%s)\n", path, strerror(errno));
}
}
@@ -1397,7 +1397,7 @@ lilv_state_delete(LilvWorld* world, const LilvState* state)
}
}
- if (lilv_remove(state->dir)) {
+ if (zix_remove(state->dir)) {
LILV_ERRORF(
"Failed to remove directory %s (%s)\n", state->dir, strerror(errno));
}
diff --git a/test/lilv_test_utils.c b/test/lilv_test_utils.c
index e924873..cca6ac9 100644
--- a/test/lilv_test_utils.c
+++ b/test/lilv_test_utils.c
@@ -142,11 +142,11 @@ void
delete_bundle(LilvTestEnv* env)
{
if (env->test_content_path) {
- lilv_remove(env->test_content_path);
+ zix_remove(env->test_content_path);
}
if (env->test_manifest_path) {
- lilv_remove(env->test_manifest_path);
+ zix_remove(env->test_manifest_path);
}
if (env->test_bundle_path) {
diff --git a/test/test_filesystem.c b/test/test_filesystem.c
index 2057101..1ac4639 100644
--- a/test/test_filesystem.c
+++ b/test/test_filesystem.c
@@ -159,8 +159,8 @@ test_is_directory(void)
assert(!lilv_is_directory(file_path)); // File
- assert(!lilv_remove(file_path));
- assert(!lilv_remove(temp_dir));
+ assert(!zix_remove(file_path));
+ assert(!zix_remove(temp_dir));
free(file_path);
free(temp_dir);
@@ -193,9 +193,9 @@ test_copy_file(void)
assert(lilv_copy_file(file_path, "/dev/full") == ENOSPC);
}
- assert(!lilv_remove(copy_path));
- assert(!lilv_remove(file_path));
- assert(!lilv_remove(temp_dir));
+ assert(!zix_remove(copy_path));
+ assert(!zix_remove(file_path));
+ assert(!zix_remove(temp_dir));
free(copy_path);
free(file_path);
@@ -217,8 +217,8 @@ test_flock(void)
fclose(f2);
fclose(f1);
- assert(!lilv_remove(file_path));
- assert(!lilv_remove(temp_dir));
+ assert(!zix_remove(file_path));
+ assert(!zix_remove(temp_dir));
free(file_path);
free(temp_dir);
}
@@ -263,9 +263,9 @@ test_dir_for_each(void)
(!strcmp(file_list.names[0], "lilv_test_2") &&
!strcmp(file_list.names[1], "lilv_test_1")));
- assert(!lilv_remove(path2));
- assert(!lilv_remove(path1));
- assert(!lilv_remove(temp_dir));
+ assert(!zix_remove(path2));
+ assert(!zix_remove(path1));
+ assert(!zix_remove(temp_dir));
free(file_list.names[0]);
free(file_list.names[1]);
@@ -287,8 +287,8 @@ test_create_temporary_directory(void)
assert(strcmp(path1, path2));
assert(lilv_is_directory(path2));
- assert(!lilv_remove(path2));
- assert(!lilv_remove(path1));
+ assert(!zix_remove(path2));
+ assert(!zix_remove(path1));
free(path2);
free(path1);
}
@@ -315,10 +315,10 @@ test_create_directories(void)
assert(lilv_create_directories(file_path));
- assert(!lilv_remove(file_path));
- assert(!lilv_remove(grandchild_dir));
- assert(!lilv_remove(child_dir));
- assert(!lilv_remove(temp_dir));
+ assert(!zix_remove(file_path));
+ assert(!zix_remove(grandchild_dir));
+ assert(!zix_remove(child_dir));
+ assert(!zix_remove(temp_dir));
free(file_path);
free(child_dir);
free(grandchild_dir);
diff --git a/test/test_state.c b/test/test_state.c
index e80ec89..26d8d97 100644
--- a/test/test_state.c
+++ b/test/test_state.c
@@ -148,7 +148,7 @@ remove_file(const char* path, const char* name, void* data)
(void)data;
char* const full_path = zix_path_join(NULL, path, name);
- assert(!lilv_remove(full_path));
+ assert(!zix_remove(full_path));
free(full_path);
}
@@ -159,11 +159,11 @@ cleanup_test_directories(const TestDirectories dirs)
lilv_dir_for_each(dirs.copy, NULL, remove_file);
lilv_dir_for_each(dirs.link, NULL, remove_file);
- assert(!lilv_remove(dirs.link));
- assert(!lilv_remove(dirs.copy));
- assert(!lilv_remove(dirs.scratch));
- assert(!lilv_remove(dirs.shared));
- assert(!lilv_remove(dirs.top));
+ assert(!zix_remove(dirs.link));
+ assert(!zix_remove(dirs.copy));
+ assert(!zix_remove(dirs.scratch));
+ assert(!zix_remove(dirs.shared));
+ assert(!zix_remove(dirs.top));
zix_free(NULL, dirs.link);
zix_free(NULL, dirs.copy);
@@ -663,8 +663,8 @@ test_to_files(void)
lilv_instance_free(instance);
lilv_dir_for_each(bundle_2_path, NULL, remove_file);
lilv_dir_for_each(bundle_1_path, NULL, remove_file);
- assert(!lilv_remove(bundle_2_path));
- assert(!lilv_remove(bundle_1_path));
+ assert(!zix_remove(bundle_2_path));
+ assert(!zix_remove(bundle_1_path));
cleanup_test_directories(dirs);
zix_free(NULL, recfile_link_2);
@@ -742,7 +742,7 @@ test_multi_save(void)
lilv_instance_free(instance);
lilv_dir_for_each(bundle_1_path, NULL, remove_file);
- lilv_remove(bundle_1_path);
+ zix_remove(bundle_1_path);
cleanup_test_directories(dirs);
free(state_path);
@@ -850,9 +850,9 @@ test_files_round_trip(void)
lilv_dir_for_each(bundle_1_1_path, NULL, remove_file);
lilv_dir_for_each(bundle_1_2_path, NULL, remove_file);
lilv_dir_for_each(bundle_2_path, NULL, remove_file);
- lilv_remove(bundle_1_1_path);
- lilv_remove(bundle_1_2_path);
- lilv_remove(bundle_2_path);
+ zix_remove(bundle_1_1_path);
+ zix_remove(bundle_1_2_path);
+ zix_remove(bundle_2_path);
cleanup_test_directories(dirs);
lilv_state_free(state_2_loaded);
diff --git a/test/test_util.c b/test/test_util.c
index 529719e..c228b8f 100644
--- a/test/test_util.c
+++ b/test/test_util.c
@@ -6,6 +6,7 @@
#include "../src/filesystem.h"
#include "lilv/lilv.h"
+#include "zix/filesystem.h"
#include "zix/path.h"
#include <assert.h>
@@ -29,9 +30,9 @@ main(void)
assert(lilv_copy_file(a_path, "not/a/dir/copy"));
assert(!lilv_copy_file(a_path, "copy_c"));
- assert(!lilv_remove(a_path));
- assert(!lilv_remove(b_path));
- assert(!lilv_remove(dir));
+ assert(!zix_remove(a_path));
+ assert(!zix_remove(b_path));
+ assert(!zix_remove(dir));
lilv_free(b_path);
lilv_free(a_path);