Wed, 13 Jan 2016 15:31:10 +0100
added override option for copy/move
dav/main.c | file | annotate | diff | comparison | revisions | |
dav/optparser.c | file | annotate | diff | comparison | revisions | |
libidav/resource.c | file | annotate | diff | comparison | revisions | |
libidav/webdav.h | file | annotate | diff | comparison | revisions |
--- a/dav/main.c Tue Jan 12 19:17:46 2016 +0100 +++ b/dav/main.c Wed Jan 13 15:31:10 2016 +0100 @@ -29,6 +29,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <stdbool.h> #include <errno.h> #include <unistd.h> #include <time.h> @@ -170,6 +171,7 @@ fprintf(stderr, " -a show all files\n"); fprintf(stderr, " -l print resources in long list format\n"); fprintf(stderr, " -t print content type\n"); + fprintf(stderr, " -O override resources\n"); fprintf(stderr, " -n <uri> specify namespace uri\n"); fprintf(stderr, " -v verbose output\n"); fprintf(stderr, "\n"); @@ -947,16 +949,19 @@ return -1; } + DavBool override = cmd_getoption(a, "override") ? true : false; + if(repo1 == repo2) { DavResource *res = dav_resource_new(sn, path1); - int err = cp ? dav_copy(res, path2) : dav_move(res, path2); + int err = cp ? dav_copy_o(res, path2, override) + : dav_move_o(res, path2, override); if(err) { print_resource_error(sn, res->path); fprintf(stderr, "Cannot %s resource.\n", cp ? "copy" : "move"); return -1; } } else { - fprintf(stderr, "Copy or Move not supported for differend hosts.\n"); + fprintf(stderr, "Copy or Move not supported for different hosts.\n"); return -1; }
--- a/dav/optparser.c Tue Jan 12 19:17:46 2016 +0100 +++ b/dav/optparser.c Wed Jan 13 15:31:10 2016 +0100 @@ -101,6 +101,10 @@ ucx_map_cstr_put(a->options, "recursive", NOARG); break; } + case 'O': { + ucx_map_cstr_put(a->options, "override", NOARG); + break; + } case 'o': { if(!option) { option = "output";
--- a/libidav/resource.c Tue Jan 12 19:17:46 2016 +0100 +++ b/libidav/resource.c Wed Jan 13 15:31:10 2016 +0100 @@ -29,6 +29,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <stdbool.h> #include <libxml/tree.h> #include "utils.h" @@ -893,11 +894,19 @@ } int dav_copy(DavResource *res, char *newpath) { - return dav_cp_mv(res, newpath, 1, 0); + return dav_cp_mv(res, newpath, true, false); } int dav_move(DavResource *res, char *newpath) { - return dav_cp_mv(res, newpath, 0, 0); + return dav_cp_mv(res, newpath, false, false); +} + +int dav_copy_o(DavResource *res, char *newpath, DavBool override) { + return dav_cp_mv(res, newpath, true, override); +} + +int dav_move_o(DavResource *res, char *newpath, DavBool override) { + return dav_cp_mv(res, newpath, false, override); }
--- a/libidav/webdav.h Tue Jan 12 19:17:46 2016 +0100 +++ b/libidav/webdav.h Wed Jan 13 15:31:10 2016 +0100 @@ -41,6 +41,8 @@ extern "C" { #endif +typedef int DavBool; + typedef struct DavContext DavContext; typedef struct DavProxy DavProxy; typedef struct DavSession DavSession; @@ -224,6 +226,8 @@ int dav_copy(DavResource *res, char *newpath); int dav_move(DavResource *res, char *newpath); +int dav_copy_o(DavResource *res, char *newpath, DavBool override); +int dav_move_o(DavResource *res, char *newpath, DavBool override); char* dav_get_property(DavResource *res, char *name); char* dav_get_property_ns(DavResource *res, char *ns, char *name);