Skip to content

Commit

Permalink
On a create call, delete any pre-existing file first
Browse files Browse the repository at this point in the history
  • Loading branch information
paladine committed Oct 6, 2024
1 parent 075f26f commit cada283
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions btrieve/SqliteDatabase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,14 @@ void SqliteDatabase::loadSqliteKeys() {
std::unique_ptr<RecordLoader> SqliteDatabase::create(
const tchar *fileName, const BtrieveDatabase &database) {
sqlite3 *db;

// remove the file if is exists since we're creating it anew
#ifdef WIN32
_wunlink(fileName);
#else
unlink(fileName);
#endif

int errorCode = sqlite3_open_v2(
toStdString(fileName).c_str(), &db,
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | openFlags, nullptr);
Expand Down

0 comments on commit cada283

Please sign in to comment.