summaryrefslogtreecommitdiff
path: root/Userland/Games/Spider/main.cpp
diff options
context:
space:
mode:
authorpbrw <borowski.pb1@gmail.com>2021-11-23 01:08:10 +0100
committerBrian Gianforcaro <b.gianfo@gmail.com>2021-11-22 21:03:45 -0800
commit71298ad9baf4e9ef245cb4febbad35bf355befd8 (patch)
tree991f14605e74afd0e387bcd5e00132e37779b2fe /Userland/Games/Spider/main.cpp
parent85ae298b85c51aabf64782e3625edeeff5221997 (diff)
downloadserenity-71298ad9baf4e9ef245cb4febbad35bf355befd8.zip
Spider: Port to LibMain
Simplified two pledge() and two unveil() by using TRY()
Diffstat (limited to 'Userland/Games/Spider/main.cpp')
-rw-r--r--Userland/Games/Spider/main.cpp28
1 files changed, 8 insertions, 20 deletions
diff --git a/Userland/Games/Spider/main.cpp b/Userland/Games/Spider/main.cpp
index a5dcb38425..8df279c878 100644
--- a/Userland/Games/Spider/main.cpp
+++ b/Userland/Games/Spider/main.cpp
@@ -18,8 +18,9 @@
#include <LibGUI/MessageBox.h>
#include <LibGUI/Statusbar.h>
#include <LibGUI/Window.h>
+#include <LibMain/Main.h>
+#include <LibSystem/Wrappers.h>
#include <stdio.h>
-#include <unistd.h>
enum class StatisticDisplay : u8 {
HighScore,
@@ -36,32 +37,19 @@ static String format_seconds(uint64_t seconds_elapsed)
return String::formatted("{:02}:{:02}:{:02}", hours, minutes, seconds);
}
-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(System::pledge("stdio recvfd sendfd rpath unix", nullptr));
- auto app = GUI::Application::construct(argc, argv);
+ auto app = GUI::Application::construct(arguments.argc, arguments.argv);
auto app_icon = GUI::Icon::default_icon("app-spider");
Config::pledge_domains("Spider");
- if (pledge("stdio recvfd sendfd rpath", nullptr) < 0) {
- perror("pledge");
- return 1;
- }
+ TRY(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(System::unveil("/res", "r"));
+ TRY(System::unveil(nullptr, nullptr));
auto window = GUI::Window::construct();
window->set_title("Spider");