summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Path.cpp
diff options
context:
space:
mode:
authorKristina Brooks <kristina@nym.hush.com>2018-09-12 22:08:10 +0000
committerKristina Brooks <kristina@nym.hush.com>2018-09-12 22:08:10 +0000
commit3a55d1ef2774a0a814bd9e12cd8f4b34afd2e6df (patch)
tree7dd9a2b89e24bc5a3f34ba4384561c6c285f773a /llvm/lib/Support/Path.cpp
parent2963c49087ebcae7c2f76ef738b8d5a73b262484 (diff)
downloadbcm5719-llvm-3a55d1ef2774a0a814bd9e12cd8f4b34afd2e6df.tar.gz
bcm5719-llvm-3a55d1ef2774a0a814bd9e12cd8f4b34afd2e6df.zip
[Support] sys::fs::directory_entry includes the file_type.
This is available on most platforms (Linux/Mac/Win/BSD) with no extra syscalls. On other platforms (e.g. Solaris) we stat() if this information is requested. This will allow switching clang's VFS to efficiently expose (path, type) when traversing a directory. Currently it exposes an entire Status, but does so by calling fs::status() on all platforms. Almost all callers only need the path, and all callers only need (path, type). Patch by sammccall (Sam McCall) Differential Revision: https://reviews.llvm.org/D51918 llvm-svn: 342089
Diffstat (limited to 'llvm/lib/Support/Path.cpp')
-rw-r--r--llvm/lib/Support/Path.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp
index 59c0aa6ee5e..41f25648985 100644
--- a/llvm/lib/Support/Path.cpp
+++ b/llvm/lib/Support/Path.cpp
@@ -1085,12 +1085,13 @@ std::error_code is_other(const Twine &Path, bool &Result) {
return std::error_code();
}
-void directory_entry::replace_filename(const Twine &filename,
- basic_file_status st) {
- SmallString<128> path = path::parent_path(Path);
- path::append(path, filename);
- Path = path.str();
- Status = st;
+void directory_entry::replace_filename(const Twine &Filename, file_type Type,
+ basic_file_status Status) {
+ SmallString<128> PathStr = path::parent_path(Path);
+ path::append(PathStr, Filename);
+ this->Path = PathStr.str();
+ this->Type = Type;
+ this->Status = Status;
}
ErrorOr<perms> getPermissions(const Twine &Path) {
OpenPOWER on IntegriCloud