ref: 7da6f37d933dcf4d3d053d809ce02bf2683cb9a8
parent: fa1d72ac469051740db03ba97377bdd4465cb480
author: Noam Preil <noam@pixelhero.dev>
date: Fri Nov 24 13:14:34 EST 2023
add flag to skip existing files
--- a/clone.c
+++ b/clone.c
@@ -37,6 +37,7 @@
int multisrc = 0;
int keepmode = 0;
int keepmtime = 0;
+int skipexisting = 0;
int keepuser = 0;
int keepgroup = 0;
int notemp = 0;
@@ -470,6 +471,7 @@
char *dst;
Dir d;
File *f;
+ int fd;
Waitgroup *wg;
threadsetname("fileproc");
@@ -480,6 +482,15 @@
if(f == nil)
break;
+ if(skipexisting){
+ fd = open(f->dst, OREAD);
+ if(fd >= 0){
+ close(fd);
+ filefree(f);
+ continue;
+ }
+ }
+
dst = nil;
f->sfd = open(f->src, OREAD);
if(f->sfd < 0){
@@ -537,6 +548,9 @@
ARGBEGIN{
case 'v':
verbose++;
+ break;
+ case 'n':
+ skipexisting++;
break;
case 'd':
dummy++;