# HG changeset patch # User Olaf Wintermann # Date 1528629724 -7200 # Node ID dc74f736aea155d3856e85e68af880e47fe2cb87 # Parent a182e503617ba8202429f80c194f79b209e1202b adds more fs abstraction diff -r a182e503617b -r dc74f736aea1 dav/main.c --- a/dav/main.c Sun Jun 10 12:35:00 2018 +0200 +++ b/dav/main.c Sun Jun 10 13:22:04 2018 +0200 @@ -878,8 +878,7 @@ if(res->iscollection) { printf("get: %s\n", res->path); - mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; - int ret = util_mkdir(out, mode); + int ret = sys_mkdir(out); if(ret != 0 && errno != EEXIST) { fprintf(stderr, "Cannot create directory '%s': ", out); perror(""); diff -r a182e503617b -r dc74f736aea1 dav/sync.c --- a/dav/sync.c Sun Jun 10 12:35:00 2018 +0200 +++ b/dav/sync.c Sun Jun 10 13:22:04 2018 +0200 @@ -345,7 +345,6 @@ fprintf(stderr, "Too %s arguments\n", a->argc < 1 ? "few" : "many"); return -1; } - // if there are syntax errors in the command line, fail asap. SyncTagFilter* tagfilter = parse_tagfilter_string(cmd_getoption(a, "tags")); if (!tagfilter) { @@ -661,8 +660,7 @@ int ret = 0; char *tmp_path = create_tmp_download_path(local_path); if(res->iscollection) { - mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; - if(util_mkdir(local_path, mode) && errno != EEXIST) { + if(sys_mkdir(local_path) && errno != EEXIST) { ret = -1; } @@ -741,7 +739,7 @@ local->size = s.st_size; local->skipped = FALSE; } else { - if(unlink(tmp_path)) { + if(sys_unlink(tmp_path)) { fprintf(stderr, "Cannot remove tmp file: %s\n", tmp_path); } } @@ -774,7 +772,7 @@ int ret = 0; if(dir->trash) { move_to_trash(dir, local_path); - } else if(unlink(local_path)) { + } else if(sys_unlink(local_path)) { fprintf(stderr, "Cannot remove file %s\n", local_path); ret = -2; } @@ -1999,7 +1997,7 @@ UCX_MAP_FOREACH(key, res, i) { printf("delete: %s\n", res->path); char *path = util_concat_path(dir->path, res->path); - if(unlink(path)) { + if(sys_unlink(path)) { if(errno != ENOENT) { perror("unlink"); num_err++; @@ -2204,7 +2202,7 @@ perror("rmdir"); } } else { - if(unlink(path)) { + if(sys_unlink(path)) { perror("unlink"); } } diff -r a182e503617b -r dc74f736aea1 dav/system.c --- a/dav/system.c Sun Jun 10 12:35:00 2018 +0200 +++ b/dav/system.c Sun Jun 10 13:22:04 2018 +0200 @@ -89,6 +89,12 @@ return rename(oldpath, newpath); } +int sys_unlink(const char *path) { + return unlink(path); +} + +int sys_mkdir(const char *path) { + return mkdir(path, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); #else /* ---------- Windows implementation ---------- */ @@ -215,7 +221,7 @@ int sys_rename(const char *oldpath, const char *newpath) { wchar_t *o = path2winpath(oldpath, FALSE, NULL); - wchara_t *n = path2winpath(newpath, FALSE, NULL); + wchar_t *n = path2winpath(newpath, FALSE, NULL); if(!o || !n) { return -1; } @@ -233,4 +239,26 @@ return ret; } +int sys_unlink(const char *path) { + wchar_t *wpath = path2winpath(path, FALSE, NULL); + if(!wpath) { + fprintf(stderr, "sys_unlink: cannot convert path\n"); + return -1; + } + int ret = _wunlink(wpath); + free(wpath); + return ret; +} + +int sys_mkdir(const char *path) { + wchar_t *wpath = path2winpath(path, FALSE, NULL); + if(!wpath) { + fprintf(stderr, "sys_mkdir: cannot convert path\n"); + return -1; + } + int ret = _wmkdir(wpath); + free(wpath); + return ret; +} + #endif \ No newline at end of file diff -r a182e503617b -r dc74f736aea1 dav/system.h --- a/dav/system.h Sun Jun 10 12:35:00 2018 +0200 +++ b/dav/system.h Sun Jun 10 13:22:04 2018 +0200 @@ -78,6 +78,8 @@ int sys_stat(const char *path, SYS_STAT *s); int sys_rename(const char *oldpath, const char *newpath); +int sys_unlink(const char *path); +int sys_mkdir(const char *path); #ifdef __cplusplus } diff -r a182e503617b -r dc74f736aea1 dav/version.h --- a/dav/version.h Sun Jun 10 12:35:00 2018 +0200 +++ b/dav/version.h Sun Jun 10 13:22:04 2018 +0200 @@ -27,6 +27,6 @@ */ #ifndef DAV_VERSION -#define DAV_VERSION "1.2 RC2" +#define DAV_VERSION "1.2 RC3" #endif diff -r a182e503617b -r dc74f736aea1 mingw.mk --- a/mingw.mk Sun Jun 10 12:35:00 2018 +0200 +++ b/mingw.mk Sun Jun 10 13:22:04 2018 +0200 @@ -31,7 +31,7 @@ AR = ar RM = rm -CFLAGS = -std=gnu99 -O2 -c +CFLAGS = -std=gnu99 -g -c COFLAGS = -o LDFLAGS = LOFLAGS = -o