| 27 | } |
| 28 | |
| 29 | CSqlite SqliteOpen(IConsole *pConsole, IStorage *pStorage, const char *pPath) |
| 30 | { |
| 31 | char aFullPath[IO_MAX_PATH_LENGTH]; |
| 32 | pStorage->GetCompletePath(IStorage::TYPE_SAVE, pPath, aFullPath, sizeof(aFullPath)); |
| 33 | sqlite3 *pSqlite = nullptr; |
| 34 | const bool ErrorOpening = SQLITE_HANDLE_ERROR(sqlite3_open(aFullPath, &pSqlite)) != SQLITE_OK; |
| 35 | // Even on error, the database is initialized and needs to be freed. |
| 36 | // Except on allocation failure, but then it'll be nullptr which is |
| 37 | // also fine. |
| 38 | CSqlite pResult{pSqlite}; |
| 39 | if(ErrorOpening) |
| 40 | { |
| 41 | return nullptr; |
| 42 | } |
| 43 | bool Error = false; |
| 44 | Error = Error || SQLITE_HANDLE_ERROR(sqlite3_exec(pSqlite, "PRAGMA journal_mode = WAL", nullptr, nullptr, nullptr)); |
| 45 | Error = Error || SQLITE_HANDLE_ERROR(sqlite3_exec(pSqlite, "PRAGMA synchronous = NORMAL", nullptr, nullptr, nullptr)); |
| 46 | if(Error) |
| 47 | { |
| 48 | return nullptr; |
| 49 | } |
| 50 | return pResult; |
| 51 | } |
| 52 | |
| 53 | CSqliteStmt SqlitePrepare(IConsole *pConsole, sqlite3 *pSqlite, const char *pStatement) |
| 54 | { |
no test coverage detected