diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2018-11-01 22:46:49 +0000 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2018-11-01 22:46:49 +0000 |
commit | 73ed607180abb6b075e863422c0530471163b54e (patch) | |
tree | af7414ebde473635a717d3a4a5760deb775b07bd | |
parent | d5d06a0763bb6e1a44b7879ee36f161a2fe9b182 (diff) | |
download | bcm5719-llvm-73ed607180abb6b075e863422c0530471163b54e.tar.gz bcm5719-llvm-73ed607180abb6b075e863422c0530471163b54e.zip |
[File] Remove static method to get permissions.
This patch removes the static accessor in File to get a file's
permissions. Permissions should be checked through the FileSystem class.
llvm-svn: 345901
-rw-r--r-- | lldb/include/lldb/Host/File.h | 2 | ||||
-rw-r--r-- | lldb/include/lldb/Host/FileSystem.h | 2 | ||||
-rw-r--r-- | lldb/source/Host/common/File.cpp | 13 | ||||
-rw-r--r-- | lldb/source/Host/common/FileSystem.cpp | 15 | ||||
-rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp | 8 |
5 files changed, 20 insertions, 20 deletions
diff --git a/lldb/include/lldb/Host/File.h b/lldb/include/lldb/Host/File.h index 8cc21ba4c51..f54c9b200ea 100644 --- a/lldb/include/lldb/Host/File.h +++ b/lldb/include/lldb/Host/File.h @@ -419,8 +419,6 @@ public: //------------------------------------------------------------------ uint32_t GetPermissions(Status &error) const; - static uint32_t GetPermissions(const FileSpec &file_spec, Status &error); - //------------------------------------------------------------------ /// Return true if this file is interactive. /// diff --git a/lldb/include/lldb/Host/FileSystem.h b/lldb/include/lldb/Host/FileSystem.h index ea1fe08bb31..60cdfdd75dd 100644 --- a/lldb/include/lldb/Host/FileSystem.h +++ b/lldb/include/lldb/Host/FileSystem.h @@ -66,6 +66,8 @@ public: /// @{ uint32_t GetPermissions(const FileSpec &file_spec) const; uint32_t GetPermissions(const llvm::Twine &path) const; + uint32_t GetPermissions(const FileSpec &file_spec, std::error_code &ec) const; + uint32_t GetPermissions(const llvm::Twine &path, std::error_code &ec) const; /// @} /// Returns whether the given file exists. diff --git a/lldb/source/Host/common/File.cpp b/lldb/source/Host/common/File.cpp index fb9549522bc..4aae4d26ccd 100644 --- a/lldb/source/Host/common/File.cpp +++ b/lldb/source/Host/common/File.cpp @@ -248,19 +248,6 @@ Status File::Open(const char *path, uint32_t options, uint32_t permissions) { return error; } -uint32_t File::GetPermissions(const FileSpec &file_spec, Status &error) { - if (file_spec) { - error.Clear(); - auto Perms = llvm::sys::fs::getPermissions(file_spec.GetPath()); - if (Perms) - return *Perms; - error = Status(Perms.getError()); - return 0; - } else - error.SetErrorString("empty file spec"); - return 0; -} - uint32_t File::GetPermissions(Status &error) const { int fd = GetDescriptor(); if (fd != kInvalidDescriptor) { diff --git a/lldb/source/Host/common/FileSystem.cpp b/lldb/source/Host/common/FileSystem.cpp index 664f794fcc2..73e74c1069f 100644 --- a/lldb/source/Host/common/FileSystem.cpp +++ b/lldb/source/Host/common/FileSystem.cpp @@ -78,10 +78,23 @@ uint32_t FileSystem::GetPermissions(const FileSpec &file_spec) const { return GetPermissions(file_spec.GetPath()); } +uint32_t FileSystem::GetPermissions(const FileSpec &file_spec, + std::error_code &ec) const { + return GetPermissions(file_spec.GetPath(), ec); +} + uint32_t FileSystem::GetPermissions(const Twine &path) const { + std::error_code ec; + return GetPermissions(path, ec); +} + +uint32_t FileSystem::GetPermissions(const Twine &path, + std::error_code &ec) const { ErrorOr<vfs::Status> status = m_fs->status(path); - if (!status) + if (!status) { + ec = status.getError(); return sys::fs::perms::perms_not_known; + } return status->getPermissions(); } diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp index 60b56b01882..382754c642c 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp @@ -660,14 +660,14 @@ GDBRemoteCommunicationServerCommon::Handle_vFile_Mode( std::string path; packet.GetHexByteString(path); if (!path.empty()) { - Status error; FileSpec file_spec(path); FileSystem::Instance().Resolve(file_spec); - const uint32_t mode = File::GetPermissions(file_spec, error); + std::error_code ec; + const uint32_t mode = FileSystem::Instance().GetPermissions(file_spec, ec); StreamString response; response.Printf("F%u", mode); - if (mode == 0 || error.Fail()) - response.Printf(",%i", (int)error.GetError()); + if (mode == 0 || ec) + response.Printf(",%i", (int)Status(ec).GetError()); return SendPacketNoLock(response.GetString()); } return SendErrorResponse(23); |