mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:14:58 +00:00
netstat: Port to Core::Stream
This commit is contained in:
parent
b5f4e96e71
commit
c8b3e68c6e
1 changed files with 5 additions and 10 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue