Possible fix for failing to create files.

This commit is contained in:
Ben Vanik 2015-12-29 11:02:28 -08:00
parent 214957da3a
commit 5019f1aa98
1 changed files with 4 additions and 4 deletions

View File

@ -115,7 +115,7 @@ std::unique_ptr<FileHandle> FileHandle::OpenExisting(std::wstring path,
open_access |= GENERIC_EXECUTE; open_access |= GENERIC_EXECUTE;
} }
if (desired_access & FileAccess::kGenericAll) { if (desired_access & FileAccess::kGenericAll) {
open_access |= GENERIC_ALL; open_access |= GENERIC_READ | GENERIC_WRITE;
} }
if (desired_access & FileAccess::kFileReadData) { if (desired_access & FileAccess::kFileReadData) {
open_access |= FILE_READ_DATA; open_access |= FILE_READ_DATA;
@ -126,12 +126,12 @@ std::unique_ptr<FileHandle> FileHandle::OpenExisting(std::wstring path,
if (desired_access & FileAccess::kFileAppendData) { if (desired_access & FileAccess::kFileAppendData) {
open_access |= FILE_APPEND_DATA; open_access |= FILE_APPEND_DATA;
} }
DWORD share_mode = FILE_SHARE_READ; DWORD share_mode = FILE_SHARE_READ | FILE_SHARE_WRITE;
// We assume we've already created the file in the caller. // We assume we've already created the file in the caller.
DWORD creation_disposition = OPEN_EXISTING; DWORD creation_disposition = OPEN_EXISTING;
HANDLE handle = HANDLE handle =
CreateFileW(path.c_str(), open_access, share_mode, NULL, CreateFileW(path.c_str(), open_access, share_mode, nullptr,
creation_disposition, FILE_FLAG_BACKUP_SEMANTICS, NULL); creation_disposition, FILE_ATTRIBUTE_NORMAL, nullptr);
if (handle == INVALID_HANDLE_VALUE) { if (handle == INVALID_HANDLE_VALUE) {
// TODO(benvanik): pick correct response. // TODO(benvanik): pick correct response.
return nullptr; return nullptr;