1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 09:07:44 +00:00

LibCore+Everywhere: Return an Error from DirIterator::error()

This also removes DirIterator::error_string(), since the same strerror()
string will be included when you print the Error itself. Except in `ls`
which is still using fprintf() for now.
This commit is contained in:
Sam Atkins 2023-03-01 15:55:15 +00:00 committed by Andreas Kling
parent a98ae8f357
commit 774f328783
17 changed files with 44 additions and 46 deletions

View file

@ -61,7 +61,7 @@ private:
Core::DirIterator iterator("/res/keymaps/", Core::DirIterator::Flags::SkipDots);
if (iterator.has_error()) {
GUI::MessageBox::show(nullptr, DeprecatedString::formatted("Error on reading mapping file list: {}", iterator.error_string()), "Keyboard settings"sv, GUI::MessageBox::Type::Error);
GUI::MessageBox::show(nullptr, DeprecatedString::formatted("Error on reading mapping file list: {}", iterator.error()), "Keyboard settings"sv, GUI::MessageBox::Type::Error);
GUI::Application::the()->quit(-1);
}

View file

@ -13,7 +13,6 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
static constexpr size_t FILES_ENCOUNTERED_UPDATE_STEP_SIZE = 25;
@ -93,8 +92,9 @@ HashMap<int, int> TreeNode::populate_filesize_tree(Vector<MountInfo>& mounts, Fu
Core::DirIterator dir_iterator(builder.to_deprecated_string(), Core::DirIterator::SkipParentAndBaseDir);
if (dir_iterator.has_error()) {
int error_sum = error_accumulator.get(dir_iterator.error()).value_or(0);
error_accumulator.set(dir_iterator.error(), error_sum + 1);
auto error_code = dir_iterator.error().code();
int error_sum = error_accumulator.get(error_code).value_or(0);
error_accumulator.set(error_code, error_sum + 1);
} else {
queue_entry.node->m_children = make<Vector<TreeNode>>();
while (dir_iterator.has_next()) {