diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-06-27 03:45:31 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-06-27 03:45:31 +0000 |
commit | 7ffacc4992129a8a8f2c6986c6bdc92802da91f9 (patch) | |
tree | 7f4e5676140f4c2ee0ab3ae24b20ab26f3668037 /llvm/lib/Support/Path.cpp | |
parent | 70bb43a11579615ec3707f293018efc94841d552 (diff) | |
download | bcm5719-llvm-7ffacc4992129a8a8f2c6986c6bdc92802da91f9.tar.gz bcm5719-llvm-7ffacc4992129a8a8f2c6986c6bdc92802da91f9.zip |
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.
llvm-svn: 185059
Diffstat (limited to 'llvm/lib/Support/Path.cpp')
-rw-r--r-- | llvm/lib/Support/Path.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp index 8b9e60a2d9e..a631c760fd7 100644 --- a/llvm/lib/Support/Path.cpp +++ b/llvm/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()); |