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 | 61187dd0ad3d8574f655074e3e7948193d90bb1e (patch) | |
tree | 079e0acc8c744b6498369fc0ce5bd3d14027a6d0 /lib/Support/PathV2.cpp | |
parent | 333fb04506233255f10d8095c9e2de5e5f0fdc6f (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121380 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/PathV2.cpp')
-rw-r--r-- | lib/Support/PathV2.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/Support/PathV2.cpp b/lib/Support/PathV2.cpp index 60e03e05f5..54522702d1 100644 --- a/lib/Support/PathV2.cpp +++ b/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()); |