function
listDirTree(
$dirName
=
null
) {
if ( empty ( $dirName )) exit ( " IBFileSystem:directoryisempty. " );
if ( is_dir ( $dirName )) {
if ( $dh = opendir ( $dirName )) {
$tree = array ();
while (( $file = readdir ( $dh )) !== false ) {
if ( $file != " . " && $file != " .. " ) {
$filePath = $dirName . " / " . $file ;
if ( is_dir ( $filePath )) {
$tree [ $file ] = listDirTree( $filePath );
} else {
$tree [] = $file ;
}
}
}
closedir ( $dh );
} else {
exit ( " IBFileSystem:cannotopendirectory$dirName. " );
}
return $tree ;
} else {
exit ( " IBFileSystem:$dirNameisnotadirectory. " );
}
}
if ( empty ( $dirName )) exit ( " IBFileSystem:directoryisempty. " );
if ( is_dir ( $dirName )) {
if ( $dh = opendir ( $dirName )) {
$tree = array ();
while (( $file = readdir ( $dh )) !== false ) {
if ( $file != " . " && $file != " .. " ) {
$filePath = $dirName . " / " . $file ;
if ( is_dir ( $filePath )) {
$tree [ $file ] = listDirTree( $filePath );
} else {
$tree [] = $file ;
}
}
}
closedir ( $dh );
} else {
exit ( " IBFileSystem:cannotopendirectory$dirName. " );
}
return $tree ;
} else {
exit ( " IBFileSystem:$dirNameisnotadirectory. " );
}
}