summaryrefslogtreecommitdiffstats
path: root/drivers/windows
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2024-09-11 09:44:53 +0300
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2024-09-11 09:48:09 +0300
commite16f8bae2e5779b48b92298f677e0bdee45c7445 (patch)
tree3930cbb7092cb3ce995b45b01c6a6801fc42dd7c /drivers/windows
parent97ef3c837263099faf02d8ebafd6c77c94d2aaba (diff)
downloadredot-engine-e16f8bae2e5779b48b92298f677e0bdee45c7445.tar.gz
[Windows] Remove _wstat use in FileAccessWindows::open_internal
Diffstat (limited to 'drivers/windows')
-rw-r--r--drivers/windows/file_access_windows.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp
index 0243d863f8..43a9f61749 100644
--- a/drivers/windows/file_access_windows.cpp
+++ b/drivers/windows/file_access_windows.cpp
@@ -118,11 +118,12 @@ Error FileAccessWindows::open_internal(const String &p_path, int p_mode_flags) {
return ERR_INVALID_PARAMETER;
}
- struct _stat st;
- if (_wstat((LPCWSTR)(path.utf16().get_data()), &st) == 0) {
- if (!S_ISREG(st.st_mode)) {
- return ERR_FILE_CANT_OPEN;
- }
+ if (path.ends_with(":\\") || path.ends_with(":")) {
+ return ERR_FILE_CANT_OPEN;
+ }
+ DWORD file_attr = GetFileAttributesW((LPCWSTR)(path.utf16().get_data()));
+ if (file_attr != INVALID_FILE_ATTRIBUTES && (file_attr & FILE_ATTRIBUTE_DIRECTORY)) {
+ return ERR_FILE_CANT_OPEN;
}
#ifdef TOOLS_ENABLED