diff options
author | Zachary Turner <zturner@google.com> | 2017-03-19 05:48:47 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2017-03-19 05:48:47 +0000 |
commit | d3d95fd66a57e48ab257bc8b804f622e763ceafb (patch) | |
tree | 660db500ae9a94d9a5b8d7a951675b783327a16d /lldb/source/Host | |
parent | c8c9f972580f06a466e42a77c01d820cba0d0106 (diff) | |
download | bcm5719-llvm-d3d95fd66a57e48ab257bc8b804f622e763ceafb.tar.gz bcm5719-llvm-d3d95fd66a57e48ab257bc8b804f622e763ceafb.zip |
Remove FileSystem::MakeDirectory.
Have callers use llvm::sys::fs::create_directory() instead.
Differential Revision: https://reviews.llvm.org/D31086
llvm-svn: 298203
Diffstat (limited to 'lldb/source/Host')
-rw-r--r-- | lldb/source/Host/common/Editline.cpp | 6 | ||||
-rw-r--r-- | lldb/source/Host/common/HostInfoBase.cpp | 8 | ||||
-rw-r--r-- | lldb/source/Host/posix/FileSystem.cpp | 33 | ||||
-rw-r--r-- | lldb/source/Host/windows/FileSystem.cpp | 15 |
4 files changed, 4 insertions, 58 deletions
diff --git a/lldb/source/Host/common/Editline.cpp b/lldb/source/Host/common/Editline.cpp index 952be3ccddf..f8339d8e599 100644 --- a/lldb/source/Host/common/Editline.cpp +++ b/lldb/source/Host/common/Editline.cpp @@ -15,13 +15,13 @@ #include "lldb/Host/ConnectionFileDescriptor.h" #include "lldb/Host/Editline.h" #include "lldb/Host/FileSpec.h" -#include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" #include "lldb/Utility/Error.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/SelectHelper.h" #include "lldb/Utility/StreamString.h" +#include "llvm/Support/FileSystem.h" #include "llvm/Support/Threading.h" using namespace lldb_private; @@ -178,9 +178,7 @@ private: if (m_path.empty() && m_history && !m_prefix.empty()) { FileSpec parent_path{"~/.lldb", true}; char history_path[PATH_MAX]; - if (FileSystem::MakeDirectory(parent_path, - lldb::eFilePermissionsDirectoryDefault) - .Success()) { + if (!llvm::sys::fs::create_directory(parent_path.GetPath()) { snprintf(history_path, sizeof(history_path), "~/.lldb/%s-history", m_prefix.c_str()); } else { diff --git a/lldb/source/Host/common/HostInfoBase.cpp b/lldb/source/Host/common/HostInfoBase.cpp index 58f7cb5e5ac..80dbc6f0c46 100644 --- a/lldb/source/Host/common/HostInfoBase.cpp +++ b/lldb/source/Host/common/HostInfoBase.cpp @@ -314,9 +314,7 @@ bool HostInfoBase::ComputeProcessTempFileDirectory(FileSpec &file_spec) { std::string pid_str{llvm::to_string(Host::GetCurrentProcessID())}; temp_file_spec.AppendPathComponent(pid_str); - if (!FileSystem::MakeDirectory(temp_file_spec, - eFilePermissionsDirectoryDefault) - .Success()) + if (llvm::sys::fs::create_directory(temp_file_spec.GetPath())) return false; file_spec.GetDirectory().SetCString(temp_file_spec.GetCString()); @@ -338,9 +336,7 @@ bool HostInfoBase::ComputeGlobalTempFileDirectory(FileSpec &file_spec) { return false; temp_file_spec.AppendPathComponent("lldb"); - if (!FileSystem::MakeDirectory(temp_file_spec, - eFilePermissionsDirectoryDefault) - .Success()) + if (llvm::sys::fs::create_directory(temp_file_spec.GetPath())) return false; file_spec.GetDirectory().SetCString(temp_file_spec.GetCString()); diff --git a/lldb/source/Host/posix/FileSystem.cpp b/lldb/source/Host/posix/FileSystem.cpp index cbdcf4fecbe..4cd9447a95b 100644 --- a/lldb/source/Host/posix/FileSystem.cpp +++ b/lldb/source/Host/posix/FileSystem.cpp @@ -40,39 +40,6 @@ FileSpec::PathSyntax FileSystem::GetNativePathSyntax() { return FileSpec::ePathSyntaxPosix; } -Error FileSystem::MakeDirectory(const FileSpec &file_spec, - uint32_t file_permissions) { - if (file_spec) { - Error error; - if (::mkdir(file_spec.GetCString(), file_permissions) == -1) { - error.SetErrorToErrno(); - errno = 0; - switch (error.GetError()) { - case ENOENT: { - // Parent directory doesn't exist, so lets make it if we can - // Make the parent directory and try again - FileSpec parent_file_spec{file_spec.GetDirectory().GetCString(), false}; - error = MakeDirectory(parent_file_spec, file_permissions); - if (error.Fail()) - return error; - // Try and make the directory again now that the parent directory was - // made successfully - if (::mkdir(file_spec.GetCString(), file_permissions) == -1) { - error.SetErrorToErrno(); - } - return error; - } break; - case EEXIST: { - if (llvm::sys::fs::is_directory(file_spec.GetPath())) - return Error(); // It is a directory and it already exists - } break; - } - } - return error; - } - return Error("empty path"); -} - Error FileSystem::GetFilePermissions(const FileSpec &file_spec, uint32_t &file_permissions) { Error error; diff --git a/lldb/source/Host/windows/FileSystem.cpp b/lldb/source/Host/windows/FileSystem.cpp index 88346a8d39f..50a9666c472 100644 --- a/lldb/source/Host/windows/FileSystem.cpp +++ b/lldb/source/Host/windows/FileSystem.cpp @@ -30,21 +30,6 @@ FileSpec::PathSyntax FileSystem::GetNativePathSyntax() { return FileSpec::ePathSyntaxWindows; } -Error FileSystem::MakeDirectory(const FileSpec &file_spec, - uint32_t file_permissions) { - // On Win32, the mode parameter is ignored, as Windows files and directories - // support a - // different permission model than POSIX. - Error error; - const auto err_code = - llvm::sys::fs::create_directories(file_spec.GetPath(), true); - if (err_code) { - error.SetErrorString(err_code.message().c_str()); - } - - return error; -} - Error FileSystem::GetFilePermissions(const FileSpec &file_spec, uint32_t &file_permissions) { Error error; |