From a07878be71aef8e59acadf01f0f18931ad382f6b Mon Sep 17 00:00:00 2001 From: Feoramund <161657516+Feoramund@users.noreply.github.com> Date: Fri, 16 Aug 2024 14:03:56 -0400 Subject: [PATCH] Check if file open-mode is `O_CREATE` on Darwin before forcing chmod Fixes #4087 --- core/os/os_darwin.odin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/os/os_darwin.odin b/core/os/os_darwin.odin index 940c0294e..602257314 100644 --- a/core/os/os_darwin.odin +++ b/core/os/os_darwin.odin @@ -702,7 +702,7 @@ open :: proc(path: string, flags: int = O_RDWR, mode: int = 0) -> (handle: Handl @INFO(Platin): this is only done because O_CREATE for some reason fails to apply mode should not happen if the handle is a directory */ - if mode != 0 && !isDir { + if flags & O_CREATE != 0 && mode != 0 && !isDir { err = fchmod(handle, cast(u16)mode) if err != nil { _unix_close(handle)