Add a convenience createUniqueDirectory function.

There are a few valid situation where we care about the structure inside a
directory, but not about the directory itself. A simple example is for unit
testing directory traversal.

PathV1 had a function like this, add one to V2 and port existing users of the
created temp file and delete it hack to using it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185059 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Support/Path.cpp b/lib/Support/Path.cpp
index 8b9e60a..a631c76 100644
--- a/lib/Support/Path.cpp
+++ b/lib/Support/Path.cpp
@@ -642,6 +642,17 @@
   return fs::remove(P);
 }
 
+error_code createUniqueDirectory(const Twine &Prefix,
+                                 SmallVectorImpl<char> &ResultPath) {
+  // FIXME: This is double inefficient. We compute a unique file name, created
+  // it, delete it and keep only the directory.
+  error_code EC = unique_file(Prefix + "-%%%%%%/dummy", ResultPath);
+  if (EC)
+    return EC;
+  path::remove_filename(ResultPath);
+  return error_code::success();
+}
+
 error_code make_absolute(SmallVectorImpl<char> &path) {
   StringRef p(path.data(), path.size());