Browse Source

Merge pull request #1688 from bkrypt/fix_file_windows_open_create_append_order

os/file_windows: Fix "create or append" file open behavior
gingerBill 3 years ago
parent
commit
a4d2ff05a9
1 changed files with 3 additions and 3 deletions
  1. 3 3
      core/os/file_windows.odin

+ 3 - 3
core/os/file_windows.odin

@@ -20,13 +20,13 @@ open :: proc(path: string, mode: int = O_RDONLY, perm: int = 0) -> (Handle, Errn
 	case O_RDWR:   access = win32.FILE_GENERIC_READ | win32.FILE_GENERIC_WRITE
 	}
 
+	if mode&O_CREATE != 0 {
+		access |= win32.FILE_GENERIC_WRITE
+	}
 	if mode&O_APPEND != 0 {
 		access &~= win32.FILE_GENERIC_WRITE
 		access |=  win32.FILE_APPEND_DATA
 	}
-	if mode&O_CREATE != 0 {
-		access |= win32.FILE_GENERIC_WRITE
-	}
 
 	share_mode := win32.FILE_SHARE_READ|win32.FILE_SHARE_WRITE
 	sa: ^win32.SECURITY_ATTRIBUTES = nil