/** * Method to connect to the store. * * @param storePath The full path to the store to connect to. * @return HRESULT */ RCODE CSPStore::OpenStore( char *pStorePath) { RCODE rc = FERR_OK; char* pDbPath; // Convert the path to current code page and then create the data base. pDbPath = setupDbPath(pStorePath); if (pDbPath) { rc = FlmDbOpen( pDbPath, NULL, NULL, //default pRflDir 0, NULL, &m_hFlaim); if (RC_OK(rc)) { // Now setup the store. rc = m_pDB->initializeDB(m_hFlaim, false); if (RC_OK(rc)) { m_connected = true; } } } return (rc); } // CSPStore::OpenStore()
/**************************************************************************** Desc: ****************************************************************************/ RCODE TestBase::openTestState( const char * pszDibName) { RCODE rc = FERR_OK; CREATE_OPTS createOpts; if( RC_BAD( rc = gv_FlmSysData.pFileSystem->doesFileExist( pszDibName))) { // Create the database f_memset( &createOpts, 0, sizeof( CREATE_OPTS)); if( RC_BAD( rc = FlmDbCreate( pszDibName, NULL, NULL, NULL, NULL, &createOpts, &m_hDb))) { goto Exit; } } else { // Open the existing database if( RC_BAD( rc = FlmDbOpen( pszDibName, NULL, NULL, 0, NULL, &m_hDb))) { goto Exit; } } Exit: return( rc); }
/******************************************************************** Desc: Checks to see if the user pressed ESCAPE to exit the loader. Also updates the total loaded counter on the screen. *********************************************************************/ FLMUINT gigaSeeIfQuit( void) { FLMUINT uiChar = 0;; f_mutexLock( gv_hWindowMutex); gigaOutputUINT( TOTAL_LOADED_ROW, gv_uiTotalLoaded, TRUE); if (RC_OK( FTXWinTestKB( gv_pWindow))) { FTXWinInputChar( gv_pWindow, &uiChar); if (uiChar == FKB_ESCAPE) { uiChar = gigaGetInput( "ESCAPE pressed, quit? (ESC,Q,Y=Quit, other=continue): ", NULL, TRUE); switch (uiChar) { case 'Q': case 'q': case 'y': case 'Y': uiChar = FKB_ESCAPE; break; case FKB_ESCAPE: break; default: uiChar = 0; break; } } else if( uiChar == 'i' || uiChar == 'I') { HFDB hDb; f_threadDestroy( &gv_pIxManagerThrd); if (RC_OK( FlmDbOpen( gv_szDibName, gv_szDataDir, gv_szRflDir, 0, NULL, &hDb))) { f_threadCreate( &gv_pIxManagerThrd, flstIndexManagerThread, "index_manager", F_DEFAULT_THREAD_GROUP, 0, (void *)hDb); } } } if (gv_bShutdown) { uiChar = FKB_ESCAPE; } f_mutexUnlock( gv_hWindowMutex); return( uiChar); }
/******************************************************************************* Desc: Copies a database, including roll-forward log files. *******************************************************************************/ FLMEXP RCODE FLMAPI FlmDbCopy( const char * pszSrcDbName, const char * pszSrcDataDir, const char * pszSrcRflDir, const char * pszDestDbName, const char * pszDestDataDir, const char * pszDestRflDir, STATUS_HOOK fnStatusCallback, void * UserData) { RCODE rc = FERR_OK; FLMBYTE * pucLastCommittedLogHdr; HFDB hDb = HFDB_NULL; FDB * pDb; FLMBOOL bDbLocked = FALSE; FLMUINT uiDbVersion; // Make sure the destination database is closed if (RC_BAD( rc = FlmConfig( FLM_CLOSE_FILE, (void *)pszDestDbName, (void *)pszDestDataDir))) { goto Exit; } gv_FlmSysData.pFileHdlCache->closeUnusedFiles(); // Open the database so we can force a checkpoint. if (RC_BAD( rc = FlmDbOpen( pszSrcDbName, pszSrcDataDir, pszSrcRflDir, 0, NULL, &hDb))) { goto Exit; } pDb = (FDB *)hDb; // Need to lock the database, because we want to do a checkpoint // and then the copy immediately after without letting other // threads have the opportunity to get in and update the // database. if (RC_BAD( rc = FlmDbLock( hDb, FLM_LOCK_EXCLUSIVE, 0, FLM_NO_TIMEOUT))) { goto Exit; } bDbLocked = TRUE; // Force a checkpoint if (RC_BAD( rc = FlmDbCheckpoint( hDb, FLM_NO_TIMEOUT))) { goto Exit; } pucLastCommittedLogHdr = &pDb->pFile->ucLastCommittedLogHdr[ 0]; // Get the low and high RFL log file numbers from the log // header. uiDbVersion = pDb->pFile->FileHdr.uiVersionNum; // Once we get this far, we have exclusive access to the database // and we have forced a checkpoint. The database's contents are // guaranteed to be on disk at this point, and they will not // change. rc = flmCopyDb( uiDbVersion, pszSrcDbName, pszSrcDataDir, pszSrcRflDir, pszDestDbName, pszDestDataDir, pszDestRflDir, fnStatusCallback, UserData); Exit: // Unlock and close the database if (bDbLocked) { FlmDbUnlock( hDb); } if (hDb != HFDB_NULL) { (void)FlmDbClose( &hDb); (void)FlmConfig( FLM_CLOSE_FILE, (void *)pszSrcDbName, (void *)pszSrcDataDir); } return( rc); }