From 03736d8bcb7e376e6d26071e2aca38566e17e203 Mon Sep 17 00:00:00 2001 From: flysand7 Date: Thu, 25 Jan 2024 20:52:39 +1100 Subject: [PATCH 1/3] sys/windows: Make INVALID_FILE_ATTRIBUTES a u32 constant --- core/sys/windows/types.odin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/sys/windows/types.odin b/core/sys/windows/types.odin index 6dbf6d523..37f953c58 100644 --- a/core/sys/windows/types.odin +++ b/core/sys/windows/types.odin @@ -2176,7 +2176,7 @@ WC_ERR_INVALID_CHARS :: 128 MAX_PATH :: 0x00000104 MAX_PATH_WIDE :: 0x8000 -INVALID_FILE_ATTRIBUTES :: -1 +INVALID_FILE_ATTRIBUTES :: DWORD(0xffff_ffff) FILE_TYPE_DISK :: 0x0001 FILE_TYPE_CHAR :: 0x0002 From af636eedde57c4c891dff7344063253b268404f3 Mon Sep 17 00:00:00 2001 From: flysand7 Date: Thu, 25 Jan 2024 21:32:10 +1100 Subject: [PATCH 2/3] os: Fix casting errors in other files --- core/os/file_windows.odin | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/os/file_windows.odin b/core/os/file_windows.odin index 0b0baeea3..96f6d8e8f 100644 --- a/core/os/file_windows.odin +++ b/core/os/file_windows.odin @@ -349,7 +349,7 @@ exists :: proc(path: string) -> bool { wpath := win32.utf8_to_wstring(path, context.temp_allocator) attribs := win32.GetFileAttributesW(wpath) - return i32(attribs) != win32.INVALID_FILE_ATTRIBUTES + return attribs != win32.INVALID_FILE_ATTRIBUTES } is_file :: proc(path: string) -> bool { @@ -357,7 +357,7 @@ is_file :: proc(path: string) -> bool { wpath := win32.utf8_to_wstring(path, context.temp_allocator) attribs := win32.GetFileAttributesW(wpath) - if i32(attribs) != win32.INVALID_FILE_ATTRIBUTES { + if attribs != win32.INVALID_FILE_ATTRIBUTES { return attribs & win32.FILE_ATTRIBUTE_DIRECTORY == 0 } return false @@ -368,7 +368,7 @@ is_dir :: proc(path: string) -> bool { wpath := win32.utf8_to_wstring(path, context.temp_allocator) attribs := win32.GetFileAttributesW(wpath) - if i32(attribs) != win32.INVALID_FILE_ATTRIBUTES { + if attribs != win32.INVALID_FILE_ATTRIBUTES { return attribs & win32.FILE_ATTRIBUTE_DIRECTORY != 0 } return false From d5b0ec712beaa8ffb5cce4b6ea655048c4af8d1f Mon Sep 17 00:00:00 2001 From: flysand7 Date: Fri, 26 Jan 2024 09:07:12 +1100 Subject: [PATCH 3/3] os/os2: Remove file attribute casting from core:os2 --- core/os/os2/file_windows.odin | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/os/os2/file_windows.odin b/core/os/os2/file_windows.odin index 600ecde21..7c31defe9 100644 --- a/core/os/os2/file_windows.odin +++ b/core/os/os2/file_windows.odin @@ -454,7 +454,7 @@ _remove :: proc(name: string) -> Error { if err != err1 { a := win32.GetFileAttributesW(p) - if a == ~u32(0) { + if a == win32.INVALID_FILE_ATTRIBUTES { err = _get_platform_error() } else { if a & win32.FILE_ATTRIBUTE_DIRECTORY != 0 { @@ -704,13 +704,13 @@ _fchtimes :: proc(f: ^File, atime, mtime: time.Time) -> Error { _exists :: proc(path: string) -> bool { wpath := _fix_long_path(path) attribs := win32.GetFileAttributesW(wpath) - return i32(attribs) != win32.INVALID_FILE_ATTRIBUTES + return attribs != win32.INVALID_FILE_ATTRIBUTES } _is_file :: proc(path: string) -> bool { wpath := _fix_long_path(path) attribs := win32.GetFileAttributesW(wpath) - if i32(attribs) != win32.INVALID_FILE_ATTRIBUTES { + if attribs != win32.INVALID_FILE_ATTRIBUTES { return attribs & win32.FILE_ATTRIBUTE_DIRECTORY == 0 } return false @@ -719,7 +719,7 @@ _is_file :: proc(path: string) -> bool { _is_dir :: proc(path: string) -> bool { wpath := _fix_long_path(path) attribs := win32.GetFileAttributesW(wpath) - if i32(attribs) != win32.INVALID_FILE_ATTRIBUTES { + if attribs != win32.INVALID_FILE_ATTRIBUTES { return attribs & win32.FILE_ATTRIBUTE_DIRECTORY != 0 } return false