mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:07:36 +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:
parent
a98ae8f357
commit
774f328783
17 changed files with 44 additions and 46 deletions
|
@ -170,7 +170,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
if (di.has_error()) {
|
||||
status = 1;
|
||||
fprintf(stderr, "%s: %s\n", path.characters(), di.error_string());
|
||||
fprintf(stderr, "%s: %s\n", path.characters(), strerror(di.error().code()));
|
||||
}
|
||||
|
||||
while (di.has_next()) {
|
||||
|
@ -396,7 +396,8 @@ static int do_file_system_object_long(char const* path)
|
|||
Core::DirIterator di(path, flags);
|
||||
|
||||
if (di.has_error()) {
|
||||
if (di.error() == ENOTDIR) {
|
||||
auto error = di.error();
|
||||
if (error.code() == ENOTDIR) {
|
||||
struct stat stat {
|
||||
};
|
||||
int rc = lstat(path, &stat);
|
||||
|
@ -406,7 +407,7 @@ static int do_file_system_object_long(char const* path)
|
|||
return 0;
|
||||
return 2;
|
||||
}
|
||||
fprintf(stderr, "%s: %s\n", path, di.error_string());
|
||||
fprintf(stderr, "%s: %s\n", path, strerror(di.error().code()));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -510,7 +511,8 @@ int do_file_system_object_short(char const* path)
|
|||
|
||||
Core::DirIterator di(path, flags);
|
||||
if (di.has_error()) {
|
||||
if (di.error() == ENOTDIR) {
|
||||
auto error = di.error();
|
||||
if (error.code() == ENOTDIR) {
|
||||
size_t nprinted = 0;
|
||||
bool status = print_filesystem_object_short(path, path, &nprinted);
|
||||
printf("\n");
|
||||
|
@ -518,7 +520,7 @@ int do_file_system_object_short(char const* path)
|
|||
return 0;
|
||||
return 2;
|
||||
}
|
||||
fprintf(stderr, "%s: %s\n", path, di.error_string());
|
||||
fprintf(stderr, "%s: %s\n", path, strerror(di.error().code()));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue