shithub: clone

Download patch

ref: e3fbb4ca9cc4174e8a020b5354e5bfa77bb93d5f
parent: 94d6eed5cfd4c6950d66dca15f6424fcafcc7abc
author: Noam Preil <noam@pixelhero.dev>
date: Fri Nov 24 13:08:57 EST 2023

add verbose flag to print transferred files/dirs

--- a/clone.c
+++ b/clone.c
@@ -43,6 +43,7 @@
 int blksz = Blksz;
 int fileprocs = Nfileprocs;
 int blkprocs = Nblkprocs;
+int verbose = 0;
 long salt;
 Dir *skipdir;
 
@@ -219,6 +220,8 @@
 {
 	int fd;
 	Dir d;
+	if(verbose)
+		print("%s\n", dst);
 	
 	if(!(sd->mode & 0400)){
 		error("can't clone directory: '%s' permission denied", src);
@@ -476,6 +479,8 @@
 			dst = estrdup(f->dst);
 		else
 			dst = smprint("%s.clone.%ld", f->dst, salt);
+		if(verbose)
+			print("%s\n", f->dst);
 		f->dfd = create(dst, OWRITE, f->mode);
 		if(f->dfd < 0){
 			error("can't create: %r");
@@ -499,7 +504,7 @@
 			error("dirfwstat: %r");
 			goto End;
 		}
-		
+
 End:
 		filefree(f);
 		free(dst);
@@ -516,6 +521,9 @@
 
 	salt = time(0);
 	ARGBEGIN{
+	case 'v':
+		verbose++;
+		break;
 	case 'b':
 		blksz = strtol(EARGF(usage()), nil, 0);
 		break;