| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | hzFileset::Import | (const char*,) |
Declared in file: hzDirectory.h
Defined in file : hzDirectory.cpp
Function Logic:
Function body:
hzEcode hzFileset::Import (const char* filepath)
{
_hzfunc("hzFileset::Import()") ;
std::ifstream is ;
hzDirent* pDX ;
hzDirent* pFX ;
char* i ;
hzString newname ;
uint32_t nLine ;
uint32_t nInode ;
uint32_t nSize ;
uint32_t nCtime ;
uint32_t nMtime ;
uint32_t nMode ;
uint32_t nOwner ;
uint32_t nGroup ;
bool bOk ;
hzEcode rc ;
char cvLine[512];
if (!filepath || !filepath[0])
return E_ARGUMENT ;
is.open(filepath) ;
if (is.fail())
return E_OPENFAIL ;
for (nLine = 1;; nLine++)
{
is.getline(cvLine, 512);
if (!is.gcount())
break ;
i = cvLine ;
if (i[0]== ''#'')
continue ;
bOk = IsPosint(nInode, i + 2);
if (bOk) bOk = IsHexnum(nMode, i + 13);
if (bOk) bOk = IsPosint(nSize, i + 22);
if (bOk) bOk = IsPosint(nCtime, i + 33);
if (bOk) bOk = IsPosint(nMtime, i + 44);
if (bOk) bOk = IsPosint(nOwner, i + 55);
if (bOk) bOk = IsPosint(nGroup, i + 61);
if (!bOk)
{
is.close() ;
return hzerr(E_CORRUPT, "Line %d of %s is malformed", nLine, filepath) ;
}
newname = i + 67;
if (i[0]== ''D'')
{
pDX = new hzDirent() ;
pDX->InitNorm(0,newname, nInode, nSize, nCtime, nMtime, nMode, nOwner, nGroup, 0);
m_dirs.Insert(pDX->Path(), pDX) ;
continue ;
}
if (i[0]== ''F'')
{
pFX = new hzDirent() ;
pFX->InitNorm(pDX->strName(), newname, nInode, nSize, nCtime, nMtime, nMode, nOwner, nGroup, 0);
m_nBytes += pFX->Size() ;
m_file.Insert(pFX->Path(), pFX) ;
}
}
is.close() ;
return E_OK ;
}