diff --git a/native/SunOS.cpp b/native/SunOS.cpp index 83a498b..3c0802c 100644 --- a/native/SunOS.cpp +++ b/native/SunOS.cpp @@ -203,9 +203,11 @@ namespace native { int open_resource_fork(const std::string &path_name, int oflag) { - - // should create if it doesn't exist... - if ((oflag & O_ACCMODE) & O_WRONLY) oflag |= O_CREAT; + /* under HFS, every file has a resource fork. + * Therefore, create it if opening for O_RDWR or O_WRONLY + */ + int mode = oflag & O_ACCMODE; + if (mode == O_WRONLY || mode == O_RDWR) oflag |= O_CREAT; return attropen(path_name.c_str(), XATTR_RESOURCEFORK_NAME, oflag, 0666); }