mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-03 13:00:29 +00:00
Games: Use pledge and unveil
This commit is contained in:
parent
9faca895d3
commit
9f8a8e07c2
Notes:
sideshowbarker
2024-07-19 01:35:08 +09:00
Author: https://github.com/bcoles Commit: https://github.com/SerenityOS/serenity/commit/9f8a8e07c2d Pull-request: https://github.com/SerenityOS/serenity/pull/3907
5 changed files with 73 additions and 0 deletions
3
Base/home/anon/.config/Snake.ini
Normal file
3
Base/home/anon/.config/Snake.ini
Normal file
|
@ -0,0 +1,3 @@
|
|||
[Snake]
|
||||
HighScore=0
|
||||
|
|
@ -45,6 +45,31 @@ int main(int argc, char** argv)
|
|||
|
||||
RefPtr<Core::ConfigFile> config = Core::ConfigFile::get_for_app("Chess");
|
||||
|
||||
if (pledge("stdio rpath accept wpath cpath shared_buffer proc exec", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (unveil("/res", "r") < 0) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (unveil(config->file_name().characters(), "crw") < 0) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (unveil("/bin/ChessEngine", "x") < 0) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (unveil(nullptr, nullptr) < 0) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto size = config->read_num_entry("Display", "size", 512);
|
||||
window->set_title("Chess");
|
||||
window->resize(size, size);
|
||||
|
|
|
@ -53,6 +53,23 @@ int main(int argc, char** argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (unveil("/res", "r") < 0) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto config = Core::ConfigFile::get_for_app("Minesweeper");
|
||||
|
||||
if (unveil(config->file_name().characters(), "crw") < 0) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (unveil(nullptr, nullptr) < 0) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto app_icon = GUI::Icon::default_icon("app-minesweeper");
|
||||
|
||||
auto window = GUI::Window::construct();
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
*/
|
||||
|
||||
#include "SnakeGame.h"
|
||||
#include <LibCore/ConfigFile.h>
|
||||
#include <LibGUI/AboutDialog.h>
|
||||
#include <LibGUI/Action.h>
|
||||
#include <LibGUI/Application.h>
|
||||
|
@ -50,6 +51,23 @@ int main(int argc, char** argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (unveil("/res", "r") < 0) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto config = Core::ConfigFile::get_for_app("Snake");
|
||||
|
||||
if (unveil(config->file_name().characters(), "crw") < 0) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (unveil(nullptr, nullptr) < 0) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto app_icon = GUI::Icon::default_icon("app-snake");
|
||||
|
||||
auto window = GUI::Window::construct();
|
||||
|
|
|
@ -45,6 +45,16 @@ int main(int argc, char** argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (unveil("/res", "r") < 0) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (unveil(nullptr, nullptr) < 0) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto window = GUI::Window::construct();
|
||||
|
||||
window->set_resizable(false);
|
||||
|
|
Loading…
Reference in a new issue