Merge pull request #14190 from Dentomologist/directiofile_dont_request_delete_access_for_read_only_open

Windows/DirectIOFile: Don't request DELETE access for read-only Open
This commit is contained in:
Jordan Woyak 2025-11-29 16:23:31 -06:00 committed by GitHub
commit 59d5e25f5f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -86,8 +86,11 @@ bool DirectIOFile::Open(const std::string& path, AccessMode access_mode, OpenMod
else if (access_mode == AccessMode::Write)
desired_access = GENERIC_WRITE;
// Allow deleting and renaming through our handle.
desired_access |= DELETE;
if (access_mode != AccessMode::Read)
{
// Allow deleting and renaming through our handle.
desired_access |= DELETE;
}
// All sharing is allowed to more closely match default behavior on other OSes.
constexpr DWORD share_mode = FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE;