From 680e132318d6dabaa7f28af33ac7666424a21be3 Mon Sep 17 00:00:00 2001 From: PabloMK7 Date: Fri, 17 Nov 2023 12:14:00 +0100 Subject: [PATCH] Unlock RW access to opened files on windows (#7161) * Unlock RW access to opened files on windows * Add missing include --- src/common/file_util.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index 1d8b2c509d..4b302a893b 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp @@ -24,6 +24,7 @@ // windows.h needs to be included before other windows headers #include // getcwd #include +#include #include #include // for SHGetFolderPath #include @@ -1058,14 +1059,13 @@ bool IOFile::Open() { Close(); #ifdef _WIN32 - if (flags != 0) { - m_file = _wfsopen(Common::UTF8ToUTF16W(filename).c_str(), - Common::UTF8ToUTF16W(openmode).c_str(), flags); - m_good = m_file != nullptr; - } else { - m_good = _wfopen_s(&m_file, Common::UTF8ToUTF16W(filename).c_str(), - Common::UTF8ToUTF16W(openmode).c_str()) == 0; + if (flags == 0) { + flags = _SH_DENYNO; } + m_file = _wfsopen(Common::UTF8ToUTF16W(filename).c_str(), + Common::UTF8ToUTF16W(openmode).c_str(), flags); + m_good = m_file != nullptr; + #elif ANDROID // Check whether filepath is startsWith content AndroidStorage::AndroidOpenMode android_open_mode = AndroidStorage::ParseOpenmode(openmode);