fix: attempt db path creation if not found

This commit is contained in:
mk
2025-11-03 20:56:51 -03:00
parent 8012f30170
commit 777a006792

View File

@@ -4,9 +4,18 @@
#include "../../Game/RealmCharacter.h"
#include "../../Game/RealmCharacterMetaKV.h"
#include "../logging.h"
#include <filesystem>
Database::Database()
{
std::filesystem::path databasePath = "./database";
if(!std::filesystem::exists(databasePath)){
Log::Warn("Unable to find database path, attempting to create it...");
if(std::filesystem::create_directory(databasePath)){
Log::Info("Database path created successefully.");
}
}
if( sqlite3_open( "./database/game.db", &m_db ) != SQLITE_OK )
{
throw std::runtime_error( "Failed to open DB: " + std::string( sqlite3_errmsg( m_db ) ) );