aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/Path.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2015-10-05 13:02:43 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2015-10-05 13:02:43 +0000
commitae1d59967dc2c8bc09b3b60afc13754b45ec0ede (patch)
tree8014b4226f2bacabcb5b988ab2f2006951a73b64 /llvm/lib/Support/Path.cpp
parenteda554a9b426f456366b41d53e1d85d879da1026 (diff)
downloadllvm-ae1d59967dc2c8bc09b3b60afc13754b45ec0ede.zip
llvm-ae1d59967dc2c8bc09b3b60afc13754b45ec0ede.tar.gz
llvm-ae1d59967dc2c8bc09b3b60afc13754b45ec0ede.tar.bz2
[Support] Add a version of fs::make_absolute with a custom CWD.
This will be used soon from clang. llvm-svn: 249309
Diffstat (limited to 'llvm/lib/Support/Path.cpp')
-rw-r--r--llvm/lib/Support/Path.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp
index aa96074..653a984 100644
--- a/llvm/lib/Support/Path.cpp
+++ b/llvm/lib/Support/Path.cpp
@@ -740,7 +740,9 @@ std::error_code createUniqueDirectory(const Twine &Prefix,
true, 0, FS_Dir);
}
-std::error_code make_absolute(SmallVectorImpl<char> &path) {
+static std::error_code make_absolute(const Twine &current_directory,
+ SmallVectorImpl<char> &path,
+ bool use_current_directory) {
StringRef p(path.data(), path.size());
bool rootDirectory = path::has_root_directory(p),
@@ -756,7 +758,9 @@ std::error_code make_absolute(SmallVectorImpl<char> &path) {
// All of the following conditions will need the current directory.
SmallString<128> current_dir;
- if (std::error_code ec = current_path(current_dir))
+ if (use_current_directory)
+ current_directory.toVector(current_dir);
+ else if (std::error_code ec = current_path(current_dir))
return ec;
// Relative path. Prepend the current directory.
@@ -793,6 +797,15 @@ std::error_code make_absolute(SmallVectorImpl<char> &path) {
"occurred above!");
}
+std::error_code make_absolute(const Twine &current_directory,
+ SmallVectorImpl<char> &path) {
+ return make_absolute(current_directory, path, true);
+}
+
+std::error_code make_absolute(SmallVectorImpl<char> &path) {
+ return make_absolute(Twine(), path, false);
+}
+
std::error_code create_directories(const Twine &Path, bool IgnoreExisting,
perms Perms) {
SmallString<128> PathStorage;