aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2018-11-01 15:47:33 +0000
committerJonas Devlieghere <jonas@devlieghere.com>2018-11-01 15:47:33 +0000
commit7c5310bbd3eeaa654f4f008e93f8a91cefe69c06 (patch)
tree3ab7babc86ddd54dcb145ada6e745ca0e6c8fd21
parentc5fe3ce2ec8b44b2cbab6fe5dc50633492fbd80d (diff)
downloadllvm-7c5310bbd3eeaa654f4f008e93f8a91cefe69c06.zip
llvm-7c5310bbd3eeaa654f4f008e93f8a91cefe69c06.tar.gz
llvm-7c5310bbd3eeaa654f4f008e93f8a91cefe69c06.tar.bz2
[FileSystem] Remove GetPermissions() and Readable() from FileSpec
This patch removes the GetPermissions and GetReadable methods from FileSpec and updates its uses with calls to the FileSystem. Differential revision: https://reviews.llvm.org/D53831 llvm-svn: 345843
-rw-r--r--lldb/include/lldb/Utility/FileSpec.h22
-rw-r--r--lldb/source/API/SBPlatform.cpp2
-rw-r--r--lldb/source/Commands/CommandObjectTarget.cpp6
-rw-r--r--lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp2
-rw-r--r--lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp2
-rw-r--r--lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp2
-rw-r--r--lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp2
-rw-r--r--lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp2
-rw-r--r--lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp7
-rw-r--r--lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp3
-rw-r--r--lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp2
-rw-r--r--lldb/source/Target/Platform.cpp2
-rw-r--r--lldb/source/Utility/FileSpec.cpp13
13 files changed, 17 insertions, 50 deletions
diff --git a/lldb/include/lldb/Utility/FileSpec.h b/lldb/include/lldb/Utility/FileSpec.h
index 467e7b6..a51ebf8 100644
--- a/lldb/include/lldb/Utility/FileSpec.h
+++ b/lldb/include/lldb/Utility/FileSpec.h
@@ -281,15 +281,6 @@ public:
bool Exists() const;
//------------------------------------------------------------------
- /// Check if a file is readable by the current user
- ///
- /// @return
- /// \b true if the file exists on disk and is readable, \b false
- /// otherwise.
- //------------------------------------------------------------------
- bool Readable() const;
-
- //------------------------------------------------------------------
/// Expanded existence test.
///
/// Call into the Host to see if it can help find the file (e.g. by
@@ -451,19 +442,6 @@ public:
ConstString GetFileNameStrippingExtension() const;
//------------------------------------------------------------------
- /// Return the current permissions of the path.
- ///
- /// Returns a bitmask for the current permissions of the file ( zero or more
- /// of the permission bits defined in File::Permissions).
- ///
- /// @return
- /// Zero if the file doesn't exist or we are unable to get
- /// information for the file, otherwise one or more permission
- /// bits from the File::Permissions enumeration.
- //------------------------------------------------------------------
- uint32_t GetPermissions() const;
-
- //------------------------------------------------------------------
/// Get the memory cost of this object.
///
/// Return the size in bytes that this object takes in memory. This returns
diff --git a/lldb/source/API/SBPlatform.cpp b/lldb/source/API/SBPlatform.cpp
index 5f29f00..bce3fd7 100644
--- a/lldb/source/API/SBPlatform.cpp
+++ b/lldb/source/API/SBPlatform.cpp
@@ -364,7 +364,7 @@ SBError SBPlatform::Get(SBFileSpec &src, SBFileSpec &dst) {
SBError SBPlatform::Put(SBFileSpec &src, SBFileSpec &dst) {
return ExecuteConnected([&](const lldb::PlatformSP &platform_sp) {
if (src.Exists()) {
- uint32_t permissions = src.ref().GetPermissions();
+ uint32_t permissions = FileSystem::Instance().GetPermissions(src.ref());
if (permissions == 0) {
if (llvm::sys::fs::is_directory(src.ref().GetPath()))
permissions = eFilePermissionsDirectoryDefault;
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index 134dd61..524df3a 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -280,7 +280,7 @@ protected:
result.SetStatus(eReturnStatusFailed);
return false;
}
- if (!core_file.Readable()) {
+ if (!FileSystem::Instance().Readable(core_file)) {
result.AppendErrorWithFormat("core file '%s' is not readable",
core_file.GetPath().c_str());
result.SetStatus(eReturnStatusFailed);
@@ -292,7 +292,7 @@ protected:
FileSpec symfile(m_symbol_file.GetOptionValue().GetCurrentValue());
if (symfile) {
if (symfile.Exists()) {
- if (!symfile.Readable()) {
+ if (!FileSystem::Instance().Readable(symfile)) {
result.AppendErrorWithFormat("symbol file '%s' is not readable",
symfile.GetPath().c_str());
result.SetStatus(eReturnStatusFailed);
@@ -405,7 +405,7 @@ protected:
char core_path[PATH_MAX];
core_file.GetPath(core_path, sizeof(core_path));
if (core_file.Exists()) {
- if (!core_file.Readable()) {
+ if (!FileSystem::Instance().Readable(core_file)) {
result.AppendMessageWithFormat(
"Core file '%s' is not readable.\n", core_path);
result.SetStatus(eReturnStatusFailed);
diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
index f5ecb52..363745f 100644
--- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -2536,7 +2536,7 @@ bool RenderScriptRuntime::LoadAllocation(Stream &strm, const uint32_t alloc_id,
return false;
}
- if (!file.Readable()) {
+ if (!FileSystem::Instance().Readable(file)) {
strm.Printf("Error: File %s does not have readable permissions", path);
strm.EOL();
return false;
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp
index 0283284..72cac26 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp
@@ -228,7 +228,7 @@ Status PlatformAppleTVSimulator::ResolveExecutable(
}
if (error.Fail() || !exe_module_sp) {
- if (resolved_module_spec.GetFileSpec().Readable()) {
+ if (FileSystem::Instance().Readable(resolved_module_spec.GetFileSpec())) {
error.SetErrorStringWithFormat(
"'%s' doesn't contain any '%s' platform architectures: %s",
resolved_module_spec.GetFileSpec().GetPath().c_str(),
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp
index 144a828..71dc807 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp
@@ -228,7 +228,7 @@ Status PlatformAppleWatchSimulator::ResolveExecutable(
}
if (error.Fail() || !exe_module_sp) {
- if (resolved_module_spec.GetFileSpec().Readable()) {
+ if (FileSystem::Instance().Readable(resolved_module_spec.GetFileSpec())) {
error.SetErrorStringWithFormat(
"'%s' doesn't contain any '%s' platform architectures: %s",
resolved_module_spec.GetFileSpec().GetPath().c_str(),
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp
index 73c70e1..88a181b 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp
@@ -119,7 +119,7 @@ Status PlatformRemoteDarwinDevice::ResolveExecutable(
}
if (error.Fail() || !exe_module_sp) {
- if (resolved_module_spec.GetFileSpec().Readable()) {
+ if (FileSystem::Instance().Readable(resolved_module_spec.GetFileSpec())) {
error.SetErrorStringWithFormat(
"'%s' doesn't contain any '%s' platform architectures: %s",
resolved_module_spec.GetFileSpec().GetPath().c_str(),
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp
index 2266bd4..af90f29 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp
@@ -234,7 +234,7 @@ Status PlatformiOSSimulator::ResolveExecutable(
}
if (error.Fail() || !exe_module_sp) {
- if (resolved_module_spec.GetFileSpec().Readable()) {
+ if (FileSystem::Instance().Readable(resolved_module_spec.GetFileSpec())) {
error.SetErrorStringWithFormat(
"'%s' doesn't contain any '%s' platform architectures: %s",
resolved_module_spec.GetFileSpec().GetPath().c_str(),
diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
index 3cced0c..0016a5c 100644
--- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -143,8 +143,8 @@ PlatformPOSIX::ResolveExecutable(const ModuleSpec &module_spec,
if (resolved_module_spec.GetFileSpec().Exists())
error.Clear();
else {
- const uint32_t permissions =
- resolved_module_spec.GetFileSpec().GetPermissions();
+ const uint32_t permissions = FileSystem::Instance().GetPermissions(
+ resolved_module_spec.GetFileSpec());
if (permissions && (permissions & eFilePermissionsEveryoneR) == 0)
error.SetErrorStringWithFormat(
"executable '%s' is not readable",
@@ -237,7 +237,8 @@ PlatformPOSIX::ResolveExecutable(const ModuleSpec &module_spec,
}
if (error.Fail() || !exe_module_sp) {
- if (resolved_module_spec.GetFileSpec().Readable()) {
+ if (FileSystem::Instance().Readable(
+ resolved_module_spec.GetFileSpec())) {
error.SetErrorStringWithFormat(
"'%s' doesn't contain any '%s' platform architectures: %s",
resolved_module_spec.GetFileSpec().GetPath().c_str(),
diff --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
index 966d1c5..fd1a402 100644
--- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
+++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
@@ -262,7 +262,8 @@ Status PlatformWindows::ResolveExecutable(
}
if (error.Fail() || !exe_module_sp) {
- if (resolved_module_spec.GetFileSpec().Readable()) {
+ if (FileSystem::Instance().Readable(
+ resolved_module_spec.GetFileSpec())) {
error.SetErrorStringWithFormat(
"'%s' doesn't contain any '%s' platform architectures: %s",
resolved_module_spec.GetFileSpec().GetPath().c_str(),
diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
index 7f86d6d..1a9dc92 100644
--- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
+++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
@@ -142,7 +142,7 @@ Status PlatformRemoteGDBServer::ResolveExecutable(
}
if (error.Fail() || !exe_module_sp) {
- if (resolved_module_spec.GetFileSpec().Readable()) {
+ if (FileSystem::Instance().Readable(resolved_module_spec.GetFileSpec())) {
error.SetErrorStringWithFormat(
"'%s' doesn't contain any '%s' platform architectures: %s",
resolved_module_spec.GetFileSpec().GetPath().c_str(),
diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index 54d72b9..ff1cbce 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -709,7 +709,7 @@ Status Platform::Install(const FileSpec &src, const FileSpec &dst) {
switch (fs::get_file_type(src.GetPath(), false)) {
case fs::file_type::directory_file: {
llvm::sys::fs::remove(fixed_dst.GetPath());
- uint32_t permissions = src.GetPermissions();
+ uint32_t permissions = FileSystem::Instance().GetPermissions(src);
if (permissions == 0)
permissions = eFilePermissionsDirectoryDefault;
error = MakeDirectory(fixed_dst, permissions);
diff --git a/lldb/source/Utility/FileSpec.cpp b/lldb/source/Utility/FileSpec.cpp
index f94f8dd..c41a0643 100644
--- a/lldb/source/Utility/FileSpec.cpp
+++ b/lldb/source/Utility/FileSpec.cpp
@@ -458,10 +458,6 @@ void FileSpec::Dump(Stream *s) const {
//------------------------------------------------------------------
bool FileSpec::Exists() const { return llvm::sys::fs::exists(GetPath()); }
-bool FileSpec::Readable() const {
- return GetPermissions() & llvm::sys::fs::perms::all_read;
-}
-
bool FileSpec::ResolveExecutableLocation() {
// CLEANUP: Use StringRef for string handling.
if (!m_directory) {
@@ -509,15 +505,6 @@ bool FileSpec::ResolvePath() {
FileSpec::Style FileSpec::GetPathStyle() const { return m_style; }
-uint32_t FileSpec::GetPermissions() const {
- namespace fs = llvm::sys::fs;
- fs::file_status st;
- if (fs::status(GetPath(), st, false))
- return fs::perms::perms_not_known;
-
- return st.permissions();
-}
-
//------------------------------------------------------------------
// Directory string get accessor.
//------------------------------------------------------------------