summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorPedro Pereira <pmh.pereira@gmail.com>2021-11-22 20:22:12 +0000
committerAndreas Kling <kling@serenityos.org>2021-11-22 21:56:31 +0100
commita0c80a6f17ce4e4e45e667a2b824931b9845ff9f (patch)
tree5eb03220e3562fd5f4bb1ef5b10e15b8ba6a7b8b /Userland
parent0ed3520ef5c84ad1cfb9640ebe1b4c2fac690f0e (diff)
downloadserenity-a0c80a6f17ce4e4e45e667a2b824931b9845ff9f.zip
Minesweeper: Port to LibMain
Simplified two unveil() and two pledge() by using TRY().
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Games/Minesweeper/CMakeLists.txt2
-rw-r--r--Userland/Games/Minesweeper/main.cpp28
2 files changed, 9 insertions, 21 deletions
diff --git a/Userland/Games/Minesweeper/CMakeLists.txt b/Userland/Games/Minesweeper/CMakeLists.txt
index fc74b7124b..8118226563 100644
--- a/Userland/Games/Minesweeper/CMakeLists.txt
+++ b/Userland/Games/Minesweeper/CMakeLists.txt
@@ -14,4 +14,4 @@ set(SOURCES
)
serenity_app(Minesweeper ICON app-minesweeper)
-target_link_libraries(Minesweeper LibGUI LibConfig)
+target_link_libraries(Minesweeper LibGUI LibConfig LibMain)
diff --git a/Userland/Games/Minesweeper/main.cpp b/Userland/Games/Minesweeper/main.cpp
index d8b8237357..3bbdbec59e 100644
--- a/Userland/Games/Minesweeper/main.cpp
+++ b/Userland/Games/Minesweeper/main.cpp
@@ -18,34 +18,22 @@
#include <LibGUI/Menubar.h>
#include <LibGUI/SeparatorWidget.h>
#include <LibGUI/Window.h>
+#include <LibMain/Main.h>
+#include <LibSystem/Wrappers.h>
#include <stdio.h>
-#include <unistd.h>
-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;
- }
+ TRY(System::pledge("stdio rpath recvfd sendfd unix", nullptr));
- auto app = GUI::Application::construct(argc, argv);
+ auto app = GUI::Application::construct(arguments.argc, arguments.argv);
Config::pledge_domains("Minesweeper");
- if (pledge("stdio rpath recvfd sendfd", nullptr) < 0) {
- perror("pledge");
- return 1;
- }
+ TRY(System::pledge("stdio rpath recvfd sendfd", nullptr));
- if (unveil("/res", "r") < 0) {
- perror("unveil");
- return 1;
- }
-
- if (unveil(nullptr, nullptr) < 0) {
- perror("unveil");
- return 1;
- }
+ TRY(System::unveil("/res", "r"));
+ TRY(System::unveil(nullptr, nullptr));
auto app_icon = GUI::Icon::default_icon("app-minesweeper");