Commit 27b1d679 authored by claes's avatar claes

CreateVolume implemented

parent 4bf2349b
......@@ -89,9 +89,9 @@ wb_volume wb_env::volume(const char *name)
return v;
}
wb_volume wb_env::createVolume(wb_cdef cdef, pwr_tVid vid, wb_name name) // Fix
wb_volume wb_env::createVolume(pwr_tVid vid, pwr_tCid cid, const char *name)
{
wb_volume v;
wb_volume v( m_erep->createVolume( &m_sts, vid, cid, name));
return v;
}
......
......@@ -42,8 +42,7 @@ public:
wb_volume snapshot(pwr_tVid);
wb_volume createVolume(wb_cdef cdef, pwr_tVid vid, wb_name name);
wb_volume createVolume(pwr_tVid vid, pwr_tCid cid, const char *name);
int nextVolatileVid( char *name) { return m_erep->nextVolatileVid( &m_sts, name); }
......
......@@ -343,7 +343,9 @@ void wb_erep::load( pwr_tStatus *sts)
*sts = status;
return;
}
loadMeta( sts);
bindMethods();
loadLocalWb( sts);
return;
}
loadCommonMeta( sts);
......@@ -465,6 +467,20 @@ void wb_erep::loadMeta( pwr_tStatus *status)
ifstream fpm( fname, ios::in);
if ( !fpm) {
*status = LDH__PROJCONFIG;
// Load directory volume
strcpy( vname, "$pwrp_db/directory.db");
dcli_translate_filename( vname, vname);
sts = dcli_search_file( vname, found_file, DCLI_DIR_SEARCH_INIT);
dcli_search_file( vname, found_file, DCLI_DIR_SEARCH_END);
if ( ODD(sts)) {
wb_vrepdb *vrepdb = new wb_vrepdb( this, vname);
vrepdb->name("directory");
addDb( &sts, vrepdb);
MsgWindow::message( 'I', "Database opened", vname);
}
return;
}
......@@ -543,11 +559,17 @@ void wb_erep::loadMeta( pwr_tStatus *status)
strcat( vname, ".db");
dcli_translate_filename( vname, vname);
wb_vrepdb *vrepdb = new wb_vrepdb( this, vname);
vrepdb->name(vol_array[0]);
addDb( &sts, vrepdb);
MsgWindow::message( 'I', "Database opened", vname);
vol_cnt++;
sts = dcli_search_file( vname, found_file, DCLI_DIR_SEARCH_INIT);
dcli_search_file( vname, found_file, DCLI_DIR_SEARCH_END);
if ( ODD(sts)) {
wb_vrepdb *vrepdb = new wb_vrepdb( this, vname);
vrepdb->name(vol_array[0]);
addDb( &sts, vrepdb);
MsgWindow::message( 'I', "Database opened", vname);
vol_cnt++;
}
else
MsgWindow::message( 'E', "Database not found", vname);
}
}
fpm.close();
......@@ -728,6 +750,26 @@ int wb_erep::nextVolatileVid( pwr_tStatus *sts, char *name)
return vid;
}
wb_vrep *wb_erep::createVolume(pwr_tStatus *sts, pwr_tVid vid, pwr_tCid cid,
const char *name)
{
char vname[200];
sprintf( vname, "$pwrp_db/%s.db", cdh_Low(name));
dcli_translate_filename( vname, vname);
vrep_iterator it = m_vrepdb.find( vid);
if ( it != m_vrepdb.end()) {
*sts = LDH__VOLIDALREXI;
return 0;
}
wb_vrepdb *vrepdb = new wb_vrepdb( this, vid, cid, name, vname);
addDb( sts, vrepdb);
MsgWindow::message( 'I', "Database created", vname);
return vrepdb;
}
......
......@@ -46,6 +46,7 @@ public:
wb_vrep *volume(pwr_tStatus *sts);
wb_vrep *volume(pwr_tStatus *sts, pwr_tVid vid);
wb_vrep *volume(pwr_tStatus *sts, const char *name);
wb_vrep *createVolume(pwr_tStatus *sts, pwr_tVid vid, pwr_tCid cid, const char *name);
wb_vrep *nextVolume(pwr_tStatus *sts, pwr_tVid vid);
wb_vrep *externVolume(pwr_tStatus *sts, pwr_tVid vid);
wb_vrep *bufferVolume(pwr_tStatus *sts);
......
......@@ -297,6 +297,8 @@ ldh_ClassNameToId(ldh_tSession session, pwr_tCid *cid, char *name)
{
wb_session *sp = (wb_session *)session;
wb_name n(name);
if ( EVEN(n.sts()))
return n.sts();
wb_cdef c = sp->cdef(n);
if (!c) return c.sts();
......@@ -390,9 +392,8 @@ ldh_CreateVolume(ldh_tWorkbench workbench, ldh_tSession *session, pwr_tVid vid,
wb_env *ep = (wb_env *)workbench;
wb_name n(name);
wb_cdef cdef;
wb_volume v = ep->createVolume(cdef, vid, name);
wb_volume v = ep->createVolume(vid, cid, name);
if (!v) return v.sts();
// wb_srep *srep = new wb_srep(v);
......@@ -771,24 +772,18 @@ ldh_GetRootList(ldh_tSession session, pwr_tOid *oid)
pwr_tStatus
ldh_GetVolumeRootList(ldh_tSession session, pwr_tVid vid, pwr_tOid *oid)
{
#if NOT_YET_IMPLEMENTED
pwr_tStatus sts;
ldhi_sVidEntry *vtp;
if (!hasAccess(sp, ldh_eAccess_ReadOnly, &sts)) return sts;
if (objid == NULL) return LDH__BADPARAM;
vtp = (ldhi_sVidEntry *) ldh_TreeFind(sp->wb->vidtab, &vid);
if (vtp == NULL) return LDH__NOSUCHVOL;
wb_session *sp = (wb_session *)session;
if (vtp->vhp->ohp->chhp == NULL)
return LDH__NOSUCHOBJ;
wb_env env = sp->env();
wb_volume v = env.volume( vid);
if (!v) return v.sts();
wb_object o = v.object();
if (!o) return o.sts();
*objid = vtp->vhp->ohp->chhp->db.oid;
*oid = o.oid();
return LDH__SUCCESS;
#endif
return LDH__NYI;
return o.sts();
}
extern "C" pwr_tStatus
......@@ -1495,15 +1490,17 @@ ldh_WbLoad( ldh_tSession session, char *loadfile)
wb_vrepdbs *vdbs = new wb_vrepdbs( erep, fname);
vdbs->load();
wb_db db( vdbs->vid());
cdh_ToLower( vname, vdbs->name());
strcpy( db_name, "$pwrp_db/");
strcat( db_name, vname);
strcat( db_name, ".db");
dcli_translate_filename( db_name, db_name);
db.create( vdbs->vid(), vdbs->cid(), vdbs->name(), db_name);
db.importVolume( *vdbs);
// wb_db db( vdbs->vid());
// db.create( vdbs->vid(), vdbs->cid(), vdbs->name(), db_name);
// db.importVolume( *vdbs);
wb_db db( pwr_cNVid);
db.copy( *vdbs, db_name);
db.close();
delete vdbs;
......@@ -1519,15 +1516,17 @@ ldh_WbLoad( ldh_tSession session, char *loadfile)
wb_vrepwbl *vwbl = new wb_vrepwbl( erep);
vwbl->load( fname);
wb_db db( vwbl->vid());
cdh_ToLower( vname, vwbl->name());
strcpy( db_name, "$pwrp_db/");
strcat( db_name, vname);
strcat( db_name, ".db");
dcli_translate_filename( db_name, db_name);
db.create( vwbl->vid(), vwbl->cid(), vwbl->name(), db_name);
db.importVolume( *vwbl);
// wb_db db( vwbl->vid());
// db.create( vwbl->vid(), vwbl->cid(), vwbl->name(), db_name);
// db.importVolume( *vwbl);
wb_db db( pwr_cNVid);
db.copy( *vwbl, db_name);
db.close();
delete vwbl;
......
......@@ -27,6 +27,8 @@ extern "C" {
#define ldh_cDirectoryVolume (0 + ((pwr_tVolumeId)254 << 24) + (254 << 16) + (254 << 8) + 253)
#define ldh_cVolatileVolMin (0 + ((pwr_tVolumeId)254 << 24) + (254 << 16) + (254 << 8) + 0)
#define ldh_cVolatileVolMax (0 + ((pwr_tVolumeId)254 << 24) + (254 << 16) + (254 << 8) + 100)
#define ldh_cUserVolMin (0 + ((pwr_tVolumeId)0 << 24) + (1 << 16) + (254 << 1) + 1)
#define ldh_cUserVolMax (0 + ((pwr_tVolumeId)0 << 24) + (254 << 16) + (254 << 8) + 254)
#if 0
#ifndef 0
......
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