diff options
author | Michael J. Spencer <bigcheesegs@gmail.com> | 2010-12-01 06:21:53 +0000 |
---|---|---|
committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2010-12-01 06:21:53 +0000 |
commit | ce2b68fb5444e712da14d214994c05bd231f221f (patch) | |
tree | c975ab19fc8533466907e56a9c16909a6fb1b1db /lib/Support/PathV2.cpp | |
parent | ae18008584b5b38a44991bf7cdf02870f75c349a (diff) |
Support/PathV2: Add is_{absolute,relative} implementation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120560 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/PathV2.cpp')
-rw-r--r-- | lib/Support/PathV2.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/Support/PathV2.cpp b/lib/Support/PathV2.cpp index 57ccf893d9..a4a3f38341 100644 --- a/lib/Support/PathV2.cpp +++ b/lib/Support/PathV2.cpp @@ -642,6 +642,30 @@ error_code has_extension(const Twine &path, bool &result) { return make_error_code(errc::success); } +error_code is_absolute(const Twine &path, bool &result) { + SmallString<128> path_storage; + StringRef p = path.toStringRef(path_storage); + + bool rootDir = false, + rootName = false; + if (error_code ec = has_root_directory(p, rootDir)) return ec; +#ifdef LLVM_ON_WIN32 + if (error_code ec = has_root_name(p, rootName)) return ec; +#else + rootName = true; +#endif + + result = rootDir && rootName; + return make_error_code(errc::success); +} + +error_code is_relative(const Twine &path, bool &result) { + bool res; + error_code ec = is_absolute(path, res); + result = !res; + return ec; +} + } } } |