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
diff --git a/lib/Support/PathV2.cpp b/lib/Support/PathV2.cpp
index dbfde54..7d4d6d1 100644
--- a/lib/Support/PathV2.cpp
+++ b/lib/Support/PathV2.cpp
@@ -671,6 +671,21 @@
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