diff --git a/lldb/source/Host/common/HostInfoBase.cpp b/lldb/source/Host/common/HostInfoBase.cpp index 39aca23ec87b..f2d1c525e298 100644 --- a/lldb/source/Host/common/HostInfoBase.cpp +++ b/lldb/source/Host/common/HostInfoBase.cpp @@ -228,7 +228,7 @@ HostInfoBase::ComputeSharedLibraryDirectory(FileSpec &file_spec) Host::GetModuleFileSpecForHostAddress(reinterpret_cast(reinterpret_cast(HostInfoBase::GetLLDBPath)))); // Remove the filename so that this FileSpec only represents the directory. - file_spec.SetFile(lldb_file_spec.GetDirectory().AsCString(), true); + file_spec.GetDirectory() = lldb_file_spec.GetDirectory(); return (bool)file_spec.GetDirectory(); } @@ -264,7 +264,7 @@ HostInfoBase::ComputeTempFileDirectory(FileSpec &file_spec) // Make an atexit handler to clean up the process specify LLDB temp dir // and all of its contents. ::atexit(CleanupProcessSpecificLLDBTempDir); - file_spec.SetFile(pid_tmpdir.GetString().c_str(), false); + file_spec.GetDirectory().SetCStringWithLength(pid_tmpdir.GetString().c_str(), pid_tmpdir.GetString().size()); return true; } diff --git a/lldb/source/Host/linux/HostInfoLinux.cpp b/lldb/source/Host/linux/HostInfoLinux.cpp index 6b4923882b22..6d55c503a0f0 100644 --- a/lldb/source/Host/linux/HostInfoLinux.cpp +++ b/lldb/source/Host/linux/HostInfoLinux.cpp @@ -194,7 +194,8 @@ HostInfoLinux::GetProgramFileSpec() bool HostInfoLinux::ComputeSystemPluginsDirectory(FileSpec &file_spec) { - file_spec.SetFile("/usr/lib/lldb", true); + FileSpec temp_file("/usr/lib/lldb", true); + file_spec.GetDirectory().SetCString(temp_file.GetPath().c_str()); return true; } @@ -204,17 +205,15 @@ HostInfoLinux::ComputeUserPluginsDirectory(FileSpec &file_spec) // XDG Base Directory Specification // http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html // If XDG_DATA_HOME exists, use that, otherwise use ~/.local/share/lldb. - FileSpec lldb_file_spec; const char *xdg_data_home = getenv("XDG_DATA_HOME"); if (xdg_data_home && xdg_data_home[0]) { std::string user_plugin_dir(xdg_data_home); user_plugin_dir += "/lldb"; - lldb_file_spec.SetFile(user_plugin_dir.c_str(), true); + file_spec.GetDirectory().SetCString(user_plugin_dir.c_str()); } else - lldb_file_spec.SetFile("~/.local/share/lldb", true); - + file_spec.GetDirectory().SetCString("~/.local/share/lldb"); return true; } diff --git a/lldb/source/Host/macosx/HostInfoMacOSX.mm b/lldb/source/Host/macosx/HostInfoMacOSX.mm index a1d6e477ca46..784855d65cd2 100644 --- a/lldb/source/Host/macosx/HostInfoMacOSX.mm +++ b/lldb/source/Host/macosx/HostInfoMacOSX.mm @@ -149,7 +149,7 @@ HostInfoMacOSX::ComputeSupportExeDirectory(FileSpec &file_spec) ::strncpy(framework_pos, "/Resources", PATH_MAX - (framework_pos - raw_path)); #endif } - file_spec.SetFile(raw_path, true); + file_spec.GetDirectory().SetCString(raw_path); return (bool)file_spec.GetDirectory(); } @@ -169,7 +169,7 @@ HostInfoMacOSX::ComputeHeaderDirectory(FileSpec &file_spec) framework_pos += strlen("LLDB.framework"); ::strncpy(framework_pos, "/Headers", PATH_MAX - (framework_pos - raw_path)); } - file_spec.SetFile(raw_path, true); + file_spec.GetDirectory().SetCString(raw_path); return true; } @@ -199,7 +199,7 @@ HostInfoMacOSX::ComputePythonDirectory(FileSpec &file_spec) // We may get our string truncated. Should we protect this with an assert? ::strncat(raw_path, python_version_dir.c_str(), sizeof(raw_path) - strlen(raw_path) - 1); } - file_spec.SetFile(raw_path, true); + file_spec.GetDirectory().SetCString(raw_path); return true; } @@ -218,14 +218,15 @@ HostInfoMacOSX::ComputeSystemPluginsDirectory(FileSpec &file_spec) framework_pos += strlen("LLDB.framework"); ::strncpy(framework_pos, "/Resources/PlugIns", PATH_MAX - (framework_pos - raw_path)); - file_spec.SetFile(raw_path, true); + file_spec.GetDirectory().SetCString(raw_path); return true; } bool HostInfoMacOSX::ComputeUserPluginsDirectory(FileSpec &file_spec) { - file_spec.SetFile("~/Library/Application Support/LLDB/PlugIns", true); + FileSpec temp_file("~/Library/Application Support/LLDB/PlugIns", true); + file_spec.GetDirectory().SetCString(temp_file.GetPath().c_str()); return true; } diff --git a/lldb/source/Host/posix/HostInfoPosix.cpp b/lldb/source/Host/posix/HostInfoPosix.cpp index 78dc031fff26..77fdc2b61a31 100644 --- a/lldb/source/Host/posix/HostInfoPosix.cpp +++ b/lldb/source/Host/posix/HostInfoPosix.cpp @@ -158,14 +158,15 @@ HostInfoPosix::ComputeSupportExeDirectory(FileSpec &file_spec) log->Printf("Host::%s() failed to find /lib/liblldb within the shared lib path, bailing on bin path construction", __FUNCTION__); } - file_spec.SetFile(raw_path, true); + file_spec.GetDirectory().SetCString(raw_path); return (bool)file_spec.GetDirectory(); } bool HostInfoPosix::ComputeHeaderDirectory(FileSpec &file_spec) { - file_spec.SetFile("/opt/local/include/lldb", false); + FileSpec temp_file("/opt/local/include/lldb", false); + file_spec.GetDirectory().SetCString(temp_file.GetPath().c_str()); return true; } @@ -187,6 +188,6 @@ HostInfoPosix::ComputePythonDirectory(FileSpec &file_spec) // We may get our string truncated. Should we protect this with an assert? ::strncat(raw_path, python_version_dir.c_str(), sizeof(raw_path) - strlen(raw_path) - 1); - file_spec.SetFile(raw_path, true); + file_spec.GetDirectory().SetCString(raw_path); return true; } diff --git a/lldb/source/Host/windows/HostInfoWindows.cpp b/lldb/source/Host/windows/HostInfoWindows.cpp index f7d7411c08dc..8b2a6600e419 100644 --- a/lldb/source/Host/windows/HostInfoWindows.cpp +++ b/lldb/source/Host/windows/HostInfoWindows.cpp @@ -107,6 +107,6 @@ HostInfoWindows::ComputePythonDirectory(FileSpec &file_spec) lldb_file_spec.AppendPathComponent("../lib/site-packages"); lldb_file_spec.GetPath(raw_path, sizeof(raw_path)); - file_spec.SetFile(raw_path, true); + file_spec.GetDirectory().SetCString(raw_path); return true; }