Return TypeFunction nameArguments
hzEcodeListDir(hzVect<hzString>&,hzVect<hzString>&,const char*,const char*,)

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

Function Logic:

0:START 1:hzVect::Clear hzVect::Clear 2:cpPath&&cpPath[0] 3:opendir pDir 4:opendir pDir 5:!pDir 6:Return E_OPENFAIL 7:pDE=readdir(pDir); 8:pDE->d_name[0]=='.'&&(pDE->d_name[1]==0||(pDE->d_name[1]=='.'&&pDE->d_name[2]==0)) 9:!FormCheckCstr(pDE->d_name,cpCriteria) 10:cpPath&&cpPath[0] 11:teststr teststr teststr 12:teststr 13:stat(*teststr,&fs)==-1 14:Return E_CORRUPT 15:S_ISDIR(fs.st_mode) 16:name hzVect::Add 17:S_ISREG(fs.st_mode) 18:name hzVect::Add 19:Return E_OK

Function body:

hzEcode ListDir (hzVect<hzString>& Dirs, hzVect<hzString>& Files, const char* cpPath, const char* cpCriteria)
{
   _hzfunc("ListDir") ;
   FSTAT       fs ;
   dirent*     pDE ;
   DIR*        pDir ;
   hzDirent    meta ;
   hzString    teststr ;
   hzString    name ;
   Dirs.Clear() ;
   Files.Clear() ;
   /*
   **  ** Move thru current directory and read files and sub directories
   **      */
   if (cpPath && cpPath[0])
       pDir = opendir(cpPath) ;
   else
       pDir = opendir(".") ;
   if (!pDir)
       return E_OPENFAIL ;
   for (; pDE = readdir(pDir) ;)
   {
       if (pDE->d_name[0]== ''.''&&(pDE->d_name[1]== 0|| (pDE->d_name[1]== ''.''&&pDE->d_name[2]== 0)))
           continue ;
       if (!FormCheckCstr(pDE->d_name, cpCriteria))
           continue ;
       if (cpPath && cpPath[0])
       {
           teststr = cpPath ;
           teststr += "/" ;
           teststr += pDE->d_name ;
       }
       else
           teststr = pDE->d_name ;
       if (stat(*teststr, &fs) == -1)
       {
           hzerr(E_CORRUPT, "Could not stat directory entry %s", *teststr) ;
           return E_CORRUPT ;
       }
       if (S_ISDIR(fs.st_mode))
       {
           name = pDE->d_name ;
           Dirs.Add(name) ;
           continue ;
       }
       if (S_ISREG(fs.st_mode))
       {
           name = pDE->d_name ;
           Files.Add(name) ;
           continue ;
       }
   }
   return E_OK ;
}