Skip to content

Commit a702cf3

Browse files
authored
Merge pull request #2326 from gmittert/ComeInWereOpen
Fix Flags in NS_open
2 parents 9297b5d + 442a91e commit a702cf3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

CoreFoundation/Base.subproj/CFPlatform.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <Security.h>
3333

3434
#define getcwd _NS_getcwd
35+
#define open _NS_open
3536

3637
#endif
3738

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

902903
DWORD dwCreationDisposition;
903904
switch (oflag & (O_CREAT | O_EXCL | O_TRUNC)) {
905+
case O_CREAT | O_TRUNC:
906+
dwCreationDisposition = CREATE_ALWAYS;
907+
break;
904908
case O_CREAT:
905909
dwCreationDisposition = OPEN_ALWAYS;
906910
break;
@@ -916,7 +920,7 @@ CF_EXPORT int _NS_open(const char *name, int oflag, int pmode) {
916920

917921
// Backup semantics are required to receive a handle to a directory
918922
DWORD dwFlagsAndAttributes = FILE_FLAG_BACKUP_SEMANTICS;
919-
if (pmode & _S_IREAD) {
923+
if (!(pmode & _S_IWRITE)) {
920924
dwFlagsAndAttributes |= FILE_ATTRIBUTE_READONLY;
921925
}
922926

0 commit comments

Comments
 (0)