[Lldb-commits] [lldb] r345787 - [FileSystem] Remove EnumerateDirectory
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Wed Oct 31 15:09:58 PDT 2018
Author: jdevlieghere
Date: Wed Oct 31 15:09:58 2018
New Revision: 345787
URL: http://llvm.org/viewvc/llvm-project?rev=345787&view=rev
Log:
[FileSystem] Remove EnumerateDirectory
The new implementation of EnumerateDirectory relies on `::no_push()`
being implemented for the VFS recursive directory iterators. However
this patch (D53465) hasn't been landed yet.
Modified:
lldb/trunk/include/lldb/Host/FileSystem.h
lldb/trunk/source/Host/common/FileSystem.cpp
lldb/trunk/unittests/Host/FileSystemTest.cpp
Modified: lldb/trunk/include/lldb/Host/FileSystem.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/FileSystem.h?rev=345787&r1=345786&r2=345787&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/FileSystem.h (original)
+++ lldb/trunk/include/lldb/Host/FileSystem.h Wed Oct 31 15:09:58 2018
@@ -92,28 +92,6 @@ public:
void Resolve(FileSpec &file_spec);
/// @}
- enum EnumerateDirectoryResult {
- /// Enumerate next entry in the current directory.
- eEnumerateDirectoryResultNext,
- /// Recurse into the current entry if it is a directory or symlink, or next
- /// if not.
- eEnumerateDirectoryResultEnter,
- /// Stop directory enumerations at any level.
- eEnumerateDirectoryResultQuit
- };
-
- typedef EnumerateDirectoryResult (*EnumerateDirectoryCallbackType)(
- void *baton, llvm::sys::fs::file_type file_type, llvm::StringRef);
-
- typedef std::function<EnumerateDirectoryResult(
- llvm::sys::fs::file_type file_type, llvm::StringRef)>
- DirectoryCallback;
-
- void EnumerateDirectory(llvm::Twine path, bool find_directories,
- bool find_files, bool find_other,
- EnumerateDirectoryCallbackType callback,
- void *callback_baton);
-
std::error_code GetRealPath(const llvm::Twine &path,
llvm::SmallVectorImpl<char> &output) const;
Modified: lldb/trunk/source/Host/common/FileSystem.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/FileSystem.cpp?rev=345787&r1=345786&r2=345787&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/FileSystem.cpp (original)
+++ lldb/trunk/source/Host/common/FileSystem.cpp Wed Oct 31 15:09:58 2018
@@ -96,36 +96,6 @@ bool FileSystem::Readable(const FileSpec
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);
}
Modified: lldb/trunk/unittests/Host/FileSystemTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Host/FileSystemTest.cpp?rev=345787&r1=345786&r2=345787&view=diff
==============================================================================
--- lldb/trunk/unittests/Host/FileSystemTest.cpp (original)
+++ lldb/trunk/unittests/Host/FileSystemTest.cpp Wed Oct 31 15:09:58 2018
@@ -265,27 +265,3 @@ TEST(FileSystemTest, Resolve) {
EXPECT_EQ("bogus", file_spec.GetPath());
}
}
-
-FileSystem::EnumerateDirectoryResult
-VFSCallback(void *baton, llvm::sys::fs::file_type file_type,
- llvm::StringRef path) {
- auto visited = static_cast<std::vector<std::string> *>(baton);
- visited->push_back(path.str());
- return FileSystem::eEnumerateDirectoryResultNext;
-}
-
-TEST(FileSystemTest, EnumerateDirectory) {
- FileSystem fs(GetSimpleDummyFS());
-
- std::vector<std::string> visited;
-
- constexpr bool find_directories = true;
- constexpr bool find_files = true;
- constexpr bool find_other = true;
-
- fs.EnumerateDirectory("/", find_directories, find_files, find_other,
- VFSCallback, &visited);
-
- EXPECT_THAT(visited,
- testing::UnorderedElementsAre("/foo", "/bar", "/baz", "/qux"));
-}
More information about the lldb-commits
mailing list