mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 17:58:18 +03:00
Assistant: Migrate to Directory::for_each_entry()
This commit is contained in:
parent
728b07fbf6
commit
3daaf47607
Notes:
sideshowbarker
2024-07-17 03:03:37 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/3daaf47607 Pull-request: https://github.com/SerenityOS/serenity/pull/17694
@ -8,7 +8,7 @@
|
|||||||
#include <AK/FuzzyMatch.h>
|
#include <AK/FuzzyMatch.h>
|
||||||
#include <AK/LexicalPath.h>
|
#include <AK/LexicalPath.h>
|
||||||
#include <AK/URL.h>
|
#include <AK/URL.h>
|
||||||
#include <LibCore/DirIterator.h>
|
#include <LibCore/Directory.h>
|
||||||
#include <LibCore/ElapsedTimer.h>
|
#include <LibCore/ElapsedTimer.h>
|
||||||
#include <LibCore/Process.h>
|
#include <LibCore/Process.h>
|
||||||
#include <LibCore/StandardPaths.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))
|
if (base_directory.template is_one_of("/dev"sv, "/proc"sv, "/sys"sv))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Core::DirIterator di(base_directory, Core::DirIterator::SkipDots);
|
// FIXME: Propagate errors.
|
||||||
|
(void)Core::Directory::for_each_entry(base_directory, Core::DirIterator::SkipDots, [&](auto const& entry, auto const& directory) -> ErrorOr<IterationDecision> {
|
||||||
while (di.has_next()) {
|
|
||||||
auto path = di.next_path();
|
|
||||||
struct stat st = {};
|
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");
|
perror("fstatat");
|
||||||
continue;
|
return IterationDecision::Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (S_ISLNK(st.st_mode))
|
if (S_ISLNK(st.st_mode))
|
||||||
continue;
|
return IterationDecision::Continue;
|
||||||
|
|
||||||
auto full_path = LexicalPath::join(slash, base_directory, path).string();
|
|
||||||
|
|
||||||
|
auto full_path = LexicalPath::join(directory.path().string(), entry.name).string();
|
||||||
m_full_path_cache.append(full_path);
|
m_full_path_cache.append(full_path);
|
||||||
|
|
||||||
if (S_ISDIR(st.st_mode)) {
|
if (S_ISDIR(st.st_mode)) {
|
||||||
m_work_queue.enqueue(full_path);
|
m_work_queue.enqueue(full_path);
|
||||||
}
|
}
|
||||||
}
|
return IterationDecision::Continue;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
dbgln("Built cache in {} ms", timer.elapsed());
|
dbgln("Built cache in {} ms", timer.elapsed());
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user