1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 09:14:58 +00:00

nproc: Port to Core::Stream

This commit is contained in:
Sam Atkins 2022-09-14 17:00:12 +01:00 committed by Linus Groh
parent c8b3e68c6e
commit bc76a4d787

View file

@ -5,17 +5,17 @@
*/
#include <AK/JsonObject.h>
#include <LibCore/File.h>
#include <LibCore/Stream.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
ErrorOr<int> serenity_main(Main::Arguments)
{
TRY(Core::System::pledge("stdio rpath"));
auto file = TRY(Core::File::open("/sys/kernel/cpuinfo", Core::OpenMode::ReadOnly));
auto file = TRY(Core::Stream::File::open("/sys/kernel/cpuinfo"sv, Core::Stream::OpenMode::Read));
auto buffer = file->read_all();
auto json = TRY(JsonValue::from_string({ buffer }));
auto buffer = TRY(file->read_all());
auto json = TRY(JsonValue::from_string(buffer));
auto const& cpuinfo_array = json.as_array();
outln("{}", cpuinfo_array.size());