[Lldb-commits] [lldb] r242568 - Implement FileSystem::GetPermissions for Windows. Differential Revision: http://reviews.llvm.org/D11303
Adrian McCarthy
amccarth at google.com
Fri Jul 17 13:23:04 PDT 2015
Author: amccarth
Date: Fri Jul 17 15:23:03 2015
New Revision: 242568
URL: http://llvm.org/viewvc/llvm-project?rev=242568&view=rev
Log:
Implement FileSystem::GetPermissions for Windows. Differential Revision: http://reviews.llvm.org/D11303
Modified:
lldb/trunk/source/Host/windows/FileSystem.cpp
Modified: lldb/trunk/source/Host/windows/FileSystem.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/FileSystem.cpp?rev=242568&r1=242567&r2=242568&view=diff
==============================================================================
--- lldb/trunk/source/Host/windows/FileSystem.cpp (original)
+++ lldb/trunk/source/Host/windows/FileSystem.cpp Fri Jul 17 15:23:03 2015
@@ -10,6 +10,8 @@
#include "lldb/Host/windows/windows.h"
#include <shellapi.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include "lldb/Host/FileSystem.h"
#include "llvm/Support/FileSystem.h"
@@ -71,7 +73,23 @@ Error
FileSystem::GetFilePermissions(const FileSpec &file_spec, uint32_t &file_permissions)
{
Error error;
- error.SetErrorStringWithFormat("%s is not supported on this host", __PRETTY_FUNCTION__);
+ // 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;
}
More information about the lldb-commits
mailing list