diff options
Diffstat (limited to 'lldb/tools/lldb-mi/MIUtilFileStd.cpp')
-rw-r--r-- | lldb/tools/lldb-mi/MIUtilFileStd.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lldb/tools/lldb-mi/MIUtilFileStd.cpp b/lldb/tools/lldb-mi/MIUtilFileStd.cpp index 9e5d10d6ba3..69730204a00 100644 --- a/lldb/tools/lldb-mi/MIUtilFileStd.cpp +++ b/lldb/tools/lldb-mi/MIUtilFileStd.cpp @@ -14,8 +14,11 @@ #include <cerrno> // In-house headers: -#include "MIUtilFileStd.h" #include "MICmnResources.h" +#include "MIUtilFileStd.h" +#include "lldb/Host/FileSystem.h" + +#include "llvm/Support/ConvertUTF.h" //++ ------------------------------------------------------------------------------------ // Details: CMIUtilFileStd constructor. @@ -82,7 +85,14 @@ CMIUtilFileStd::CreateWrite(const CMIUtilString &vFileNamePath, bool &vwrbNewCre m_pFileHandle = ::fopen(vFileNamePath.c_str(), "wb"); #else // Open a file with exclusive write and shared read permissions - m_pFileHandle = ::_fsopen(vFileNamePath.c_str(), "wb", _SH_DENYWR); + std::wstring path; + if (llvm::ConvertUTF8toWide(vFileNamePath.c_str(), path)) + m_pFileHandle = ::_wfsopen(path.c_str(), L"wb", _SH_DENYWR); + else + { + errno = EINVAL; + m_pFileHandle = nullptr; + } #endif // !defined( _MSC_VER ) if (m_pFileHandle == nullptr) @@ -221,8 +231,7 @@ CMIUtilFileStd::IsFileExist(const CMIUtilString &vFileNamePath) const if (vFileNamePath.empty()) return false; - FILE *pTmp = nullptr; - pTmp = ::fopen(vFileNamePath.c_str(), "wb"); + FILE *pTmp = lldb_private::FileSystem::Fopen(vFileNamePath.c_str(), "wb"); if (pTmp != nullptr) { ::fclose(pTmp); |