diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-09-11 12:34:28 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-09-11 12:34:28 +0200 |
commit | e9194702a3b4aa58c397f630eecb4118c15b9365 (patch) | |
tree | 4f998dac222e8a4ca0a7bdab561036aa2b81d302 | |
parent | 6162312f22d2647affd041056866deb50c5f3bfb (diff) | |
parent | e16f8bae2e5779b48b92298f677e0bdee45c7445 (diff) | |
download | redot-engine-e9194702a3b4aa58c397f630eecb4118c15b9365.tar.gz |
Merge pull request #96840 from bruvzg/open_wstat
[Windows] Remove `_wstat` use in `FileAccessWindows::open_internal`
-rw-r--r-- | drivers/windows/file_access_windows.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp index e07d26002e..9d6aa13332 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 |