You are here

function recurse_build_tree in Web File Manager 5.2

Same name and namespace in other branches
  1. 5 webfm.module \recurse_build_tree()
1 call to recurse_build_tree()
webfm_tree in ./webfm.module
Build directory tree

File

./webfm.module, line 1572

Code

function recurse_build_tree($dir, $full) {
  if ($handle = opendir($dir)) {
    while (false !== ($readdir = readdir($handle))) {
      if ($readdir != '.' && $readdir != '..') {
        $path = $dir . '/' . $readdir;

        //directories are array keys with an array value or a null value for

        //empty directories (note that a file cannot have a null value)
        if (is_dir($path)) {
          $tree[$readdir] = recurse_build_tree($path, $full);
        }
        if ($full == true) {

          //files are non-null, non-array key values
          if (is_file($path)) {
            $tree[] = $readdir;
          }
        }
      }
    }
    closedir($handle);
  }
  return isset($tree) ? $tree : '';
}