aboutsummaryrefslogtreecommitdiff
path: root/lib/Support/Unix
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Support/Unix')
-rw-r--r--lib/Support/Unix/PathV2.inc14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/Support/Unix/PathV2.inc b/lib/Support/Unix/PathV2.inc
index 1368a82658..fc0d4a09a7 100644
--- a/lib/Support/Unix/PathV2.inc
+++ b/lib/Support/Unix/PathV2.inc
@@ -146,6 +146,20 @@ error_code copy_file(const Twine &from, const Twine &to, copy_option copt) {
return make_error_code(errc::success);
}
+error_code create_directory(const Twine &path, bool &existed) {
+ SmallString<128> path_storage;
+ StringRef p = path.toNullTerminatedStringRef(path_storage);
+
+ if (::mkdir(p.begin(), 0700) == -1) {
+ if (errno != EEXIST)
+ return error_code(errno, system_category());
+ existed = true;
+ } else
+ existed = false;
+
+ return make_error_code(errc::success);
+}
+
error_code exists(const Twine &path, bool &result) {
SmallString<128> path_storage;
StringRef p = path.toNullTerminatedStringRef(path_storage);