diff options
author | Zachary Turner <zturner@google.com> | 2016-03-22 17:58:09 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2016-03-22 17:58:09 +0000 |
commit | 190fadcdb245707011e31b69a24bd6bba7c93ab5 (patch) | |
tree | 4448dbd3327aa3e5244a448d70ceb1b7a2f45be1 /lldb/tools/lldb-mi/MIUtilFileStd.cpp | |
parent | 6feeb6554e271e308238750078b178ff1e83c15c (diff) | |
download | bcm5719-llvm-190fadcdb245707011e31b69a24bd6bba7c93ab5.tar.gz bcm5719-llvm-190fadcdb245707011e31b69a24bd6bba7c93ab5.zip |
Unicode support on Win32.
Win32 API calls that are Unicode aware require wide character
strings, but LLDB uses UTF8 everywhere. This patch does conversions
wherever necessary when passing strings into and out of Win32 API
calls.
Patch by Cameron
Differential Revision: http://reviews.llvm.org/D17107
Reviewed By: zturner, amccarth
llvm-svn: 264074
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); |