Merge branch 'master' of github.com:ksherlock/mpw-tools

This commit is contained in:
Kelvin Sherlock 2018-07-30 20:28:01 -04:00
commit 58c8cb758e
1 changed files with 14 additions and 3 deletions

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;
}
}