summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Pereira <pmh.pereira@gmail.com>2021-11-23 10:41:06 +0000
committerAndreas Kling <kling@serenityos.org>2021-11-23 22:55:50 +0100
commit8d3059c6f551737269953b03ba3fc9dcb6f80fd2 (patch)
tree134f70481c3812bb1e73ead030674ee192406483
parentc4e49e19556db92256fda74f085410717b815593 (diff)
downloadserenity-8d3059c6f551737269953b03ba3fc9dcb6f80fd2.zip
Solitaire: Port to LibMain
Simplified two pledge() and two unveil() by using TRY().
-rw-r--r--Userland/Games/Solitaire/CMakeLists.txt2
-rw-r--r--Userland/Games/Solitaire/main.cpp28
2 files changed, 9 insertions, 21 deletions
diff --git a/Userland/Games/Solitaire/CMakeLists.txt b/Userland/Games/Solitaire/CMakeLists.txt
index 42eb2b3c7a..9ee8c174a9 100644
--- a/Userland/Games/Solitaire/CMakeLists.txt
+++ b/Userland/Games/Solitaire/CMakeLists.txt
@@ -13,4 +13,4 @@ set(SOURCES
)
serenity_app(Solitaire ICON app-solitaire)
-target_link_libraries(Solitaire LibCards LibConfig LibGUI LibGfx LibCore)
+target_link_libraries(Solitaire LibCards LibConfig LibGUI LibGfx LibCore LibMain)
diff --git a/Userland/Games/Solitaire/main.cpp b/Userland/Games/Solitaire/main.cpp
index 5c43930fed..964e5b6e18 100644
--- a/Userland/Games/Solitaire/main.cpp
+++ b/Userland/Games/Solitaire/main.cpp
@@ -8,6 +8,7 @@
#include "Game.h"
#include <Games/Solitaire/SolitaireGML.h>
#include <LibConfig/Client.h>
+#include <LibCore/System.h>
#include <LibCore/Timer.h>
#include <LibGUI/Action.h>
#include <LibGUI/ActionGroup.h>
@@ -18,35 +19,22 @@
#include <LibGUI/MessageBox.h>
#include <LibGUI/Statusbar.h>
#include <LibGUI/Window.h>
+#include <LibMain/Main.h>
#include <stdio.h>
-#include <unistd.h>
-int main(int argc, char** argv)
+ErrorOr<int> serenity_main(Main::Arguments arguments)
{
- if (pledge("stdio recvfd sendfd rpath unix", nullptr) < 0) {
- perror("pledge");
- return 1;
- }
+ TRY(Core::System::pledge("stdio recvfd sendfd rpath unix", nullptr));
- auto app = GUI::Application::construct(argc, argv);
+ auto app = GUI::Application::construct(arguments);
auto app_icon = GUI::Icon::default_icon("app-solitaire");
Config::pledge_domains("Solitaire");
- if (pledge("stdio recvfd sendfd rpath", nullptr) < 0) {
- perror("pledge");
- return 1;
- }
+ TRY(Core::System::pledge("stdio recvfd sendfd rpath", nullptr));
- if (unveil("/res", "r") < 0) {
- perror("unveil");
- return 1;
- }
-
- if (unveil(nullptr, nullptr) < 0) {
- perror("unveil");
- return 1;
- }
+ TRY(Core::System::unveil("/res", "r"));
+ TRY(Core::System::unveil(nullptr, nullptr));
auto window = GUI::Window::construct();
window->set_title("Solitaire");