mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:38:11 +00:00
nproc: Port to Core::Stream
This commit is contained in:
parent
c8b3e68c6e
commit
bc76a4d787
1 changed files with 4 additions and 4 deletions
|
@ -5,17 +5,17 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <AK/JsonObject.h>
|
#include <AK/JsonObject.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>
|
||||||
|
|
||||||
ErrorOr<int> serenity_main(Main::Arguments)
|
ErrorOr<int> serenity_main(Main::Arguments)
|
||||||
{
|
{
|
||||||
TRY(Core::System::pledge("stdio rpath"));
|
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 buffer = TRY(file->read_all());
|
||||||
auto json = TRY(JsonValue::from_string({ buffer }));
|
auto json = TRY(JsonValue::from_string(buffer));
|
||||||
auto const& cpuinfo_array = json.as_array();
|
auto const& cpuinfo_array = json.as_array();
|
||||||
outln("{}", cpuinfo_array.size());
|
outln("{}", cpuinfo_array.size());
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue