aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Support/Windows/PathV2.inc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Support/Windows/PathV2.inc')
-rw-r--r--lib/Support/Windows/PathV2.inc12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/Support/Windows/PathV2.inc b/lib/Support/Windows/PathV2.inc
index 3b2992d..bec95e3 100644
--- a/lib/Support/Windows/PathV2.inc
+++ b/lib/Support/Windows/PathV2.inc
@@ -362,6 +362,18 @@ error_code exists(const Twine &path, bool &result) {
return error_code::success();
}
+bool can_write(const Twine &Path) {
+ // FIXME: take security attributes into account.
+ SmallString<128> PathStorage;
+ SmallVector<wchar_t, 128> PathUtf16;
+
+ if (UTF8ToUTF16(Path.toStringRef(PathStorage), PathUtf16))
+ return false;
+
+ DWORD Attr = ::GetFileAttributesW(PathUtf16.begin());
+ return (Attr != INVALID_FILE_ATTRIBUTES) && !(Attr & FILE_ATTRIBUTE_READONLY);
+}
+
bool can_execute(const Twine &Path) {
SmallString<128> PathStorage;
SmallVector<wchar_t, 128> PathUtf16;