Return TypeFunction nameArguments
hzEcodehdbIsamfile::Open(void)

Declared in file: hzDatabase.h
Defined in file : hdbIsamfile.cpp

Function Logic:

0:START 1:m_nInitState==0 2:hzexit 3:m_nInitState==2 4:hzexit 5:ofstream::open ofstream::fail 6:m_WrI.fail() 7:Return hzerr(E_OPENFAIL,Cannot open index file for writing: Repos %s,*m_fileDelta) 8:ofstream::open ofstream::fail 9:m_WrD.fail() 10:Return hzerr(E_OPENFAIL,Could not open file (%s) for writing,*m_fileStore) 11:open ifstream::fail 12:is.fail() 13:Return hzerr(E_OPENFAIL,Could not open index file (%s) for reading,*m_fileStore) 14:m_nBlocks 15:; 16:ifstream::getline ifstream::gcount 17:!is.gcount() 18:items m_Buf IsHexnum key hzMapS::Insert items 19:close n 20:n 21:hzMapS::GetKey addr hzMapS::GetObj key hzMapM::Insert 22:hzMapS::Clear open ifstream::fail 23:m_RdD.fail() 24:Return hzerr(E_OPENFAIL,Could not open data file (%s) for reading,*m_fileStore) 25:m_nInitState 26:Return E_OK

Function body:

hzEcode hdbIsamfile::Open (void)
{
   _hzfunc("hdbIsamfile::Open") ;
   hzMapS<uint32_t,hzString>   tmp ;
   ifstream    is ;
   hzString    key ;
   uint32_t    addr ;
   uint32_t    nLines = 0;
   uint32_t    n ;
   if (m_nInitState == 0)  hzexit(E_NOINIT, "Cannot open an uninitialized datacron") ;
   if (m_nInitState == 2)  hzexit(E_SEQUENCE, "Datacron %s is already open", *m_Name) ;
   m_WrI.open(*m_fileDelta) ;
   if (m_WrI.fail())
       return hzerr(E_OPENFAIL, "Cannot open index file for writing: Repos %s", *m_fileDelta) ;
   m_WrD.open(*m_fileStore) ;
   if (m_WrD.fail())
       return hzerr(E_OPENFAIL, "Could not open file (%s) for writing", *m_fileStore) ;
   is.open(*m_fileDelta) ;
   if (is.fail())
       return hzerr(E_OPENFAIL, "Could not open index file (%s) for reading", *m_fileStore) ;
   m_nBlocks = 0;
   for (;;)
   {
       is.getline(m_Buf, 500);
       if (!is.gcount())
           break ;
       nLines++ ;
       m_Buf[8]= 0;
       IsHexnum(addr, m_Buf) ;
       key = m_Buf + 9;
       tmp.Insert(addr, key) ;
       m_nBlocks++ ;
   }
   is.close() ;
   for (n = 0; n < tmp.Count() ; n++)
   {
       addr = tmp.GetKey(n) ;
       key = tmp.GetObj(n) ;
       m_Index.Insert(key, addr) ;
   }
   tmp.Clear() ;
   m_RdD.open(*m_fileStore) ;
   if (m_RdD.fail())
       return hzerr(E_OPENFAIL, "Could not open data file (%s) for reading", *m_fileStore) ;
   m_nInitState = 2;
   return E_OK ;
}