From 9946c0363648b44d396b07d8a1a4557c568edc88 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 15 Jul 2020 16:49:36 +0200 Subject: Implement html sync, fix rss sync --- src/fileutils.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/fileutils.c') diff --git a/src/fileutils.c b/src/fileutils.c index 4fba0d0..524a603 100644 --- a/src/fileutils.c +++ b/src/fileutils.c @@ -25,7 +25,7 @@ int file_get_content(const char *filepath, char **data, long *size) { FILE *file = fopen(filepath, "rb"); if(!file) { int err = -errno; - perror(filepath); + /*perror(filepath);*/ return err; } @@ -116,11 +116,11 @@ int file_overwrite(const char *filepath, const char *data, size_t size) { int file_overwrite_in_dir(const char *dir, const char *filename, const char *data, size_t size) { char filepath[PATH_MAX]; const char *filepath_components[] = { dir, filename }; - path_join(filepath, filepath_components, 2); + int filepath_len = path_join(filepath, filepath_components, 2); char tmp_filepath[PATH_MAX]; strcpy(tmp_filepath, filepath); - strcat(tmp_filepath, ".tmp"); + strcpy(tmp_filepath + filepath_len, ".tmp"); int result = file_overwrite(tmp_filepath, data, size); if(result != 0) @@ -130,7 +130,7 @@ int file_overwrite_in_dir(const char *dir, const char *filename, const char *dat return rename(tmp_filepath, filepath); } -void path_join(char *output, const char **components, int num_components) { +int path_join(char *output, const char **components, int num_components) { int offset = 0; for(int i = 0; i < num_components; ++i) { if(i > 0) { @@ -143,4 +143,5 @@ void path_join(char *output, const char **components, int num_components) { offset += component_len; } output[offset] = '\0'; + return offset; } -- cgit v1.2.3