// enumerate all plugins that had valid DatabasePluginInfo() int tryOpenDatabase(const TCHAR *tszProfile) { bool bWasOpened = false; for (int i=arDbPlugins.getCount()-1; i >= 0; i--) { DATABASELINK *p = arDbPlugins[i]; // liked the profile? int err = p->grokHeader(tszProfile); if (err != ERROR_SUCCESS) { // smth went wrong switch (err) { case EGROKPRF_CANTREAD: case EGROKPRF_UNKHEADER: // just not supported. continue; } return err; } bWasOpened = true; // try to load database MIDatabase *pDb = p->Load(tszProfile); if (pDb) { fillProfileName(tszProfile); currDblink = p; db_setCurrent(currDb = pDb); return 0; } } return (bWasOpened) ? -1 : EGROKPRF_CANTREAD; }
static bool CheckBroken(const TCHAR *ptszFullPath) { DATABASELINK *dblink = FindDatabasePlugin(ptszFullPath); if (dblink == NULL || dblink->CheckDB == NULL) return true; return dblink->grokHeader(ptszFullPath) != EGROKPRF_NOERROR; }