mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-25 10:48:53 +00:00
Utilities/w: Port to Core::Stream
This commit is contained in:
parent
8d798c2716
commit
fde9cba2a0
Notes:
sideshowbarker
2024-07-17 17:38:29 +09:00
Author: https://github.com/AtkinsSJ
Commit: fde9cba2a0
Pull-request: https://github.com/SerenityOS/serenity/pull/15244
Reviewed-by: https://github.com/davidot ✅
Reviewed-by: https://github.com/demostanis
1 changed files with 4 additions and 3 deletions
|
@ -7,8 +7,8 @@
|
||||||
#include <AK/JsonObject.h>
|
#include <AK/JsonObject.h>
|
||||||
#include <AK/JsonValue.h>
|
#include <AK/JsonValue.h>
|
||||||
#include <LibCore/DateTime.h>
|
#include <LibCore/DateTime.h>
|
||||||
#include <LibCore/File.h>
|
|
||||||
#include <LibCore/ProcessStatisticsReader.h>
|
#include <LibCore/ProcessStatisticsReader.h>
|
||||||
|
#include <LibCore/Stream.h>
|
||||||
#include <LibCore/System.h>
|
#include <LibCore/System.h>
|
||||||
#include <LibMain/Main.h>
|
#include <LibMain/Main.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
|
@ -25,8 +25,9 @@ ErrorOr<int> serenity_main(Main::Arguments)
|
||||||
TRY(Core::System::unveil("/sys/kernel/processes", "r"));
|
TRY(Core::System::unveil("/sys/kernel/processes", "r"));
|
||||||
TRY(Core::System::unveil(nullptr, nullptr));
|
TRY(Core::System::unveil(nullptr, nullptr));
|
||||||
|
|
||||||
auto file = TRY(Core::File::open("/var/run/utmp", Core::OpenMode::ReadOnly));
|
auto file = TRY(Core::Stream::File::open("/var/run/utmp"sv, Core::Stream::OpenMode::Read));
|
||||||
auto json = TRY(JsonValue::from_string(file->read_all()));
|
auto file_contents = TRY(file->read_all());
|
||||||
|
auto json = TRY(JsonValue::from_string(file_contents));
|
||||||
if (!json.is_object()) {
|
if (!json.is_object()) {
|
||||||
warnln("Error: Could not parse /var/run/utmp");
|
warnln("Error: Could not parse /var/run/utmp");
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue