diff options
| author | Zachary Turner <zturner@google.com> | 2017-03-19 05:49:43 +0000 |
|---|---|---|
| committer | Zachary Turner <zturner@google.com> | 2017-03-19 05:49:43 +0000 |
| commit | 6934e0aaa7fa1f081a43e3ceea4c7a865ba015ce (patch) | |
| tree | 1458713baad812a8f935583cbcd8eead1ee4df9a /lldb/source | |
| parent | 3a86a04404037dd5f0e19a4b866f2d9c082d0c18 (diff) | |
| download | bcm5719-llvm-6934e0aaa7fa1f081a43e3ceea4c7a865ba015ce.tar.gz bcm5719-llvm-6934e0aaa7fa1f081a43e3ceea4c7a865ba015ce.zip | |
Remove FileSystem::Get/SetFilePermissions
Differential Revision: https://reviews.llvm.org/D31089
llvm-svn: 298205
Diffstat (limited to 'lldb/source')
| -rw-r--r-- | lldb/source/Host/posix/FileSystem.cpp | 22 | ||||
| -rw-r--r-- | lldb/source/Host/windows/FileSystem.cpp | 28 | ||||
| -rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp | 5 | ||||
| -rw-r--r-- | lldb/source/Target/Platform.cpp | 16 |
4 files changed, 13 insertions, 58 deletions
diff --git a/lldb/source/Host/posix/FileSystem.cpp b/lldb/source/Host/posix/FileSystem.cpp index 4cd9447a95b..4c21fcd34a0 100644 --- a/lldb/source/Host/posix/FileSystem.cpp +++ b/lldb/source/Host/posix/FileSystem.cpp @@ -40,28 +40,6 @@ FileSpec::PathSyntax FileSystem::GetNativePathSyntax() { return FileSpec::ePathSyntaxPosix; } -Error FileSystem::GetFilePermissions(const FileSpec &file_spec, - uint32_t &file_permissions) { - Error error; - struct stat file_stats; - if (::stat(file_spec.GetCString(), &file_stats) == 0) { - // The bits in "st_mode" currently match the definitions - // for the file mode bits in unix. - file_permissions = file_stats.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); - } else { - error.SetErrorToErrno(); - } - return error; -} - -Error FileSystem::SetFilePermissions(const FileSpec &file_spec, - uint32_t file_permissions) { - Error error; - if (::chmod(file_spec.GetCString(), file_permissions) != 0) - error.SetErrorToErrno(); - return error; -} - lldb::user_id_t FileSystem::GetFileSize(const FileSpec &file_spec) { return file_spec.GetByteSize(); } diff --git a/lldb/source/Host/windows/FileSystem.cpp b/lldb/source/Host/windows/FileSystem.cpp index 50a9666c472..e834c85a28c 100644 --- a/lldb/source/Host/windows/FileSystem.cpp +++ b/lldb/source/Host/windows/FileSystem.cpp @@ -30,34 +30,6 @@ FileSpec::PathSyntax FileSystem::GetNativePathSyntax() { return FileSpec::ePathSyntaxWindows; } -Error FileSystem::GetFilePermissions(const FileSpec &file_spec, - uint32_t &file_permissions) { - Error error; - // Beware that Windows's permission model is different from Unix's, and it's - // not clear if this API is supposed to check ACLs. To match the caller's - // expectations as closely as possible, we'll use Microsoft's _stat, which - // attempts to emulate POSIX stat. This should be good enough for basic - // checks like FileSpec::Readable. - struct _stat file_stats; - if (::_stat(file_spec.GetCString(), &file_stats) == 0) { - // The owner permission bits in "st_mode" currently match the definitions - // for the owner file mode bits. - file_permissions = file_stats.st_mode & (_S_IREAD | _S_IWRITE | _S_IEXEC); - } else { - error.SetErrorToErrno(); - } - - return error; -} - -Error FileSystem::SetFilePermissions(const FileSpec &file_spec, - uint32_t file_permissions) { - Error error; - error.SetErrorStringWithFormat("%s is not supported on this host", - LLVM_PRETTY_FUNCTION); - return error; -} - lldb::user_id_t FileSystem::GetFileSize(const FileSpec &file_spec) { return file_spec.GetByteSize(); } diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp index 604f3fb3dbc..5ebd186c232 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp @@ -809,11 +809,12 @@ GDBRemoteCommunicationServerCommon::Handle_qPlatform_chmod( StringExtractorGDBRemote &packet) { packet.SetFilePos(::strlen("qPlatform_chmod:")); - mode_t mode = packet.GetHexMaxU32(false, UINT32_MAX); + auto perms = + static_cast<llvm::sys::fs::perms>(packet.GetHexMaxU32(false, UINT32_MAX)); if (packet.GetChar() == ',') { std::string path; packet.GetHexByteString(path); - Error error = FileSystem::SetFilePermissions(FileSpec{path, true}, mode); + Error error(llvm::sys::fs::setPermissions(path, perms)); StreamGDBRemote response; response.Printf("F%u", error.GetError()); diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp index d3f265da09e..d92bf12dffa 100644 --- a/lldb/source/Target/Platform.cpp +++ b/lldb/source/Target/Platform.cpp @@ -773,9 +773,12 @@ Error Platform::MakeDirectory(const FileSpec &file_spec, uint32_t permissions) { Error Platform::GetFilePermissions(const FileSpec &file_spec, uint32_t &file_permissions) { - if (IsHost()) - return FileSystem::GetFilePermissions(file_spec, file_permissions); - else { + if (IsHost()) { + auto Value = llvm::sys::fs::getPermissions(file_spec.GetPath()); + if (Value) + file_permissions = Value.get(); + return Error(Value.getError()); + } else { Error error; error.SetErrorStringWithFormat("remote platform %s doesn't support %s", GetPluginName().GetCString(), @@ -786,9 +789,10 @@ Error Platform::GetFilePermissions(const FileSpec &file_spec, Error Platform::SetFilePermissions(const FileSpec &file_spec, uint32_t file_permissions) { - if (IsHost()) - return FileSystem::SetFilePermissions(file_spec, file_permissions); - else { + if (IsHost()) { + auto Perms = static_cast<llvm::sys::fs::perms>(file_permissions); + return llvm::sys::fs::setPermissions(file_spec.GetPath(), Perms); + } else { Error error; error.SetErrorStringWithFormat("remote platform %s doesn't support %s", GetPluginName().GetCString(), |

