Ejemplo n.º 1
0
/*
 * Resets the backend database.  This function shall be called only when
 * nothing holds the database open.
 *
 * ARGUMENTS:
 *      path            Pathname of the database directory.  Shall not be NULL.
 *                      The client can free it upon return.
 * RETURNS:
 *      0               Success.
 *      EIO             Backend database error.  "log_start()" called.
 */
RegStatus
beReset(
    const char* const   path)
{
    RegStatus   status;

    assert(NULL != path);

    if (0 == (status = verifyBackend(path))) {
        /*
         * The database is OK.  Make a backup copy.
         */
        status = copyDatabase(path, "", ".bck");
    }
    else if (ECANCELED == status) {
        /*
         * The backend database needs to be restored.
         */
        log_add("Restoring from backup");
        log_log(LOG_NOTICE);

        if (0 == (status = removeEnvironment(path))) {
            status = copyDatabase(path, ".bck", "");
        }
    }

    return status;
}
Ejemplo n.º 2
0
void MainWindow::saveAsDatabase() {
    QString fileName = QFileDialog::getSaveFileName(this, tr("Save Database"), ".", tr("Database files (*.db);;All files (*.*)"));

    if (!fileName.isEmpty()) {
        // Copy the current database, close it, and open the "saved as" file
        copyDatabase(fileName);

        m_dbWidget->closeDatabase();
        loadDatabase(fileName);
    }
}