Read directory

@param	$dept		whether or not to read recursive
@param	$filters	whether or not to read recursive
@return	array
769318
public function read($depth = 0, $filters = null)
	{
		return $this->area->read_dir($this->path, $depth, $filters, $this->area);
	}
1301669
public function readDirectory($directory, $recursive = true)
    {
        if (is_dir($directory) === false) {
            return false;
        }

        try {
            $resource = opendir($directory);
            $contents = array();

            while (false !== ($item = readdir($resource)))
            {
                if (in_array($item, array('.', '..'))
                    || substr($item, 0, 1) == '_') {
                    continue;
                }

                $absoluteItem = $directory . DIRECTORY_SEPARATOR . $item;
                if ($recursive === true && is_dir($absoluteItem)) {
                    $contents[$item] = $this->readDirectory($absoluteItem, $recursive);
                } else {
                    $contents[$item] = $absoluteItem;
                }
            }
        } catch(\Exception $e) {
            return false;
        }

        return $contents;
    }
282616
static public function getFiles( $dir, $recursive = false )
    {
        $files = [];
        if ( ( $dh = opendir( $dir ) ) ) {
            while ( ( $file = readdir( $dh ) ) !== false ) {
                if ( is_file( $dir . '/' . $file ) ) {
                    $files[] = $file;
                }
                if ( $recursive && ( $file !== '.' && $file !== '..' && is_dir( $dir . '/' . $file ) ) ) {
                    $files = array_merge( $files, self::getFiles( $dir . DS . $file, true ) );
                }
            }
            closedir( $dh );
        }
        return $files;
    }
1271776
public function readDirRecursive( $dir, $pattern ) {

		$sub_dirs = glob( $dir . '/*', \GLOB_ONLYDIR );
		$files = array();
		if ( ! empty( $sub_dirs ) ) {
			foreach ( $sub_dirs as $sub_dir ) {
				$files = array_merge( $files, $this->readDirRecursive( $sub_dir, $pattern ) );
			}
		}
		$files = array_merge( $files, glob( $dir . '/' . $pattern, \GLOB_NOCHECK ) );

		return $files;
	}
667278
public function directories($directory = null, $recursive = false)
    {

        $directories = [ ];

        foreach (Finder::create()->in($directory)->directories() as $dir) {
            $directories[] = $dir->getPathname();
        }

        return $directories;
    }
1354882
public function getFilesFromDirectories(array $directoryArray)
    {
        $directoryArray = $this->getAbsoluteDirectoryPath($directoryArray);
        if (is_array($directoryArray) && count($directoryArray)) {
            $files = array();
            foreach ($directoryArray as $directory) {
                $foundFiles = GeneralUtility::getAllFilesAndFoldersInPath(
                    array(),
                    $directory,
                    $this->indexerConfig['fileext']
                );

                if (is_array($foundFiles) && count($foundFiles)) {
                    foreach ($foundFiles as $file) {
                        $files[] = $file;
                    }
                }
            }
            return $files;
        } else {
            return array();
        }
    }
222143
protected function getFilesFromDirectory(string $mappingDirectory): array
    {
        $mappingPaths = [];

        $filePattern = \sprintf('/^.+\.(%s)$/i', \implode('|', $this->extensions));
        $recursiveIterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($mappingDirectory));
        $regexIterator = new \RegexIterator($recursiveIterator, $filePattern, \RecursiveRegexIterator::GET_MATCH);

        foreach ($regexIterator as $mappingFile) {
            $mappingPaths[] = $mappingFile[0];
        }

        \sort($mappingPaths);

        return $mappingPaths;
    }
556868
public function listDirs($depth = 0, $filter = null, $asHandlers = false)
	{
		return $this->listContents($depth, $filter, 'dir', $asHandlers);
	}
648791
public function dir_readdir()
    {
        $current = current($this->listing);
        next($this->listing);

        return $current ? $current['path'] : false;
    }
637461
public function items($directory)
    {
        $directory = trim($directory, '/') . '/';

        $options = array(
            'return_prefixes' => true,
            'sort_results' => true
        );

        $objectIterator = $this->clientS3->getIterator('ListObjects', array(
            'Bucket'    => $this->bucket,
            'Prefix'    => $directory,
            'Delimiter' => '/',
        ), $options);

        $iterator = new CallbackFilterIterator($objectIterator, function($object){
            return (isset($object['Key']) || isset($object['Prefix']));
        });

        $files = array();

        foreach ($iterator as $object)
        {
            $files[] = isset($object['Key']) ? $object['Key'] : $object['Prefix'];
        }

        return $files;
    }
1220182
public function directories($directory)
    {
        $directories = array();

        foreach (Finder::create()->in($directory)->directories()->ignoreVCS(false)->ignoreDotFiles(false)->ignoreUnreadableDirs(false)->depth(0) as $dir)
        {
            $directories[] = $dir->getPathname();
        }

        return $directories;
    }
861726
public function dir_readdir()
  {
    $each = each($this->_dirFiles);

    if ($each === false) {
      $result = false;
    } else {
      $result = $each["value"];
    }

    return $result;
  }
1067808
public function listWith(array $keys = [], $directory = '', $recursive = false)
    {
        $contents = $this->listContents($directory, $recursive);

        foreach ($contents as $index => $object) {
            if ($object['type'] === 'file') {
                $missingKeys = \array_diff($keys, \array_keys($object));
                $contents[$index] = \array_reduce($missingKeys, [$this, 'getMetadataByName'], $object);
            }
        }

        return $contents;
    }
1349864
public static function getFiles(string $path, string $filter = null): array
    {
        if (!self::exists($path)) {
            return [];
        }
        $files = array_filter(scandir($path), function ($item) use ($path, $filter) {
            if ($item == '.' || $item == '..' || is_dir($path . '/' . $item)) {
                return false;
            }
            if (!empty($filter) && (pathinfo($item)['extension'] != trim($filter, '.'))) {
                return false;
            }
            return true;
        });

        $files = array_map(function ($item) use ($path) {
            return $path . '/' . $item;
        }, $files);

        return $files;
    }
1249478
public function getDirs($dir)
    {
        $dirArr = array();
        $files = ftp_rawlist($this->link, $dir);
        foreach ($files as $v) {
            $file = ltrim(strrchr($v, ' '), ' ');
            $path = "{$dir}/{$file}";
            if (preg_match('/^d/', $v)) {
                if (in_array($file, array('.', '..'))) {
                    continue;
                }
                if (preg_match('/^[a-zA-z0-9]+$/', $file)) { //file check
                    $dirArr[] = $path;
                    $dirArr = array_merge($dirArr, self::getDirs($path));
                }
            }
        }
        return $dirArr;
    }
443396
public function readDirectory($directory, $showDetail = false)
    {
        $this->ftp->chdir($this->getDefaultPath());
        if ($showDetail) {
            $list = $this->ftp->rawlist($directory);
            foreach ($list as &$file) {
                $file = new FileInfo($file);
            }

            return $list;
        } else {
            return $this->ftp->nlist($directory);
        }
    }
24197
public function listFiles( $filter = NULL ) : array
    {
        $path = $this->path;

        if ( !file_exists($path) )    return NULL;

        if ( !is_readable($path) )    return NULL;

        if ( is_file($path) )    return NULL;

        $files = array();

        $dh = opendir($path);
        while( ($file_name = readdir($dh)) !== FALSE ){
            if ( $file_name === '.' || $file_name === '..' ){
                continue;
            }
            $file = new File( $file_name, $this );
            if ( $filter ){
                if ( $filter instanceof FileFilterInterface ){
                    if ( $filter->accept($file) ){
                        $files[] = $file;
                    }
                }
                else if ( is_callable($filter) ){
                    if ( $filter($file) ){
                        $files[] = $file;
                    }
                }
            }
            else{
                $files[] = $file;
            }
        }
        return $files;
    }