summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Path.cpp
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2017-03-13 12:17:14 +0000
committerAaron Ballman <aaron@aaronballman.com>2017-03-13 12:17:14 +0000
commitf5cba91591f45baf25d097763b59915bbee81114 (patch)
treee1ff2bf0f6d56a91b9474d47726127e7438a5326 /llvm/lib/Support/Path.cpp
parent7163ecb4294ede871a9fe5e5d27b6937d5bade7e (diff)
downloadbcm5719-llvm-f5cba91591f45baf25d097763b59915bbee81114.tar.gz
bcm5719-llvm-f5cba91591f45baf25d097763b59915bbee81114.zip
Add support for getting file system permissions and implement sys::fs::permissions to set them.
Patch by James Henderson. llvm-svn: 297617
Diffstat (limited to 'llvm/lib/Support/Path.cpp')
-rw-r--r--llvm/lib/Support/Path.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp
index fc3cf525c93..5ac60e8dc3e 100644
--- a/llvm/lib/Support/Path.cpp
+++ b/llvm/lib/Support/Path.cpp
@@ -1189,12 +1189,20 @@ std::error_code identify_magic(const Twine &Path, file_magic &Result) {
}
std::error_code directory_entry::status(file_status &result) const {
- return fs::status(Path, result, FollowSymlinks);
-}
-
-} // end namespace fs
-} // end namespace sys
-} // end namespace llvm
+ return fs::status(Path, result, FollowSymlinks);
+}
+
+ErrorOr<perms> getPermissions(const Twine &Path) {
+ file_status Status;
+ if (std::error_code EC = status(Path, Status))
+ return EC;
+
+ return Status.permissions();
+}
+
+} // end namespace fs
+} // end namespace sys
+} // end namespace llvm
// Include the truly platform-specific parts.
#if defined(LLVM_ON_UNIX)
OpenPOWER on IntegriCloud