diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2023-03-01 15:55:15 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-03-05 20:23:42 +0100 |
commit | 774f328783db31a02eba76d7c55d53a0b41b1508 (patch) | |
tree | 4fc9c393af9d93f2925d38234c9c520bb2e05d75 /Userland/Utilities/ls.cpp | |
parent | a98ae8f35704737e37920b7ddb516ea703a3dca7 (diff) | |
download | serenity-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.cpp | 12 |
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; } |