summaryrefslogtreecommitdiff
path: root/Userland/Utilities/ls.cpp
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2023-03-01 15:55:15 +0000
committerAndreas Kling <kling@serenityos.org>2023-03-05 20:23:42 +0100
commit774f328783db31a02eba76d7c55d53a0b41b1508 (patch)
tree4fc9c393af9d93f2925d38234c9c520bb2e05d75 /Userland/Utilities/ls.cpp
parenta98ae8f35704737e37920b7ddb516ea703a3dca7 (diff)
downloadserenity-774f328783db31a02eba76d7c55d53a0b41b1508.zip
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.
Diffstat (limited to 'Userland/Utilities/ls.cpp')
-rw-r--r--Userland/Utilities/ls.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/Userland/Utilities/ls.cpp b/Userland/Utilities/ls.cpp
index b41aec19d1..df4759f3f8 100644
--- a/Userland/Utilities/ls.cpp
+++ b/Userland/Utilities/ls.cpp
@@ -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;
}