summaryrefslogtreecommitdiffstats
path: root/lldb/tools/lldb-server/lldb-platform.cpp
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2017-03-21 13:49:50 +0000
committerPavel Labath <labath@google.com>2017-03-21 13:49:50 +0000
commite3ad2e2e73983966b5b84293a0f501e409abddde (patch)
tree9f93fdc91eb2c2526205fa54c3c148b5035b5e10 /lldb/tools/lldb-server/lldb-platform.cpp
parent15930862327b0d7120ea4b89ea2a173554db8b90 (diff)
downloadbcm5719-llvm-e3ad2e2e73983966b5b84293a0f501e409abddde.tar.gz
bcm5719-llvm-e3ad2e2e73983966b5b84293a0f501e409abddde.zip
Replace std::ofstream with llvm::raw_fd_ostream
Summary: ofstream does not handle paths with non-ascii characters correctly on windows, so I am switching these to llvm streams to fix that. Reviewers: zturner, eugene Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D31079 llvm-svn: 298375
Diffstat (limited to 'lldb/tools/lldb-server/lldb-platform.cpp')
-rw-r--r--lldb/tools/lldb-server/lldb-platform.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/lldb/tools/lldb-server/lldb-platform.cpp b/lldb/tools/lldb-server/lldb-platform.cpp
index 3da3c09a90d..11fbcfe9818 100644
--- a/lldb/tools/lldb-server/lldb-platform.cpp
+++ b/lldb/tools/lldb-server/lldb-platform.cpp
@@ -106,23 +106,25 @@ static Error save_socket_id_to_file(const std::string &socket_id,
return Error("Failed to create directory %s: %s",
temp_file_spec.GetCString(), error.AsCString());
- llvm::SmallString<PATH_MAX> temp_file_path;
+ llvm::SmallString<64> temp_file_path;
temp_file_spec.AppendPathComponent("port-file.%%%%%%");
- auto err_code = llvm::sys::fs::createUniqueFile(temp_file_spec.GetCString(),
+ int FD;
+ auto err_code = llvm::sys::fs::createUniqueFile(temp_file_spec.GetPath(), FD,
temp_file_path);
if (err_code)
return Error("Failed to create temp file: %s", err_code.message().c_str());
- llvm::FileRemover tmp_file_remover(temp_file_path.c_str());
+ llvm::FileRemover tmp_file_remover(temp_file_path);
{
- std::ofstream temp_file(temp_file_path.c_str(), std::ios::out);
- if (!temp_file.is_open())
- return Error("Failed to open temp file %s", temp_file_path.c_str());
+ llvm::raw_fd_ostream temp_file(FD, true);
temp_file << socket_id;
+ temp_file.close();
+ if (temp_file.has_error())
+ return Error("Failed to write to port file.");
}
- err_code = llvm::sys::fs::rename(temp_file_path.c_str(), file_spec.GetPath());
+ err_code = llvm::sys::fs::rename(temp_file_path, file_spec.GetPath());
if (err_code)
return Error("Failed to rename file %s to %s: %s", temp_file_path.c_str(),
file_spec.GetPath().c_str(), err_code.message().c_str());
OpenPOWER on IntegriCloud