ImageViewer: Migrate to Directory::for_each_entry()

This commit is contained in:
Sam Atkins 2023-03-02 17:46:37 +00:00 committed by Andreas Kling
parent c325a656ec
commit 8f3c77a5a3
Notes: sideshowbarker 2024-07-17 05:02:42 +09:00

View file

@ -12,7 +12,7 @@
#include <AK/LexicalPath.h>
#include <AK/StringBuilder.h>
#include <LibCore/DeprecatedFile.h>
#include <LibCore/DirIterator.h>
#include <LibCore/Directory.h>
#include <LibCore/MappedFile.h>
#include <LibCore/MimeData.h>
#include <LibCore/Timer.h>
@ -82,13 +82,13 @@ Vector<DeprecatedString> ViewWidget::load_files_from_directory(DeprecatedString
Vector<DeprecatedString> files_in_directory;
auto current_dir = LexicalPath(path).parent().string();
Core::DirIterator iterator(current_dir, Core::DirIterator::Flags::SkipDots);
while (iterator.has_next()) {
DeprecatedString file = iterator.next_full_path();
if (!Gfx::Bitmap::is_path_a_supported_image_format(file))
continue;
files_in_directory.append(file);
}
// FIXME: Propagate errors
(void)Core::Directory::for_each_entry(current_dir, Core::DirIterator::Flags::SkipDots, [&](auto const& entry, auto const& directory) -> ErrorOr<IterationDecision> {
auto full_path = LexicalPath::join(directory.path().string(), entry.name).string();
if (Gfx::Bitmap::is_path_a_supported_image_format(full_path))
files_in_directory.append(full_path);
return IterationDecision::Continue;
});
return files_in_directory;
}