diff options
author | Michael J. Spencer <bigcheesegs@gmail.com> | 2010-12-01 06:03:50 +0000 |
---|---|---|
committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2010-12-01 06:03:50 +0000 |
commit | 112a769379d4a56b2b9bf038bef5bbbb2517bfbd (patch) | |
tree | dd9ed0dde0beda417b8f57d8cd8106f1b3fdd419 /llvm/lib/Support/PathV2.cpp | |
parent | 4d0c6fdda600179e780297461e576ac4c4d6bf03 (diff) | |
download | bcm5719-llvm-112a769379d4a56b2b9bf038bef5bbbb2517bfbd.tar.gz bcm5719-llvm-112a769379d4a56b2b9bf038bef5bbbb2517bfbd.zip |
Support/PathV2: Add has_{root_path,root_name,root_directory,parent_path,filename,stem,extension} implementation.
llvm-svn: 120559
Diffstat (limited to 'llvm/lib/Support/PathV2.cpp')
-rw-r--r-- | llvm/lib/Support/PathV2.cpp | 88 |
1 files changed, 70 insertions, 18 deletions
diff --git a/llvm/lib/Support/PathV2.cpp b/llvm/lib/Support/PathV2.cpp index 47e59dd1cf1..57ccf893d9b 100644 --- a/llvm/lib/Support/PathV2.cpp +++ b/llvm/lib/Support/PathV2.cpp @@ -370,24 +370,6 @@ error_code root_directory(const StringRef &path, StringRef &result) { return make_error_code(errc::success); } -error_code has_root_name(const Twine &path, bool &result) { - SmallString<128> storage; - StringRef p = path.toStringRef(storage); - - if (error_code ec = root_name(p, p)) return ec; - result = !p.empty(); - return make_error_code(errc::success); -} - -error_code has_root_directory(const Twine &path, bool &result) { - SmallString<128> storage; - StringRef p = path.toStringRef(storage); - - if (error_code ec = root_directory(p, p)) return ec; - result = !p.empty(); - return make_error_code(errc::success); -} - error_code relative_path(const StringRef &path, StringRef &result) { StringRef root; if (error_code ec = root_path(path, root)) return ec; @@ -590,6 +572,76 @@ error_code extension(const StringRef &path, StringRef &result) { return make_error_code(errc::success); } +error_code has_root_name(const Twine &path, bool &result) { + SmallString<128> path_storage; + StringRef p = path.toStringRef(path_storage); + + if (error_code ec = root_name(p, p)) return ec; + + result = !p.empty(); + return make_error_code(errc::success); +} + +error_code has_root_directory(const Twine &path, bool &result) { + SmallString<128> path_storage; + StringRef p = path.toStringRef(path_storage); + + if (error_code ec = root_directory(p, p)) return ec; + + result = !p.empty(); + return make_error_code(errc::success); +} + +error_code has_root_path(const Twine &path, bool &result) { + SmallString<128> path_storage; + StringRef p = path.toStringRef(path_storage); + + if (error_code ec = root_path(p, p)) return ec; + + result = !p.empty(); + return make_error_code(errc::success); +} + +error_code has_filename(const Twine &path, bool &result) { + SmallString<128> path_storage; + StringRef p = path.toStringRef(path_storage); + + if (error_code ec = filename(p, p)) return ec; + + result = !p.empty(); + return make_error_code(errc::success); +} + +error_code has_parent_path(const Twine &path, bool &result) { + SmallString<128> path_storage; + StringRef p = path.toStringRef(path_storage); + + if (error_code ec = parent_path(p, p)) return ec; + + result = !p.empty(); + return make_error_code(errc::success); +} + +error_code has_stem(const Twine &path, bool &result) { + SmallString<128> path_storage; + StringRef p = path.toStringRef(path_storage); + + if (error_code ec = stem(p, p)) return ec; + + result = !p.empty(); + return make_error_code(errc::success); +} + +error_code has_extension(const Twine &path, bool &result) { + SmallString<128> path_storage; + StringRef p = path.toStringRef(path_storage); + + if (error_code ec = extension(p, p)) return ec; + + result = !p.empty(); + return make_error_code(errc::success); +} + } } } |