From d74c8d0d6e0213ded0f3e70a0d0c1dbd833f4fb6 Mon Sep 17 00:00:00 2001 From: "USHIRODA, Atsushi" Date: Thu, 23 Nov 2017 11:02:38 +0900 Subject: [PATCH 1/3] Suppress Duplicate's useless error message --- Duplicate.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Duplicate.c b/Duplicate.c index de5877c..a20d954 100644 --- a/Duplicate.c +++ b/Duplicate.c @@ -151,13 +151,23 @@ int copyFork(const char *src, const char *dest, unsigned fork) fork = fork ? O_RSRC : 0; - rfd = open(src, O_RDONLY | O_BINARY | fork); + rfd = open(src, O_RDONLY | O_BINARY); if (rfd < 0) { fprintf(stderr, "Error opening %s: %s\n", src, strerror(errno)); return -1; } + if (fork) { + close(rfd); + rfd = open(src, O_RDONLY | O_BINARY | fork); + if (rfd < 0) + { + fprintf(stderr, "No resource fork %s\n", src); + return 0; + } + } + // no 3rd parameter to open. wfd = open(dest, O_WRONLY | O_BINARY | O_CREAT |O_TRUNC| fork); if (wfd < 0) @@ -320,7 +330,8 @@ int main(int argc, char **argv) fprintf(stderr, "Error: directory destination is not yet supported.\n"); exit(1); } - if (m == 0 && opts['r' - 'a']) +// if (m == 0 && opts['r' - 'a']) + if (m == 0) { // workaround to create the file if // only copying the resource fork. @@ -374,4 +385,4 @@ int main(int argc, char **argv) } return ok; -} \ No newline at end of file +} From 63bda6b158161012ce44cae1abd48df308401b55 Mon Sep 17 00:00:00 2001 From: "USHIRODA, Atsushi" Date: Thu, 23 Nov 2017 11:11:41 +0900 Subject: [PATCH 2/3] delete debug message --- Duplicate.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Duplicate.c b/Duplicate.c index a20d954..3cc6eb4 100644 --- a/Duplicate.c +++ b/Duplicate.c @@ -163,7 +163,7 @@ int copyFork(const char *src, const char *dest, unsigned fork) rfd = open(src, O_RDONLY | O_BINARY | fork); if (rfd < 0) { - fprintf(stderr, "No resource fork %s\n", src); + // no resource fork return 0; } } @@ -330,8 +330,7 @@ int main(int argc, char **argv) fprintf(stderr, "Error: directory destination is not yet supported.\n"); exit(1); } -// if (m == 0 && opts['r' - 'a']) - if (m == 0) + if (m == 0 && opts['r' - 'a']) { // workaround to create the file if // only copying the resource fork. From c3143ec1e569999c920a4a2b5651e341af35f7a1 Mon Sep 17 00:00:00 2001 From: "USHIRODA, Atsushi" Date: Thu, 23 Nov 2017 13:41:09 +0900 Subject: [PATCH 3/3] Copy the finder info to new file --- Duplicate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Duplicate.c b/Duplicate.c index 3cc6eb4..3914d66 100644 --- a/Duplicate.c +++ b/Duplicate.c @@ -330,7 +330,8 @@ int main(int argc, char **argv) fprintf(stderr, "Error: directory destination is not yet supported.\n"); exit(1); } - if (m == 0 && opts['r' - 'a']) +// if (m == 0 && opts['r' - 'a']) + if (m == 0) { // workaround to create the file if // only copying the resource fork.