From 119d9aab57af413f1691adcc0e6caca639edb52c Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Mon, 2 Oct 2017 16:31:33 -0400 Subject: [PATCH] APFS - when opening a resource fork as rdwr, create it as well -- Under HFS, empty resource fork always exists. on APFS, it must be specifically created. --- toolbox/os_internal.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/toolbox/os_internal.cpp b/toolbox/os_internal.cpp index 8b646f0..27b9394 100644 --- a/toolbox/os_internal.cpp +++ b/toolbox/os_internal.cpp @@ -548,12 +548,21 @@ namespace OS { namespace Internal { } std::string xname = filename; - if (fork) + if (fork) { xname.append(_PATH_RSRCFORKSPEC); + // O_RDWR should also O_CREAT + } Log(" open(%s, %04x)\n", xname.c_str(), access); fd = ::open(xname.c_str(), access); + + if (fd < 0 && access == O_RDWR && errno == ENOENT && fork) + { + fd = ::open(xname.c_str(), O_RDWR | O_CREAT, 0666); + } + + if (fd < 0 && ioPermission == fsCurPerm && errno == EACCES) { fd = ::open(xname.c_str(), O_RDONLY);