mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-26 12:12:03 +00:00
LibGUI: Added error events to FileSystemModel
This will allow us to catch errors early on FileManager
This commit is contained in:
parent
802c06ab7b
commit
451b3fa73c
Notes:
sideshowbarker
2024-07-19 17:35:09 +09:00
Author: https://github.com/anpep
Commit: 451b3fa73c
Pull-request: https://github.com/SerenityOS/serenity/pull/1907
Reviewed-by: https://github.com/alimpfard
Reviewed-by: https://github.com/awesomekling
2 changed files with 18 additions and 5 deletions
|
@ -60,6 +60,7 @@ bool FileSystemModel::Node::fetch_data(const String& full_path, bool is_root)
|
|||
else
|
||||
rc = lstat(full_path.characters(), &st);
|
||||
if (rc < 0) {
|
||||
m_error = errno;
|
||||
perror("stat/lstat");
|
||||
return false;
|
||||
}
|
||||
|
@ -95,6 +96,7 @@ void FileSystemModel::Node::traverse_if_needed(const FileSystemModel& model)
|
|||
auto full_path = this->full_path(model);
|
||||
Core::DirIterator di(full_path, Core::DirIterator::SkipDots);
|
||||
if (di.has_error()) {
|
||||
m_error = di.error();
|
||||
fprintf(stderr, "DirIterator: %s\n", di.error_string());
|
||||
return;
|
||||
}
|
||||
|
@ -288,11 +290,14 @@ static String permission_string(mode_t mode)
|
|||
void FileSystemModel::set_root_path(const StringView& root_path)
|
||||
{
|
||||
m_root_path = canonicalized_path(root_path);
|
||||
|
||||
if (on_root_path_change)
|
||||
on_root_path_change();
|
||||
|
||||
update();
|
||||
|
||||
if (m_root->has_error()) {
|
||||
if (on_error)
|
||||
on_error(m_root->error(), m_root->error_string());
|
||||
} else if (on_complete) {
|
||||
on_complete();
|
||||
}
|
||||
}
|
||||
|
||||
void FileSystemModel::update()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue