diff options
author | Pedro Pereira <pmh.pereira@gmail.com> | 2021-11-23 10:37:19 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-11-23 22:55:56 +0100 |
commit | 3ca2f192afece98f80525eb76c90339c5c843c59 (patch) | |
tree | d7d43ad66bd20024b16e1ae20941ae66faace069 /Userland/Games | |
parent | 8d3059c6f551737269953b03ba3fc9dcb6f80fd2 (diff) | |
download | serenity-3ca2f192afece98f80525eb76c90339c5c843c59.zip |
GameOfLife: Port to LibMain
Simplified two pledge() and two unveil() by using TRY().
Diffstat (limited to 'Userland/Games')
-rw-r--r-- | Userland/Games/GameOfLife/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Userland/Games/GameOfLife/main.cpp | 34 |
2 files changed, 12 insertions, 24 deletions
diff --git a/Userland/Games/GameOfLife/CMakeLists.txt b/Userland/Games/GameOfLife/CMakeLists.txt index a8421a1e8b..8715c17fd4 100644 --- a/Userland/Games/GameOfLife/CMakeLists.txt +++ b/Userland/Games/GameOfLife/CMakeLists.txt @@ -15,4 +15,4 @@ set(SOURCES ) serenity_app(GameOfLife ICON app-gameoflife) -target_link_libraries(GameOfLife LibGUI) +target_link_libraries(GameOfLife LibGUI LibMain) diff --git a/Userland/Games/GameOfLife/main.cpp b/Userland/Games/GameOfLife/main.cpp index 1262260575..dec2c28fb6 100644 --- a/Userland/Games/GameOfLife/main.cpp +++ b/Userland/Games/GameOfLife/main.cpp @@ -7,6 +7,7 @@ #include "BoardWidget.h" #include <Games/GameOfLife/GameOfLifeGML.h> +#include <LibCore/System.h> #include <LibGUI/Application.h> #include <LibGUI/BoxLayout.h> #include <LibGUI/Button.h> @@ -18,33 +19,20 @@ #include <LibGUI/Toolbar.h> #include <LibGUI/ToolbarContainer.h> #include <LibGUI/Window.h> -#include <unistd.h> +#include <LibMain/Main.h> const char* click_tip = "Tip: click the board to toggle individual cells, or click+drag to toggle multiple cells"; -int main(int argc, char** argv) +ErrorOr<int> serenity_main(Main::Arguments arguments) { - if (pledge("stdio rpath recvfd sendfd unix", nullptr) < 0) { - perror("pledge"); - return 1; - } - - auto app = GUI::Application::construct(argc, argv); - - if (pledge("stdio rpath recvfd sendfd", nullptr) < 0) { - perror("pledge"); - return 1; - } - - if (unveil("/res", "r") < 0) { - perror("unveil"); - return 1; - } - - if (unveil(nullptr, nullptr) < 0) { - perror("unveil"); - return 1; - } + TRY(Core::System::pledge("stdio rpath recvfd sendfd unix", nullptr)); + + auto app = GUI::Application::construct(arguments); + + TRY(Core::System::pledge("stdio rpath recvfd sendfd", nullptr)); + + TRY(Core::System::unveil("/res", "r")); + TRY(Core::System::unveil(nullptr, nullptr)); auto app_icon = GUI::Icon::default_icon("app-gameoflife"); |