diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2023-03-02 17:46:37 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-03-05 20:23:42 +0100 |
commit | 8f3c77a5a3806908c751d979285b25c72de85aad (patch) | |
tree | d99dc9904a66bfd559534b8e139586afc3bee0b1 /Userland | |
parent | c325a656ec790b6459581a094e053281d7470704 (diff) | |
download | serenity-8f3c77a5a3806908c751d979285b25c72de85aad.zip |
ImageViewer: Migrate to Directory::for_each_entry()
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Applications/ImageViewer/ViewWidget.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/Userland/Applications/ImageViewer/ViewWidget.cpp b/Userland/Applications/ImageViewer/ViewWidget.cpp index 0941251da4..428aa9d18b 100644 --- a/Userland/Applications/ImageViewer/ViewWidget.cpp +++ b/Userland/Applications/ImageViewer/ViewWidget.cpp @@ -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; } |