summaryrefslogtreecommitdiff
path: root/lib/Support/Path.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-06-27 03:45:31 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-06-27 03:45:31 +0000
commit08ddd12e444880b4d570ac42a42414a227022190 (patch)
treed47e948fb007aea27ccdfd68c38dd88a2df19026 /lib/Support/Path.cpp
parente2b9912a7877d0c73e0c5863ae2ea668edca1de4 (diff)
downloadllvm-08ddd12e444880b4d570ac42a42414a227022190.tar.gz
llvm-08ddd12e444880b4d570ac42a42414a227022190.tar.bz2
llvm-08ddd12e444880b4d570ac42a42414a227022190.tar.xz
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
Diffstat (limited to 'lib/Support/Path.cpp')
-rw-r--r--lib/Support/Path.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/Support/Path.cpp b/lib/Support/Path.cpp
index 8b9e60a2d9..a631c760fd 100644
--- a/lib/Support/Path.cpp
+++ b/lib/Support/Path.cpp
@@ -642,6 +642,17 @@ error_code unique_file(const Twine &Model, SmallVectorImpl<char> &ResultPath,
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());