From cd31fff8b308d054bec45ca0c7791e546052837c Mon Sep 17 00:00:00 2001 From: tobil4sk Date: Thu, 7 Mar 2024 18:12:41 +0000 Subject: [PATCH] Make sys_read_dir errors consistent between platforms Haxe documentation specifies that an exception should be thrown if the path is not a valid directory. This was already the case on all platforms except Windows, where `null` was returned. Now the behavior is consistent. --- src/hx/libs/std/Sys.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hx/libs/std/Sys.cpp b/src/hx/libs/std/Sys.cpp index 30ad2e29c..371addf93 100644 --- a/src/hx/libs/std/Sys.cpp +++ b/src/hx/libs/std/Sys.cpp @@ -669,7 +669,7 @@ Array _hx_std_sys_read_dir( String p ) const wchar_t *path = p.wchar_str(); size_t len = wcslen(path); if (len>MAX_PATH) - return null(); + hx::Throw(HX_CSTRING("Invalid directory")); WIN32_FIND_DATAW d; HANDLE handle; @@ -698,7 +698,7 @@ Array _hx_std_sys_read_dir( String p ) if( handle == INVALID_HANDLE_VALUE ) { hx::ExitGCFreeZone(); - return null(); + hx::Throw(HX_CSTRING("Invalid directory")); } while( true ) {