mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:57:45 +00:00
arp: Port to Core::Stream
This commit is contained in:
parent
4ad1695c78
commit
5a0c298074
1 changed files with 4 additions and 14 deletions
|
@ -12,7 +12,7 @@
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
#include <LibCore/File.h>
|
#include <LibCore/Stream.h>
|
||||||
#include <LibCore/System.h>
|
#include <LibCore/System.h>
|
||||||
#include <LibMain/Main.h>
|
#include <LibMain/Main.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
@ -89,19 +89,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
outln();
|
outln();
|
||||||
|
|
||||||
if (!flag_set && !flag_delete) {
|
if (!flag_set && !flag_delete) {
|
||||||
auto file = Core::File::construct("/sys/kernel/net/arp");
|
auto file = TRY(Core::Stream::File::open("/sys/kernel/net/arp"sv, Core::Stream::OpenMode::Read));
|
||||||
if (!file->open(Core::OpenMode::ReadOnly)) {
|
auto file_contents = TRY(file->read_all());
|
||||||
warnln("Failed to open {}: {}", file->name(), file->error_string());
|
auto json = TRY(JsonValue::from_string(file_contents));
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto file_contents = file->read_all();
|
|
||||||
auto json_or_error = JsonValue::from_string(file_contents);
|
|
||||||
if (json_or_error.is_error()) {
|
|
||||||
warnln("Failed to decode JSON: {}", json_or_error.error());
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
auto json = json_or_error.release_value();
|
|
||||||
|
|
||||||
Vector<JsonValue> sorted_regions = json.as_array().values();
|
Vector<JsonValue> sorted_regions = json.as_array().values();
|
||||||
quick_sort(sorted_regions, [](auto& a, auto& b) {
|
quick_sort(sorted_regions, [](auto& a, auto& b) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue