fix: attempt db path creation if not found
This commit is contained in:
@@ -4,9 +4,18 @@
|
|||||||
#include "../../Game/RealmCharacter.h"
|
#include "../../Game/RealmCharacter.h"
|
||||||
#include "../../Game/RealmCharacterMetaKV.h"
|
#include "../../Game/RealmCharacterMetaKV.h"
|
||||||
#include "../logging.h"
|
#include "../logging.h"
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
Database::Database()
|
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 )
|
if( sqlite3_open( "./database/game.db", &m_db ) != SQLITE_OK )
|
||||||
{
|
{
|
||||||
throw std::runtime_error( "Failed to open DB: " + std::string( sqlite3_errmsg( m_db ) ) );
|
throw std::runtime_error( "Failed to open DB: " + std::string( sqlite3_errmsg( m_db ) ) );
|
||||||
|
|||||||
Reference in New Issue
Block a user