mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:17:36 +00:00
Games: Use pledge and unveil
This commit is contained in:
parent
9faca895d3
commit
9f8a8e07c2
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");
|
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);
|
auto size = config->read_num_entry("Display", "size", 512);
|
||||||
window->set_title("Chess");
|
window->set_title("Chess");
|
||||||
window->resize(size, size);
|
window->resize(size, size);
|
||||||
|
|
|
@ -53,6 +53,23 @@ int main(int argc, char** argv)
|
||||||
return 1;
|
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 app_icon = GUI::Icon::default_icon("app-minesweeper");
|
||||||
|
|
||||||
auto window = GUI::Window::construct();
|
auto window = GUI::Window::construct();
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "SnakeGame.h"
|
#include "SnakeGame.h"
|
||||||
|
#include <LibCore/ConfigFile.h>
|
||||||
#include <LibGUI/AboutDialog.h>
|
#include <LibGUI/AboutDialog.h>
|
||||||
#include <LibGUI/Action.h>
|
#include <LibGUI/Action.h>
|
||||||
#include <LibGUI/Application.h>
|
#include <LibGUI/Application.h>
|
||||||
|
@ -50,6 +51,23 @@ int main(int argc, char** argv)
|
||||||
return 1;
|
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 app_icon = GUI::Icon::default_icon("app-snake");
|
||||||
|
|
||||||
auto window = GUI::Window::construct();
|
auto window = GUI::Window::construct();
|
||||||
|
|
|
@ -45,6 +45,16 @@ int main(int argc, char** argv)
|
||||||
return 1;
|
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();
|
auto window = GUI::Window::construct();
|
||||||
|
|
||||||
window->set_resizable(false);
|
window->set_resizable(false);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue