diff options
author | Michael J. Spencer <bigcheesegs@gmail.com> | 2010-12-09 17:37:02 +0000 |
---|---|---|
committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2010-12-09 17:37:02 +0000 |
commit | 730f51ad96f0fd8babb9db3f2145b8698ca9bd73 (patch) | |
tree | 0a08c8d43d554442627dac960d0113f636eb5ec7 /llvm/lib/Support | |
parent | 7b6fef82d43a4e121a284ebabf5de94c3485b29a (diff) | |
download | bcm5719-llvm-730f51ad96f0fd8babb9db3f2145b8698ca9bd73.tar.gz bcm5719-llvm-730f51ad96f0fd8babb9db3f2145b8698ca9bd73.zip |
Support/FileSystem: Change file_status predicate functions that cannot fail to
return their result instead of an error_code. Also add some missing predicate
functions.
llvm-svn: 121380
Diffstat (limited to 'llvm/lib/Support')
-rw-r--r-- | llvm/lib/Support/PathV2.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/llvm/lib/Support/PathV2.cpp b/llvm/lib/Support/PathV2.cpp index 60e03e05f54..54522702d1e 100644 --- a/llvm/lib/Support/PathV2.cpp +++ b/llvm/lib/Support/PathV2.cpp @@ -625,6 +625,33 @@ error_code create_directories(const Twine &path, bool &existed) { return create_directory(p, existed); } +bool exists(file_status status) { + return status_known(status) && status.type() != file_type::file_not_found; +} + +bool status_known(file_status s) { + return s.type() != file_type::status_error; +} + +bool is_directory(file_status status) { + return status.type() == file_type::directory_file; +} + +bool is_regular_file(file_status status) { + return status.type() == file_type::regular_file; +} + +bool is_symlink(file_status status) { + return status.type() == file_type::symlink_file; +} + +bool is_other(file_status status) { + return exists(status) && + !is_regular_file(status) && + !is_directory(status) && + !is_symlink(status); +} + void directory_entry::replace_filename(const Twine &filename, file_status st, file_status symlink_st) { SmallString<128> path(Path.begin(), Path.end()); |