Merge pull request #4 from ushicow/issue#1

Issue #3
This commit is contained in:
ksherlock 2017-11-23 11:48:47 -05:00 committed by GitHub
commit 1a9185959f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)
{
// no resource fork
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;
}
}