1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-03 07:58:12 +00:00

PartitionEditor: Migrate to Directory::for_each_entry()

This commit is contained in:
Sam Atkins 2023-03-02 17:47:27 +00:00 committed by Andreas Kling
parent 3c25a9b5fe
commit 8110cf9fab

View file

@ -7,7 +7,7 @@
#include <Applications/PartitionEditor/PartitionEditorWindowGML.h> #include <Applications/PartitionEditor/PartitionEditorWindowGML.h>
#include <Applications/PartitionEditor/PartitionModel.h> #include <Applications/PartitionEditor/PartitionModel.h>
#include <LibCore/DeprecatedFile.h> #include <LibCore/DeprecatedFile.h>
#include <LibCore/DirIterator.h> #include <LibCore/Directory.h>
#include <LibCore/System.h> #include <LibCore/System.h>
#include <LibGUI/Application.h> #include <LibGUI/Application.h>
#include <LibGUI/ComboBox.h> #include <LibGUI/ComboBox.h>
@ -20,12 +20,13 @@
static Vector<DeprecatedString> get_device_paths() static Vector<DeprecatedString> get_device_paths()
{ {
auto device_paths = Vector<DeprecatedString>(); auto device_paths = Vector<DeprecatedString>();
Core::DirIterator iterator("/dev", Core::DirIterator::SkipParentAndBaseDir); // FIXME: Propagate errors.
while (iterator.has_next()) { (void)Core::Directory::for_each_entry("/dev"sv, Core::DirIterator::Flags::SkipParentAndBaseDir, [&](auto const& entry, auto const& directory) -> ErrorOr<IterationDecision> {
auto path = iterator.next_full_path(); auto full_path = LexicalPath::join(directory.path().string(), entry.name).string();
if (Core::DeprecatedFile::is_block_device(path)) if (Core::DeprecatedFile::is_block_device(full_path))
device_paths.append(path); device_paths.append(full_path);
} return IterationDecision::Continue;
});
return device_paths; return device_paths;
} }