From d3173f34e8546a96b8d0df0d9de133f88f10c127 Mon Sep 17 00:00:00 2001 From: Chaoren Lin Date: Fri, 29 May 2015 19:52:29 +0000 Subject: Refactor many file functions to use FileSpec over strings. Summary: This should solve the issue of sending denormalized paths over gdb-remote if we stick to GetPath(false) in GDBRemoteCommunicationClient, and let the server handle any denormalization. Reviewers: ovyalov, zturner, vharron, clayborg Reviewed By: clayborg Subscribers: tberghammer, emaste, lldb-commits Differential Revision: http://reviews.llvm.org/D9728 llvm-svn: 238604 --- lldb/source/Host/common/HostInfoBase.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'lldb/source/Host/common/HostInfoBase.cpp') diff --git a/lldb/source/Host/common/HostInfoBase.cpp b/lldb/source/Host/common/HostInfoBase.cpp index f44ad961653..cd4815a767e 100644 --- a/lldb/source/Host/common/HostInfoBase.cpp +++ b/lldb/source/Host/common/HostInfoBase.cpp @@ -40,7 +40,7 @@ namespace // Remove the LLDB temporary directory if we have one. Set "recurse" to // true to all files that were created for the LLDB process can be cleaned up. - FileSystem::DeleteDirectory(tmpdir_file_spec.GetDirectory().GetCString(), true); + FileSystem::DeleteDirectory(tmpdir_file_spec, true); } //---------------------------------------------------------------------- @@ -326,18 +326,15 @@ HostInfoBase::ComputeProcessTempFileDirectory(FileSpec &file_spec) if (!HostInfo::ComputeGlobalTempFileDirectory(temp_file_spec)) return false; - std::string pid_str; - llvm::raw_string_ostream pid_stream(pid_str); - pid_stream << Host::GetCurrentProcessID(); - temp_file_spec.AppendPathComponent(pid_stream.str().c_str()); - std::string final_path = temp_file_spec.GetPath(); - if (!FileSystem::MakeDirectory(final_path.c_str(), eFilePermissionsDirectoryDefault).Success()) + std::string pid_str{std::to_string(Host::GetCurrentProcessID())}; + temp_file_spec.AppendPathComponent(pid_str); + if (!FileSystem::MakeDirectory(temp_file_spec, eFilePermissionsDirectoryDefault).Success()) return false; // Make an atexit handler to clean up the process specify LLDB temp dir // and all of its contents. ::atexit(CleanupProcessSpecificLLDBTempDir); - file_spec.GetDirectory().SetCStringWithLength(final_path.c_str(), final_path.size()); + file_spec = temp_file_spec; return true; } @@ -370,7 +367,7 @@ HostInfoBase::ComputeGlobalTempFileDirectory(FileSpec &file_spec) return false; temp_file_spec.AppendPathComponent("lldb"); - if (!FileSystem::MakeDirectory(temp_file_spec.GetPath().c_str(), eFilePermissionsDirectoryDefault).Success()) + if (!FileSystem::MakeDirectory(temp_file_spec, eFilePermissionsDirectoryDefault).Success()) return false; file_spec = temp_file_spec; -- cgit v1.2.3