Skip to content

Commit

Permalink
Merge pull request swiftlang#2326 from gmittert/ComeInWereOpen
Browse files Browse the repository at this point in the history
Fix Flags in NS_open
  • Loading branch information
millenomi authored Jun 11, 2019
2 parents 9297b5d + 442a91e commit a702cf3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion CoreFoundation/Base.subproj/CFPlatform.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <Security.h>

#define getcwd _NS_getcwd
#define open _NS_open

#endif

Expand Down Expand Up @@ -901,6 +902,9 @@ CF_EXPORT int _NS_open(const char *name, int oflag, int pmode) {

DWORD dwCreationDisposition;
switch (oflag & (O_CREAT | O_EXCL | O_TRUNC)) {
case O_CREAT | O_TRUNC:
dwCreationDisposition = CREATE_ALWAYS;
break;
case O_CREAT:
dwCreationDisposition = OPEN_ALWAYS;
break;
Expand All @@ -916,7 +920,7 @@ CF_EXPORT int _NS_open(const char *name, int oflag, int pmode) {

// Backup semantics are required to receive a handle to a directory
DWORD dwFlagsAndAttributes = FILE_FLAG_BACKUP_SEMANTICS;
if (pmode & _S_IREAD) {
if (!(pmode & _S_IWRITE)) {
dwFlagsAndAttributes |= FILE_ATTRIBUTE_READONLY;
}

Expand Down

0 comments on commit a702cf3

Please sign in to comment.