summaryrefslogtreecommitdiffstats
path: root/llvm/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
commit31e310cda0e1660e3bada29096e29796aabe059a (patch)
tree7bd51cf9ee84c23f92c087d970a12c97c141d5c2 /llvm/lib/Support/PathV2.cpp
parent4a5fcbb92b2981589cf9fb1771d06a1f2ff775e2 (diff)
downloadbcm5719-llvm-31e310cda0e1660e3bada29096e29796aabe059a.tar.gz
bcm5719-llvm-31e310cda0e1660e3bada29096e29796aabe059a.zip
Support/FileSystem: Add create_director{y,ies} implementations.
llvm-svn: 120790
Diffstat (limited to 'llvm/lib/Support/PathV2.cpp')
-rw-r--r--llvm/lib/Support/PathV2.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/Support/PathV2.cpp b/llvm/lib/Support/PathV2.cpp
index dbfde54a73a..7d4d6d1fc28 100644
--- a/llvm/lib/Support/PathV2.cpp
+++ b/llvm/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
OpenPOWER on IntegriCloud