Commit cf6417c9 authored by claes's avatar claes

Opening of single database, not whole env

parent 50e9554c
...@@ -27,7 +27,7 @@ public: ...@@ -27,7 +27,7 @@ public:
operator wb_erep*() const; operator wb_erep*() const;
bool operator==(wb_env&); bool operator==(wb_env&);
void load() { m_erep->load(&m_sts);} void load( char *db) { m_erep->load(&m_sts, db);}
bool open(); bool open();
bool close(); bool close();
......
...@@ -182,6 +182,8 @@ wb_vrep *wb_erep::nextVolume(pwr_tStatus *sts, pwr_tVid vid) ...@@ -182,6 +182,8 @@ wb_vrep *wb_erep::nextVolume(pwr_tStatus *sts, pwr_tVid vid)
it = m_vrepdbs.find(vid); it = m_vrepdbs.find(vid);
if ( it != m_vrepdbs.end()) { if ( it != m_vrepdbs.end()) {
it++; it++;
if ( it != m_vrepdbs.end() && it->second->duplicateDb())
it++;
if ( it != m_vrepdbs.end()) { if ( it != m_vrepdbs.end()) {
*sts = LDH__SUCCESS; *sts = LDH__SUCCESS;
return it->second; return it->second;
...@@ -332,7 +334,7 @@ void wb_erep::removeBuffer(pwr_tStatus *sts, wb_vrep *vrep) ...@@ -332,7 +334,7 @@ void wb_erep::removeBuffer(pwr_tStatus *sts, wb_vrep *vrep)
return; return;
} }
void wb_erep::load( pwr_tStatus *sts) void wb_erep::load( pwr_tStatus *sts, char *db)
{ {
loadDirList( sts); loadDirList( sts);
if ( EVEN(*sts)) return; if ( EVEN(*sts)) return;
...@@ -343,7 +345,7 @@ void wb_erep::load( pwr_tStatus *sts) ...@@ -343,7 +345,7 @@ void wb_erep::load( pwr_tStatus *sts)
*sts = status; *sts = status;
return; return;
} }
loadMeta( sts); loadMeta( sts, db);
bindMethods(); bindMethods();
loadLocalWb( sts); loadLocalWb( sts);
return; return;
...@@ -351,7 +353,7 @@ void wb_erep::load( pwr_tStatus *sts) ...@@ -351,7 +353,7 @@ void wb_erep::load( pwr_tStatus *sts)
loadCommonMeta( sts); loadCommonMeta( sts);
if ( EVEN(*sts)) return; if ( EVEN(*sts)) return;
loadMeta( sts); loadMeta( sts, db);
bindMethods(); bindMethods();
loadLocalWb( sts); loadLocalWb( sts);
} }
...@@ -446,7 +448,7 @@ void wb_erep::loadCommonMeta( pwr_tStatus *status) ...@@ -446,7 +448,7 @@ void wb_erep::loadCommonMeta( pwr_tStatus *status)
*status = LDH__SUCCESS; *status = LDH__SUCCESS;
} }
void wb_erep::loadMeta( pwr_tStatus *status) void wb_erep::loadMeta( pwr_tStatus *status, char *db)
{ {
// Load local metavolumes // Load local metavolumes
char found_file[200]; char found_file[200];
...@@ -553,6 +555,11 @@ void wb_erep::loadMeta( pwr_tStatus *status) ...@@ -553,6 +555,11 @@ void wb_erep::loadMeta( pwr_tStatus *status)
} }
else { else {
// Load db for this volume // Load db for this volume
if ( db) {
// If db is specified, load only specified db
if ( cdh_NoCaseStrcmp( vol_array[0], db) != 0)
continue;
}
strcpy( vname, "$pwrp_db/"); strcpy( vname, "$pwrp_db/");
strcat( vname, vol_array[0]); strcat( vname, vol_array[0]);
cdh_ToLower( vname, vname); cdh_ToLower( vname, vname);
...@@ -574,22 +581,36 @@ void wb_erep::loadMeta( pwr_tStatus *status) ...@@ -574,22 +581,36 @@ void wb_erep::loadMeta( pwr_tStatus *status)
} }
fpm.close(); fpm.close();
// Identify dbs that also is loaded as db
vrep_iterator itdbs, itdb;
for ( itdbs = m_vrepdbs.begin(); itdbs != m_vrepdbs.end(); itdbs++) {
for ( itdb = m_vrepdb.begin(); itdb != m_vrepdb.end(); itdb++) {
if ( itdbs->first == itdb->first)
itdbs->second->setDuplicateDb( true);
}
}
// Load directory volume // Load directory volume
strcpy( vname, "$pwrp_db/directory.db"); if ( !db || (db && cdh_NoCaseStrcmp( "directory", db) == 0)) {
dcli_translate_filename( vname, vname); strcpy( vname, "$pwrp_db/directory.db");
dcli_translate_filename( vname, vname);
sts = dcli_search_file( vname, found_file, DCLI_DIR_SEARCH_INIT); sts = dcli_search_file( vname, found_file, DCLI_DIR_SEARCH_INIT);
dcli_search_file( vname, found_file, DCLI_DIR_SEARCH_END); dcli_search_file( vname, found_file, DCLI_DIR_SEARCH_END);
if ( ODD(sts)) { if ( ODD(sts)) {
wb_vrepdb *vrepdb = new wb_vrepdb( this, vname); wb_vrepdb *vrepdb = new wb_vrepdb( this, vname);
vrepdb->name("directory"); vrepdb->name("directory");
addDb( &sts, vrepdb); addDb( &sts, vrepdb);
MsgWindow::message( 'I', "Database opened", vname); MsgWindow::message( 'I', "Database opened", vname);
}
if ( EVEN(sts)) {
*status = LDH__PROJCONFIG;
return;
}
} }
if ( EVEN(sts)) if ( !vol_cnt)
*status = LDH__PROJCONFIG;
else if ( !vol_cnt)
*status = LDH__PROJCONFIG; *status = LDH__PROJCONFIG;
else else
*status = LDH__SUCCESS; *status = LDH__SUCCESS;
......
...@@ -60,7 +60,7 @@ public: ...@@ -60,7 +60,7 @@ public:
void removeDbs( pwr_tStatus *sts, wb_vrep *vrep); void removeDbs( pwr_tStatus *sts, wb_vrep *vrep);
void removeExtern( pwr_tStatus *sts, wb_vrep *vrep); void removeExtern( pwr_tStatus *sts, wb_vrep *vrep);
void removeBuffer( pwr_tStatus *sts, wb_vrep *vrep); void removeBuffer( pwr_tStatus *sts, wb_vrep *vrep);
void load( pwr_tStatus *sts); void load( pwr_tStatus *sts, char *db);
wb_orep *object( pwr_tStatus *sts, pwr_tOid oid); wb_orep *object( pwr_tStatus *sts, pwr_tOid oid);
wb_orep *object( pwr_tStatus *sts, wb_name &name); wb_orep *object( pwr_tStatus *sts, wb_name &name);
...@@ -74,7 +74,7 @@ public: ...@@ -74,7 +74,7 @@ public:
private: private:
void loadDirList( pwr_tStatus *status); void loadDirList( pwr_tStatus *status);
void loadCommonMeta( pwr_tStatus *status); void loadCommonMeta( pwr_tStatus *status);
void loadMeta( pwr_tStatus *status); void loadMeta( pwr_tStatus *status, char *db);
void loadLocalWb( pwr_tStatus *sts); void loadLocalWb( pwr_tStatus *sts);
void bindMethods(); void bindMethods();
}; };
......
...@@ -1143,11 +1143,11 @@ ldh_OpenSession(ldh_tSession *session, ldh_tVolume volume, ...@@ -1143,11 +1143,11 @@ ldh_OpenSession(ldh_tSession *session, ldh_tVolume volume,
it with objects from database on disk. */ it with objects from database on disk. */
pwr_tStatus pwr_tStatus
ldh_OpenWB(ldh_tWorkbench *workbench) ldh_OpenWB(ldh_tWorkbench *workbench, char *db)
{ {
wb_erep *erep = new wb_erep(); wb_erep *erep = new wb_erep();
wb_env *env = new wb_env(erep); wb_env *env = new wb_env(erep);
env->load(); env->load( db);
*workbench = (ldh_tWorkbench)env; *workbench = (ldh_tWorkbench)env;
return env->sts(); return env->sts();
......
...@@ -804,7 +804,8 @@ ldh_OpenSession ( ...@@ -804,7 +804,8 @@ ldh_OpenSession (
pwr_tStatus pwr_tStatus
ldh_OpenWB ( ldh_OpenWB (
ldh_tWorkbench *WorkBench ldh_tWorkbench *WorkBench,
char *db
); );
pwr_tStatus ldh_Paste ( pwr_tStatus ldh_Paste (
......
...@@ -1218,7 +1218,7 @@ static int wtt_get_wbctx( void *ctx, ldh_tWBContext *wbctx) ...@@ -1218,7 +1218,7 @@ static int wtt_get_wbctx( void *ctx, ldh_tWBContext *wbctx)
else else
{ {
wtt->set_clock_cursor(); wtt->set_clock_cursor();
sts = ldh_OpenWB( &wtt->wbctx); sts = ldh_OpenWB( &wtt->wbctx, 0);
if ( ODD(sts)) if ( ODD(sts))
*wbctx = wtt->wbctx; *wbctx = wtt->wbctx;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment