public function scan(string $dir, string $type = null, &$res = [], int $timeout = 0): array
  {
    $res = [];
    if ( $dirs = $this->listFiles($dir) ){
      foreach ( $dirs as $d ){
        if ( $type &&
                (strpos($type, 'file') === 0) &&
                !isset($d['num']) ){
          $res[] = $d['name'];
        }
        else if ( $type &&
                ((strpos($type, 'dir') === 0) || (strpos($type, 'fold') === 0)) &&
                isset($d['num']) ){
          $res[] = $d['name'];
        }
        else{
          $res[] = $d['name'];
        }
        if ( isset($d['num']) ){
          $this->scan($d['name'], $type, $res);
        }
      }
    }
    return $res;
	}
public function scan(string $dir, string $type = null, &$res = [], int $timeout = 0): array
  {
    $res = [];
    if ( $dirs = $this->listFiles($dir) ){
      foreach ( $dirs as $d ){
        if ( $type &&
                (strpos($type, 'file') === 0) &&
                !isset($d['num']) ){
          $res[] = $d['name'];
        }
        else if ( $type &&
                ((strpos($type, 'dir') === 0) || (strpos($type, 'fold') === 0)) &&
                isset($d['num']) ){
          $res[] = $d['name'];
        }
        else{
          $res[] = $d['name'];
        }
        if ( isset($d['num']) ){
          $this->scan($d['name'], $type, $res);
        }
      }
    }
    return $res;
	}
public function scan ( string $ dir , string $ type = null , & $ res = [ ] , int $ timeout = 0 ) : array { $ res = [ ] ; if ( $ dirs = $ this -> listFiles ( $ dir ) ) { foreach ( $ dirs as $ d ) { if ( $ type && ( strpos ( $ type , 'file' ) === 0 ) && ! isset ( $ d [ 'num' ] ) ) { $ res [ ] = $ d [ 'name' ] ; } else if ( $ type && ( ( strpos ( $ type , 'dir' ) === 0 ) || ( strpos ( $ type , 'fold' ) === 0 ) ) && isset ( $ d [ 'num' ] ) ) { $ res [ ] = $ d [ 'name' ] ; } else { $ res [ ] = $ d [ 'name' ] ; } if ( isset ( $ d [ 'num' ] ) ) { $ this -> scan ( $ d [ 'name' ] , $ type , $ res ) ; } } } return $ res ; }
Scans all the content from a directory, including the subdirectories

<code>
bbn\file\dir::scan("/home/me");
bbn\file\dir::delete("C:\Documents\Test");
</code>

@param string $dir The directory path.
@param string $type The type of item to return ('file', 'dir', default is both)

@return array
Scans all the content from a directory including the subdirectories