mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:57:45 +00:00
nproc: Port to LibMain :^)
This commit is contained in:
parent
561e50108d
commit
f5927f167b
2 changed files with 8 additions and 15 deletions
|
@ -79,6 +79,7 @@ target_link_libraries(markdown-check LibMarkdown)
|
||||||
target_link_libraries(matroska LibVideo)
|
target_link_libraries(matroska LibVideo)
|
||||||
target_link_libraries(md LibMarkdown)
|
target_link_libraries(md LibMarkdown)
|
||||||
target_link_libraries(notify LibGUI)
|
target_link_libraries(notify LibGUI)
|
||||||
|
target_link_libraries(nproc LibMain)
|
||||||
target_link_libraries(open LibDesktop)
|
target_link_libraries(open LibDesktop)
|
||||||
target_link_libraries(pape LibGUI)
|
target_link_libraries(pape LibGUI)
|
||||||
target_link_libraries(passwd LibCrypt)
|
target_link_libraries(passwd LibCrypt)
|
||||||
|
|
|
@ -6,25 +6,17 @@
|
||||||
|
|
||||||
#include <AK/JsonObject.h>
|
#include <AK/JsonObject.h>
|
||||||
#include <LibCore/File.h>
|
#include <LibCore/File.h>
|
||||||
#include <stdio.h>
|
#include <LibMain/Main.h>
|
||||||
#include <unistd.h>
|
#include <LibSystem/Wrappers.h>
|
||||||
|
|
||||||
int main()
|
ErrorOr<int> serenity_main(Main::Arguments)
|
||||||
{
|
{
|
||||||
if (pledge("stdio rpath", nullptr) < 0) {
|
TRY(System::pledge("stdio rpath", nullptr));
|
||||||
perror("pledge");
|
auto file = TRY(Core::File::open("/proc/cpuinfo", Core::OpenMode::ReadOnly));
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto file = Core::File::construct("/proc/cpuinfo");
|
|
||||||
if (!file->open(Core::OpenMode::ReadOnly)) {
|
|
||||||
perror("Core::File::open()");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto buffer = file->read_all();
|
auto buffer = file->read_all();
|
||||||
auto json = JsonValue::from_string({ buffer });
|
auto json = TRY(JsonValue::from_string({ buffer }));
|
||||||
auto cpuinfo_array = json.value().as_array();
|
auto const& cpuinfo_array = json.as_array();
|
||||||
outln("{}", cpuinfo_array.size());
|
outln("{}", cpuinfo_array.size());
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue