From 1732888777dd8aa8f59e31c4b790765fdcfd917c Mon Sep 17 00:00:00 2001 From: Yufeng Ying Date: Sat, 11 Jan 2025 21:21:18 +0800 Subject: [PATCH] Don't open file in file_exists for Windows. --- drivers/windows/file_access_windows.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp index 062dd87aff8..b2796e4e67b 100644 --- a/drivers/windows/file_access_windows.cpp +++ b/drivers/windows/file_access_windows.cpp @@ -402,13 +402,8 @@ bool FileAccessWindows::file_exists(const String &p_name) { } String filename = fix_path(p_name); - FILE *g = _wfsopen((LPCWSTR)(filename.utf16().get_data()), L"rb", _SH_DENYNO); - if (g == nullptr) { - return false; - } else { - fclose(g); - return true; - } + DWORD file_attr = GetFileAttributesW((LPCWSTR)(filename.utf16().get_data())); + return (file_attr != INVALID_FILE_ATTRIBUTES) && !(file_attr & FILE_ATTRIBUTE_DIRECTORY); } uint64_t FileAccessWindows::_get_modified_time(const String &p_file) {