Closed leidegre closed 1 month ago
According to the documentation the return value of FindFirstFileW is INVALID_HANDLE_VALUE not nil.
FindFirstFileW
INVALID_HANDLE_VALUE
nil
https://github.com/odin-lang/Odin/blob/575e5a255b98727c304cf6a23fbb8f235c6eaa7f/core/os/dir_windows.odin#L89-L91
This be seen in other places in the Odin source tree. For example,
https://github.com/odin-lang/Odin/blob/575e5a255b98727c304cf6a23fbb8f235c6eaa7f/core/os/stat_windows.odin#L55-L59
It's unclear what the purpose of this find_handle != nil check, since find_handle is not written to within the loop body.
find_handle != nil
find_handle
I'd consider inserting,
if find_handle == win32.INVALID_HANDLE_VALUE { e = Errno(win32.GetLastError()) return }
...between the call to FindFirstFileW and defer win32.FindClose(find_handle) and removing the find_handle != nil check.
defer win32.FindClose(find_handle)
According to the documentation the return value of
FindFirstFileW
isINVALID_HANDLE_VALUE
notnil
.https://github.com/odin-lang/Odin/blob/575e5a255b98727c304cf6a23fbb8f235c6eaa7f/core/os/dir_windows.odin#L89-L91
This be seen in other places in the Odin source tree. For example,
https://github.com/odin-lang/Odin/blob/575e5a255b98727c304cf6a23fbb8f235c6eaa7f/core/os/stat_windows.odin#L55-L59
It's unclear what the purpose of this
find_handle != nil
check, sincefind_handle
is not written to within the loop body.I'd consider inserting,
...between the call to
FindFirstFileW
anddefer win32.FindClose(find_handle)
and removing thefind_handle != nil
check.