summaryrefslogtreecommitdiff
path: root/Userland/Applications/Assistant
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2023-03-02 17:45:38 +0000
committerAndreas Kling <kling@serenityos.org>2023-03-05 20:23:42 +0100
commit3daaf476070c8a76e2a7d69e5c6ad5984fe24e6f (patch)
tree99da39abf78d5d80f1140257aceed9199b76e454 /Userland/Applications/Assistant
parent728b07fbf64d4a34ef928fddc7ac185bf656c438 (diff)
downloadserenity-3daaf476070c8a76e2a7d69e5c6ad5984fe24e6f.zip
Assistant: Migrate to Directory::for_each_entry()
Diffstat (limited to 'Userland/Applications/Assistant')
-rw-r--r--Userland/Applications/Assistant/Providers.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/Userland/Applications/Assistant/Providers.cpp b/Userland/Applications/Assistant/Providers.cpp
index fc3b7dfc97..89b740857e 100644
--- a/Userland/Applications/Assistant/Providers.cpp
+++ b/Userland/Applications/Assistant/Providers.cpp
@@ -8,7 +8,7 @@
#include <AK/FuzzyMatch.h>
#include <AK/LexicalPath.h>
#include <AK/URL.h>
-#include <LibCore/DirIterator.h>
+#include <LibCore/Directory.h>
#include <LibCore/ElapsedTimer.h>
#include <LibCore/Process.h>
#include <LibCore/StandardPaths.h>
@@ -174,27 +174,25 @@ void FileProvider::build_filesystem_cache()
if (base_directory.template is_one_of("/dev"sv, "/proc"sv, "/sys"sv))
continue;
- Core::DirIterator di(base_directory, Core::DirIterator::SkipDots);
-
- while (di.has_next()) {
- auto path = di.next_path();
+ // FIXME: Propagate errors.
+ (void)Core::Directory::for_each_entry(base_directory, Core::DirIterator::SkipDots, [&](auto const& entry, auto const& directory) -> ErrorOr<IterationDecision> {
struct stat st = {};
- if (fstatat(di.fd(), path.characters(), &st, AT_SYMLINK_NOFOLLOW) < 0) {
+ if (fstatat(directory.fd(), entry.name.characters(), &st, AT_SYMLINK_NOFOLLOW) < 0) {
perror("fstatat");
- continue;
+ return IterationDecision::Continue;
}
if (S_ISLNK(st.st_mode))
- continue;
-
- auto full_path = LexicalPath::join(slash, base_directory, path).string();
+ return IterationDecision::Continue;
+ auto full_path = LexicalPath::join(directory.path().string(), entry.name).string();
m_full_path_cache.append(full_path);
if (S_ISDIR(st.st_mode)) {
m_work_queue.enqueue(full_path);
}
- }
+ return IterationDecision::Continue;
+ });
}
dbgln("Built cache in {} ms", timer.elapsed());
return 0;