diff --git a/Sources/System/Internals/WindowsSyscallAdapters.swift b/Sources/System/Internals/WindowsSyscallAdapters.swift index 3e3f9c6..1e35ee9 100644 --- a/Sources/System/Internals/WindowsSyscallAdapters.swift +++ b/Sources/System/Internals/WindowsSyscallAdapters.swift @@ -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)