mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-08 20:32:56 +03:00
netstat: Port to Core::Stream
This commit is contained in:
parent
b5f4e96e71
commit
c8b3e68c6e
Notes:
sideshowbarker
2024-07-17 04:15:45 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/c8b3e68c6e Pull-request: https://github.com/SerenityOS/serenity/pull/15244 Reviewed-by: https://github.com/davidot ✅ Reviewed-by: https://github.com/demostanis
@ -11,8 +11,8 @@
|
||||
#include <AK/QuickSort.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/ProcessStatisticsReader.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <arpa/inet.h>
|
||||
@ -154,13 +154,8 @@ ErrorOr<int> 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<int> 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<JsonValue> sorted_regions = json.as_array().values();
|
||||
|
Loading…
Reference in New Issue
Block a user