Skip to content

Commit 5877f94

Browse files
committed
Merge pull request godotengine#101431 from YYF233333/remote_tree_fix
Use `GetFileAttributesW` for checking file existence on Windows
2 parents 06a49a9 + 1732888 commit 5877f94

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

drivers/windows/file_access_windows.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -402,13 +402,8 @@ bool FileAccessWindows::file_exists(const String &p_name) {
402402
}
403403

404404
String filename = fix_path(p_name);
405-
FILE *g = _wfsopen((LPCWSTR)(filename.utf16().get_data()), L"rb", _SH_DENYNO);
406-
if (g == nullptr) {
407-
return false;
408-
} else {
409-
fclose(g);
410-
return true;
411-
}
405+
DWORD file_attr = GetFileAttributesW((LPCWSTR)(filename.utf16().get_data()));
406+
return (file_attr != INVALID_FILE_ATTRIBUTES) && !(file_attr & FILE_ATTRIBUTE_DIRECTORY);
412407
}
413408

414409
uint64_t FileAccessWindows::_get_modified_time(const String &p_file) {

0 commit comments

Comments
 (0)