summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Unix
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-06-18 20:56:38 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-06-18 20:56:38 +0000
commita1280c16fb012fb167787a7c99d526bc19153dcc (patch)
tree5c4e2e3285a13b6ffa94b149b6e751a98a5c2216 /llvm/lib/Support/Unix
parent8f99e9413f49f89d1c29e1c083068b9aedbbee4e (diff)
downloadbcm5719-llvm-a1280c16fb012fb167787a7c99d526bc19153dcc.tar.gz
bcm5719-llvm-a1280c16fb012fb167787a7c99d526bc19153dcc.zip
Add a can_write function to PathV2.
llvm-svn: 184233
Diffstat (limited to 'llvm/lib/Support/Unix')
-rw-r--r--llvm/lib/Support/Unix/PathV2.inc6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Support/Unix/PathV2.inc b/llvm/lib/Support/Unix/PathV2.inc
index 9ea4f9ed51a..a806083b193 100644
--- a/llvm/lib/Support/Unix/PathV2.inc
+++ b/llvm/lib/Support/Unix/PathV2.inc
@@ -308,6 +308,12 @@ error_code exists(const Twine &path, bool &result) {
return error_code::success();
}
+bool can_write(const Twine &Path) {
+ SmallString<128> PathStorage;
+ StringRef P = Path.toNullTerminatedStringRef(PathStorage);
+ return 0 == access(P.begin(), W_OK);
+}
+
bool can_execute(const Twine &Path) {
SmallString<128> PathStorage;
StringRef P = Path.toNullTerminatedStringRef(PathStorage);
OpenPOWER on IntegriCloud