This revision was automatically updated to reflect the committed changes.
Closed by commit rL298205: Remove FileSystem::Get/SetFilePermissions (authored 
by zturner).

Changed prior to commit:
  https://reviews.llvm.org/D31089?vs=92167&id=92260#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31089

Files:
  lldb/trunk/include/lldb/Host/FileSystem.h
  lldb/trunk/source/Host/posix/FileSystem.cpp
  lldb/trunk/source/Host/windows/FileSystem.cpp
  
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
  lldb/trunk/source/Target/Platform.cpp

Index: lldb/trunk/include/lldb/Host/FileSystem.h
===================================================================
--- lldb/trunk/include/lldb/Host/FileSystem.h
+++ lldb/trunk/include/lldb/Host/FileSystem.h
@@ -28,10 +28,6 @@
 
   static FileSpec::PathSyntax GetNativePathSyntax();
 
-  static Error GetFilePermissions(const FileSpec &file_spec,
-                                  uint32_t &file_permissions);
-  static Error SetFilePermissions(const FileSpec &file_spec,
-                                  uint32_t file_permissions);
   static lldb::user_id_t GetFileSize(const FileSpec &file_spec);
   static bool GetFileExists(const FileSpec &file_spec);
 
Index: lldb/trunk/source/Target/Platform.cpp
===================================================================
--- lldb/trunk/source/Target/Platform.cpp
+++ lldb/trunk/source/Target/Platform.cpp
@@ -773,9 +773,12 @@
 
 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::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(),
Index: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
===================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -809,11 +809,12 @@
     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());
Index: lldb/trunk/source/Host/posix/FileSystem.cpp
===================================================================
--- lldb/trunk/source/Host/posix/FileSystem.cpp
+++ lldb/trunk/source/Host/posix/FileSystem.cpp
@@ -40,28 +40,6 @@
   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();
 }
Index: lldb/trunk/source/Host/windows/FileSystem.cpp
===================================================================
--- lldb/trunk/source/Host/windows/FileSystem.cpp
+++ lldb/trunk/source/Host/windows/FileSystem.cpp
@@ -30,34 +30,6 @@
   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();
 }
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to