| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | hdbBinRepos::Init | (const hzString&,const hzString&,) |
Declared in file: hzDatabase.h
Defined in file : hdbBinRepos.cpp
Function Logic:
Function body:
hzEcode hdbBinRepos::Init (const hzString& name, const hzString& opdir)
{
_hzfunc("hdbBinRepos::Init") ;
FSTAT fs ;
ifstream is ;
hzEcode rc ;
if (m_nInitState)
return hzerr(E_INITDUP, "Resource already initialized") ;
if (!name)
return hzerr(E_ARGUMENT, "No name") ;
if (!opdir)
return hzerr(E_ARGUMENT, "Repository %s: No working directory", *name) ;
if (m_pADP->GetBinRepos(name))
return hzerr(E_DUPLICATE, "Binary datum cron %s already exists", *name) ;
m_Name = name ;
m_Workdir = opdir ;
threadLog("called with cron name %s and workdir %s\n", *m_Name, *m_Workdir) ;
if (lstat(*m_Workdir, &fs) == -1)
{
rc = AssertDir(*m_Workdir, 0777);
if (rc != E_OK)
return hzerr(rc, "Could not assert working dir of %s", *m_Workdir) ;
}
m_FileIndx = m_Workdir + "/" + m_Name + ".idx" ;
m_FileData = m_Workdir + "/" + m_Name + ".dat" ;
if (lstat(*m_FileIndx, &fs) == -1)
m_nSeqId = m_nPopulation = 0;
else
m_nSeqId = m_nPopulation = fs.st_size / sizeof(_datum_hd) ;
if (lstat(*m_FileData, &fs) == -1)
m_nSize = 0;
else
m_nSize = fs.st_size ;
threadLog("A Initialized %s (%p) count %u (size %u) with err=%s\n", *m_Name, this, Count(), m_nSize, Err2Txt(rc)) ;
rc = m_pADP->RegisterBinRepos(this) ;
threadLog("B Initialized %s (%p) count %d with files %s and %s. err=%s\n",
*m_Name, this, m_pADP->CountBinRepos(), *m_FileIndx, *m_FileData, Err2Txt(rc)) ;
m_nInitState = 1;
return E_OK ;
}