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.
This commit is contained in:
Kelvin Sherlock 2017-10-02 16:31:33 -04:00
parent 60b49a1ff4
commit 119d9aab57

View File

@ -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);