Return Type | Function name | Arguments |
---|---|---|
hzEcode | hdbIsamfile::Open | (void) |
Declared in file: hzDatabase.h
Defined in file : hdbIsamfile.cpp
Function Logic:
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 ; }