diff --git a/Userland/Services/WebServer/Client.cpp b/Userland/Services/WebServer/Client.cpp index bb0741225d..8c3fcd7f16 100644 --- a/Userland/Services/WebServer/Client.cpp +++ b/Userland/Services/WebServer/Client.cpp @@ -19,13 +19,13 @@ #include #include #include +#include #include #include #include #include #include #include -#include #include namespace WebServer { @@ -290,13 +290,14 @@ ErrorOr Client::handle_directory_listing(String const& requested_path, Str else TRY(path_builder.try_append(name)); - struct stat st; - memset(&st, 0, sizeof(st)); - int rc = stat(path_builder.to_deprecated_string().characters(), &st); - if (rc < 0) { - perror("stat"); + auto st_or_error = Core::System::stat(path_builder.string_view()); + if (st_or_error.is_error()) { + warnln("Skipping file: '{}'. {}", path_builder.string_view(), strerror(st_or_error.error().code())); + continue; } + auto st = st_or_error.release_value(); + bool is_directory = S_ISDIR(st.st_mode); TRY(builder.try_append(""sv));