[Lldb-commits] [lldb] r345901 - [File] Remove static method to get permissions.
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Thu Nov 1 15:46:49 PDT 2018
Author: jdevlieghere
Date: Thu Nov 1 15:46:49 2018
New Revision: 345901
URL: http://llvm.org/viewvc/llvm-project?rev=345901&view=rev
Log:
[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.
Modified:
lldb/trunk/include/lldb/Host/File.h
lldb/trunk/include/lldb/Host/FileSystem.h
lldb/trunk/source/Host/common/File.cpp
lldb/trunk/source/Host/common/FileSystem.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
Modified: lldb/trunk/include/lldb/Host/File.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/File.h?rev=345901&r1=345900&r2=345901&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/File.h (original)
+++ lldb/trunk/include/lldb/Host/File.h Thu Nov 1 15:46:49 2018
@@ -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.
///
Modified: lldb/trunk/include/lldb/Host/FileSystem.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/FileSystem.h?rev=345901&r1=345900&r2=345901&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/FileSystem.h (original)
+++ lldb/trunk/include/lldb/Host/FileSystem.h Thu Nov 1 15:46:49 2018
@@ -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.
Modified: lldb/trunk/source/Host/common/File.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/File.cpp?rev=345901&r1=345900&r2=345901&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/File.cpp (original)
+++ lldb/trunk/source/Host/common/File.cpp Thu Nov 1 15:46:49 2018
@@ -248,19 +248,6 @@ Status File::Open(const char *path, uint
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) {
Modified: lldb/trunk/source/Host/common/FileSystem.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/FileSystem.cpp?rev=345901&r1=345900&r2=345901&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/FileSystem.cpp (original)
+++ lldb/trunk/source/Host/common/FileSystem.cpp Thu Nov 1 15:46:49 2018
@@ -78,10 +78,23 @@ uint32_t FileSystem::GetPermissions(cons
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();
}
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp?rev=345901&r1=345900&r2=345901&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp Thu Nov 1 15:46:49 2018
@@ -660,14 +660,14 @@ GDBRemoteCommunicationServerCommon::Hand
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);
More information about the lldb-commits
mailing list