diff --git a/Userland/Applications/Spreadsheet/CMakeLists.txt b/Userland/Applications/Spreadsheet/CMakeLists.txt index 481eae1f54..2c3cb429ae 100644 --- a/Userland/Applications/Spreadsheet/CMakeLists.txt +++ b/Userland/Applications/Spreadsheet/CMakeLists.txt @@ -41,7 +41,7 @@ set(GENERATED_SOURCES ) serenity_app(Spreadsheet ICON app-spreadsheet) -target_link_libraries(Spreadsheet LibFileSystemAccessClient LibGUI LibJS LibWeb) +target_link_libraries(Spreadsheet LibFileSystemAccessClient LibGUI LibJS LibMain LibWeb) link_with_unicode_data(Spreadsheet) serenity_test(Writers/Test/TestXSVWriter.cpp Spreadsheet) diff --git a/Userland/Applications/Spreadsheet/main.cpp b/Userland/Applications/Spreadsheet/main.cpp index 277e3d2b8a..148e8d3e5f 100644 --- a/Userland/Applications/Spreadsheet/main.cpp +++ b/Userland/Applications/Spreadsheet/main.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, the SerenityOS developers. + * Copyright (c) 2020-2022, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause */ @@ -9,8 +9,10 @@ #include "Spreadsheet.h" #include "SpreadsheetWidget.h" #include +#include #include #include +#include #include #include #include @@ -19,23 +21,21 @@ #include #include #include +#include #include -int main(int argc, char* argv[]) +ErrorOr serenity_main(Main::Arguments arguments) { - if (pledge("stdio recvfd sendfd rpath fattr unix cpath wpath thread", nullptr) < 0) { - perror("pledge"); - return 1; - } + TRY(Core::System::pledge("stdio recvfd sendfd rpath fattr unix cpath wpath thread", nullptr)); - auto app = GUI::Application::construct(argc, argv); + auto app = GUI::Application::construct(arguments); const char* filename = nullptr; Core::ArgsParser args_parser; args_parser.add_positional_argument(filename, "File to read from", "file", Core::ArgsParser::Required::No); - args_parser.parse(argc, argv); + args_parser.parse(arguments); if (filename) { if (!Core::File::exists(filename) || Core::File::is_directory(filename)) { @@ -44,36 +44,13 @@ int main(int argc, char* argv[]) } } - if (unveil("/tmp/portal/webcontent", "rw") < 0) { - perror("unveil"); - return 1; - } - + TRY(Core::System::unveil("/tmp/portal/webcontent", "rw")); // For writing temporary files when exporting. - if (unveil("/tmp", "crw") < 0) { - perror("unveil"); - return 1; - } - - if (unveil("/etc", "r") < 0) { - perror("unveil"); - return 1; - } - - if (unveil(Core::StandardPaths::home_directory().characters(), "rwc") < 0) { - perror("unveil"); - return 1; - } - - if (unveil("/res", "r") < 0) { - perror("unveil"); - return 1; - } - - if (unveil(nullptr, nullptr) < 0) { - perror("unveil"); - return 1; - } + TRY(Core::System::unveil("/tmp", "crw")); + TRY(Core::System::unveil("/etc", "r")); + TRY(Core::System::unveil(Core::StandardPaths::home_directory().characters(), "rwc")); + TRY(Core::System::unveil("/res", "r")); + TRY(Core::System::unveil(nullptr, nullptr)); auto app_icon = GUI::Icon::default_icon("app-spreadsheet"); auto window = GUI::Window::construct();