diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2018-11-01 00:26:09 +0000 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2018-11-01 00:26:09 +0000 |
commit | 9ca491da2f336150d700dd1e00f27bcee23bdd09 (patch) | |
tree | 1644bd2568e44439dcaefe014555db62a405807c /lldb/source | |
parent | 6b67ff03002f39adf773f456aa4fd79bb22f3a04 (diff) | |
download | bcm5719-llvm-9ca491da2f336150d700dd1e00f27bcee23bdd09.tar.gz bcm5719-llvm-9ca491da2f336150d700dd1e00f27bcee23bdd09.zip |
[FileSystem] Re-add EnumerateDirectory
Re-enable EnumerateDirectory now that no_push is available in llvm (r345793).
llvm-svn: 345799
Diffstat (limited to 'lldb/source')
-rw-r--r-- | lldb/source/Host/common/FileSystem.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lldb/source/Host/common/FileSystem.cpp b/lldb/source/Host/common/FileSystem.cpp index c985ebb8115..aa181ecdd11 100644 --- a/lldb/source/Host/common/FileSystem.cpp +++ b/lldb/source/Host/common/FileSystem.cpp @@ -96,6 +96,36 @@ bool FileSystem::Readable(const FileSpec &file_spec) const { return Readable(file_spec.GetPath()); } +void FileSystem::EnumerateDirectory(Twine path, bool find_directories, + bool find_files, bool find_other, + EnumerateDirectoryCallbackType callback, + void *callback_baton) { + std::error_code EC; + vfs::recursive_directory_iterator Iter(*m_fs, path, EC); + vfs::recursive_directory_iterator End; + for (; Iter != End && !EC; Iter.increment(EC)) { + const auto &Item = *Iter; + ErrorOr<vfs::Status> Status = m_fs->status(Item.path()); + if (!Status) + break; + if (!find_files && Status->isRegularFile()) + continue; + if (!find_directories && Status->isDirectory()) + continue; + if (!find_other && Status->isOther()) + continue; + + auto Result = callback(callback_baton, Status->getType(), Item.path()); + if (Result == eEnumerateDirectoryResultQuit) + return; + if (Result == eEnumerateDirectoryResultNext) { + // Default behavior is to recurse. Opt out if the callback doesn't want + // this behavior. + Iter.no_push(); + } + } +} + std::error_code FileSystem::MakeAbsolute(SmallVectorImpl<char> &path) const { return m_fs->makeAbsolute(path); } |