summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/filesystem.c44
-rw-r--r--src/filesystem.h8
-rw-r--r--src/state.c8
3 files changed, 4 insertions, 56 deletions
diff --git a/src/filesystem.c b/src/filesystem.c
index c0ad864..7e42dbd 100644
--- a/src/filesystem.c
+++ b/src/filesystem.c
@@ -25,16 +25,11 @@
#include <sys/stat.h>
-#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#ifndef PAGE_SIZE
-# define PAGE_SIZE 4096
-#endif
-
static bool
lilv_is_dir_sep(const char c)
{
@@ -198,45 +193,6 @@ lilv_is_directory(const char* path)
}
int
-lilv_copy_file(const char* src, const char* dst)
-{
- FILE* in = fopen(src, "r");
- if (!in) {
- return errno;
- }
-
- FILE* out = fopen(dst, "w");
- if (!out) {
- fclose(in);
- return errno;
- }
-
- char* page = (char*)malloc(PAGE_SIZE);
- size_t n_read = 0;
- int st = 0;
- while ((n_read = fread(page, 1, PAGE_SIZE, in)) > 0) {
- if (fwrite(page, 1, n_read, out) != n_read) {
- st = errno;
- break;
- }
- }
-
- if (!st && fflush(out)) {
- st = errno;
- }
-
- if (!st && (ferror(in) || ferror(out))) {
- st = EBADF;
- }
-
- free(page);
- fclose(in);
- fclose(out);
-
- return st;
-}
-
-int
lilv_symlink(const char* oldpath, const char* newpath)
{
int ret = 0;
diff --git a/src/filesystem.h b/src/filesystem.h
index 4d66e19..33294da 100644
--- a/src/filesystem.h
+++ b/src/filesystem.h
@@ -47,14 +47,6 @@ bool
lilv_is_directory(const char* path);
/**
- Copy the file at path `src` to path `dst`.
-
- @return Zero on success, or a standard `errno` error code.
-*/
-int
-lilv_copy_file(const char* src, const char* dst);
-
-/**
Create a symlink at `newpath` that points to `oldpath`.
@return Zero on success, otherwise non-zero and `errno` is set.
diff --git a/src/state.c b/src/state.c
index bce4eaa..c0c9400 100644
--- a/src/state.c
+++ b/src/state.c
@@ -300,10 +300,10 @@ 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);
- int rc = 0;
- if ((rc = lilv_copy_file(real_path, copy))) {
- LILV_ERRORF("Error copying state file %s (%s)\n", copy, strerror(st));
+ copy = lilv_find_free_path(cpath, path_exists, NULL);
+ if ((st = zix_copy_file(NULL, real_path, copy, 0U))) {
+ LILV_ERRORF(
+ "Error copying state file %s (%s)\n", copy, zix_strerror(st));
}
}
zix_free(NULL, real_path);