summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2022-09-13 12:24:37 +0100
committerBrian Gianforcaro <b.gianfo@gmail.com>2022-09-18 18:57:28 -0700
commitc8bfb07b4146ba5c560866a0c1ea6236ea1d37eb (patch)
tree16877ad811435eaadd7e80acf9bcb052f75bb774
parent761f079a22bcb937e98d824bab603b2a2548200e (diff)
downloadserenity-c8bfb07b4146ba5c560866a0c1ea6236ea1d37eb.zip
Applets/Network: Port to Core::Stream
-rw-r--r--Userland/Applets/Network/main.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/Userland/Applets/Network/main.cpp b/Userland/Applets/Network/main.cpp
index cf67198a66..f4827196f3 100644
--- a/Userland/Applets/Network/main.cpp
+++ b/Userland/Applets/Network/main.cpp
@@ -5,7 +5,7 @@
*/
#include <LibCore/ArgsParser.h>
-#include <LibCore/File.h>
+#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibGUI/Action.h>
#include <LibGUI/Application.h>
@@ -109,14 +109,19 @@ private:
{
StringBuilder adapter_info;
- auto file = Core::File::construct("/proc/net/adapters");
- if (!file->open(Core::OpenMode::ReadOnly)) {
- dbgln("Error: Could not open {}: {}", file->name(), file->error_string());
- return adapter_info.to_string();
+ auto file_or_error = Core::Stream::File::open("/proc/net/adapters"sv, Core::Stream::OpenMode::Read);
+ if (file_or_error.is_error()) {
+ dbgln("Error: Could not open /proc/net/adapters: {}", file_or_error.error());
+ return "";
+ }
+
+ auto file_contents_or_error = file_or_error.value()->read_all();
+ if (file_contents_or_error.is_error()) {
+ dbgln("Error: Could not read /proc/net/adapters: {}", file_contents_or_error.error());
+ return "";
}
- auto file_contents = file->read_all();
- auto json = JsonValue::from_string(file_contents);
+ auto json = JsonValue::from_string(file_contents_or_error.value());
if (json.is_error())
return adapter_info.to_string();