do it with qt

This commit is contained in:
cancer 2021-08-08 21:12:03 +03:00
parent 23b5962e2a
commit a624fd502a
2 changed files with 6 additions and 12 deletions

View File

@ -29,18 +29,8 @@
#include <QSqlDriver>
#include <QSqlError>
#include <QSqlQuery>
#include <QFileInfo>
#if defined(_WIN32)
#include <io.h>
#define access(pathname, mode) _access(pathname, mode)
#elif defined(__unix__)
#include <unistd.h>
#else
#define access(pathname, mode) 1
#endif
/**
* @brief A class used to handle database interaction.
*

View File

@ -20,8 +20,12 @@
DBManager::DBManager() :
DRIVER("QSQLITE")
{
if(!access("config/akashi.db", R_OK | W_OK))
QFileInfo *db_info = new QFileInfo;
*db_info = QFileInfo("config/akashi.db");
if(!(db_info->isReadable()) || !(db_info->isWritable()))
qCritical() << "Database Error: Missing permissions. Check if \"config/akashi.db\" is writable.\n";
delete db_info;
db = QSqlDatabase::addDatabase(DRIVER);
db.setDatabaseName("config/akashi.db");