Return TypeFunction nameArguments
hzEcodehzFileset::Import(const char*,)

Declared in file: hzDirectory.h
Defined in file : hzDirectory.cpp

Function Logic:

0:START 1:!filepath||!filepath[0] 2:Return E_ARGUMENT 3:open ifstream::fail 4:is.fail() 5:Return E_OPENFAIL 6:; 7:ifstream::getline ifstream::gcount 8:!is.gcount() 9:i 10:i[0]=='#' 11:IsPosint bOk 12:bOk 13:IsHexnum bOk 14:bOk 15:IsPosint bOk 16:bOk 17:IsPosint bOk 18:bOk 19:IsPosint bOk 20:bOk 21:IsPosint bOk 22:bOk 23:IsPosint bOk 24:!bOk 25:close 26:Return hzerr(E_CORRUPT,Line %d of %s is malformed,nLine,filepath) 27:newname 28:i[0]=='D' 29:pDX hzDirent::InitNorm hzDirent::Path hzMapS::Insert 30:i[0]=='F' 31:pFX hzDirent::strName hzDirent::InitNorm hzDirent::Size m_nBytes hzDirent::Path hzMapM::Insert 32:close 33:Return E_OK

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 ;
}