summaryrefslogtreecommitdiff
path: root/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
commit68ba1825fcaf94bdf7e057ef19585226ec48ce5d (patch)
treefcbb31282038cfbfdf949b899cd866d8934774a5 /lib/Support/Unix
parent41502e1af77443c31138cee309bd89898f23e33a (diff)
downloadllvm-68ba1825fcaf94bdf7e057ef19585226ec48ce5d.tar.gz
llvm-68ba1825fcaf94bdf7e057ef19585226ec48ce5d.tar.bz2
llvm-68ba1825fcaf94bdf7e057ef19585226ec48ce5d.tar.xz
Add a can_write function to PathV2.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184233 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Unix')
-rw-r--r--lib/Support/Unix/PathV2.inc6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Support/Unix/PathV2.inc b/lib/Support/Unix/PathV2.inc
index 9ea4f9ed51..a806083b19 100644
--- a/lib/Support/Unix/PathV2.inc
+++ b/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);