From a624fd502ac198abc07326f0dd784c063a2dcaa2 Mon Sep 17 00:00:00 2001 From: cancer Date: Sun, 8 Aug 2021 21:12:03 +0300 Subject: [PATCH] do it with qt --- core/include/db_manager.h | 12 +----------- core/src/db_manager.cpp | 6 +++++- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/core/include/db_manager.h b/core/include/db_manager.h index 847faba..2e26f95 100644 --- a/core/include/db_manager.h +++ b/core/include/db_manager.h @@ -29,18 +29,8 @@ #include #include #include +#include -#if defined(_WIN32) - #include - #define access(pathname, mode) _access(pathname, mode) - -#elif defined(__unix__) - #include - -#else - #define access(pathname, mode) 1 - -#endif /** * @brief A class used to handle database interaction. * diff --git a/core/src/db_manager.cpp b/core/src/db_manager.cpp index 66bd1be..7acb899 100644 --- a/core/src/db_manager.cpp +++ b/core/src/db_manager.cpp @@ -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");