From c8b3e68c6eb7809f633a50e32f6cee995f0936d9 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Wed, 14 Sep 2022 16:57:17 +0100 Subject: [PATCH] netstat: Port to Core::Stream --- Userland/Utilities/netstat.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Userland/Utilities/netstat.cpp b/Userland/Utilities/netstat.cpp index d86ddd9a9f..0b21706545 100644 --- a/Userland/Utilities/netstat.cpp +++ b/Userland/Utilities/netstat.cpp @@ -11,8 +11,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -154,13 +154,8 @@ ErrorOr serenity_main(Main::Arguments arguments) } if (!has_protocol_flag || flag_tcp) { - auto file = Core::File::construct("/sys/kernel/net/tcp"); - if (!file->open(Core::OpenMode::ReadOnly)) { - warnln("Error: {}", file->error_string()); - return 1; - } - - auto file_contents = file->read_all(); + auto file = TRY(Core::Stream::File::open("/sys/kernel/net/tcp"sv, Core::Stream::OpenMode::Read)); + auto file_contents = TRY(file->read_all()); auto json_or_error = JsonValue::from_string(file_contents); if (json_or_error.is_error()) { warnln("Error: {}", json_or_error.error()); @@ -251,8 +246,8 @@ ErrorOr serenity_main(Main::Arguments arguments) } if (!has_protocol_flag || flag_udp) { - auto file = TRY(Core::File::open("/sys/kernel/net/udp", Core::OpenMode::ReadOnly)); - auto file_contents = file->read_all(); + auto file = TRY(Core::Stream::File::open("/sys/kernel/net/udp"sv, Core::Stream::OpenMode::Read)); + auto file_contents = TRY(file->read_all()); auto json = TRY(JsonValue::from_string(file_contents)); Vector sorted_regions = json.as_array().values();