[Windows] Fix a problem with opening files read only.

`_O_RDONLY` is zero, so we can't test for it by AND-ing.
This commit is contained in:
Alastair Houghton authored and Guillaume Lessard committed 2024-10-14 16:01:01 -07:00
1 parent f1d7eb52c6
commit 53471ce33b
1 file changed
+6 -5
@@ -621,14 +621,15 @@ fileprivate struct DecodedOpenFlags {
}
dwDesiredAccess = 0
if (oflag & _O_RDONLY) != 0 {
switch (oflag & (_O_RDONLY|_O_WRONLY|_O_RDWR)) {
case _O_RDONLY:
dwDesiredAccess |= DWORD(GENERIC_READ)
}
if (oflag & _O_WRONLY) != 0 {
case _O_WRONLY:
dwDesiredAccess |= DWORD(GENERIC_WRITE)
}
if (oflag & _O_RDWR) != 0 {
case _O_RDWR:
dwDesiredAccess |= DWORD(GENERIC_READ) | DWORD(GENERIC_WRITE)
default:
break
}
bInheritHandle = WindowsBool((oflag & _O_NOINHERIT) == 0)