Exemplo n.º 1
0
 /**
  * Read Directory Nested
  *
  * @param  string  $path            Path directory to be scan
  * @param  integer $directory_depth directory depth of nested to be scanned
  * @param  boolean $hidden          true if want to show hidden content
  * @return array                    path trees
  */
 public static function readDirList($path, $directory_depth = 0, $hidden = false)
 {
     $file_data = false;
     if (static::isDir($path) && ($fp = opendir($path))) {
         $new_depth = $directory_depth - 1;
         $path = PathHelper::cleanPath($path) . '/';
         while (false !== ($file = readdir($fp))) {
             // Remove '.', '..', and hidden files [optional]
             if ($file === '.' || $file === '..' || $hidden === false && $file[0] === '.') {
                 continue;
             }
             static::isDir($path . $file) && ($path .= '/');
             if (($directory_depth < 1 || $new_depth > 0) && static::isDir($path . $file)) {
                 $file_data[$file] = static::readDirList($path . $file, $new_depth, $hidden);
             } else {
                 $file_data[] = $file;
             }
         }
         // close resource
         closedir($fp);
     }
     return $file_data;
 }