mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 03:47:35 +00:00
SQLServer: Store LibSQL database files in the standard data directory
This also allows for overriding the path. Ladybird will want to store the database files in a subdirectory of the standard data directory that contains the Ladybird application name. Fixes #16000.
This commit is contained in:
parent
49d74ee288
commit
b3e287342f
5 changed files with 23 additions and 12 deletions
|
@ -4,24 +4,22 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibCore/Directory.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/StandardPaths.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibIPC/MultiServer.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <SQLServer/ConnectionFromClient.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments)
|
||||
{
|
||||
TRY(Core::System::pledge("stdio accept unix rpath wpath cpath"));
|
||||
|
||||
if (mkdir("/home/anon/sql", 0700) < 0 && errno != EEXIST) {
|
||||
perror("mkdir");
|
||||
return 1;
|
||||
}
|
||||
auto database_path = DeprecatedString::formatted("{}/sql", Core::StandardPaths::data_directory());
|
||||
TRY(Core::Directory::create(database_path, Core::Directory::CreateDirectories::Yes));
|
||||
|
||||
TRY(Core::System::unveil("/home/anon/sql", "rwc"));
|
||||
TRY(Core::System::unveil(database_path, "rwc"sv));
|
||||
TRY(Core::System::unveil(nullptr, nullptr));
|
||||
|
||||
Core::EventLoop event_loop;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue