Return Type | Function name | Arguments |
---|---|---|
hzEcode | BlattDir | (const char*,) |
Declared in file: hzDirectory.h
Defined in file : hzDirectory.cpp
Function Logic:
Function body:
hzEcode BlattDir (const char* dirname) { _hzfunc("BlattDir") ; FSTAT fs ; dirent* pDE ; DIR* pDir ; hzString teststr ; int32_t sys_rc = 0; hzEcode rc = E_OK ; /* ** ** Move thru current directory and read files and sub directories ** */ if (!dirname || !dirname[0]) return E_ARGUMENT ; pDir = opendir(dirname) ; if (!pDir) return E_OPENFAIL ; for (; rc == E_OK && (pDE = readdir(pDir)) ;) { if (pDE->d_name[0]== ''.''&&(pDE->d_name[1]== 0|| (pDE->d_name[1]== ''.''&&pDE->d_name[2]== 0))) continue ; teststr = dirname ; teststr += "/" ; 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)) { rc = BlattDir(*teststr) ; continue ; } if (S_ISREG(fs.st_mode)) { sys_rc = unlink(*teststr) ; if (sys_rc) rc = E_WRITEFAIL ; continue ; } } closedir(pDir) ; if (rc == E_OK) { sys_rc = rmdir(dirname) ; if (sys_rc) rc = E_WRITEFAIL ; } return rc ; }