Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Windows] Remove _wstat use in FileAccessWindows::open_internal #96840

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions drivers/windows/file_access_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(":")) {
Copy link
Member Author

@bruvzg bruvzg Sep 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: for whatever reason, drive root is not FILE_ATTRIBUTE_DIRECTORY.

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
Expand Down
Loading