summaryrefslogtreecommitdiff
path: root/lib/Support/PathV2.cpp
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2010-12-03 05:42:11 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2010-12-03 05:42:11 +0000
commitb83769f36afe5221ca6aa7741561801836a179cb (patch)
treeb59e4264aae3529bdd995d3663f9229188a5251f /lib/Support/PathV2.cpp
parent2df042cb32ecb8d2e1d499dfa27d5074c8b40e13 (diff)
downloadllvm-b83769f36afe5221ca6aa7741561801836a179cb.tar.gz
llvm-b83769f36afe5221ca6aa7741561801836a179cb.tar.bz2
llvm-b83769f36afe5221ca6aa7741561801836a179cb.tar.xz
Support/FileSystem: Add create_director{y,ies} implementations.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120790 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/PathV2.cpp')
-rw-r--r--lib/Support/PathV2.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/Support/PathV2.cpp b/lib/Support/PathV2.cpp
index dbfde54a73..7d4d6d1fc2 100644
--- a/lib/Support/PathV2.cpp
+++ b/lib/Support/PathV2.cpp
@@ -671,6 +671,21 @@ error_code is_relative(const Twine &path, bool &result) {
namespace fs {
+error_code create_directories(const Twine &path, bool &existed) {
+ SmallString<128> path_storage;
+ StringRef p = path.toStringRef(path_storage);
+
+ StringRef parent;
+ bool parent_exists;
+ if (error_code ec = path::parent_path(p, parent)) return ec;
+ if (error_code ec = fs::exists(parent, parent_exists)) return ec;
+
+ if (!parent_exists)
+ return create_directories(parent, existed);
+
+ return create_directory(p, existed);
+}
+
} // end namespace fs
} // end namespace sys
} // end namespace llvm