Get all of the directories within a given directory.

@param  string|null  $directory
@param  bool  $recursive
@return array
498293
public function directories($directory = null, $recursive = false)
    {
        $contents = $this->driver->listContents($directory, $recursive);

        return $this->filterContentsByType($contents, 'dir');
    }
31232
public function listContents($directory = '', $recursive = false)
    {
        list($prefix, $directory) = $this->getPrefixAndPath($directory);
        $filesystem = $this->getFilesystem($prefix);
        $result = $filesystem->listContents($directory, $recursive);

        foreach ($result as &$file) {
            $file['filesystem'] = $prefix;
        }

        return $result;
    }
859752
public function listContents($directory = '', $recursive = false)
    {
        try{
            //组合目录
            $directory  = static::normalizerPath($directory);

            $file_list = $this->getUpyun()->getList($directory);

            if (is_array($file_list) && count($file_list) > 0 ) {
                foreach ($file_list as &$file) {
                    $file['path']   = static::normalizerPath($directory) . DIRECTORY_SEPARATOR . $file['name'];
                }
            }
            return $file_list;
        }catch (Exception $e){

        }
        return [];
    }
1257681
public function files($directory, $recursive = false)
    {
        $result     = [];
        $recursive  = boolval($recursive);

        if ( ! $this->isDirectory($directory)) return [];

        $items = new FilesystemIterator($directory);

        foreach ($items as $item) {
            if ($item->isFile()) {
                $result[]       = $item->getPathname();
            } elseif ($recursive && $item->isDir() && ! $item->isLink()) {
                $subFiles       = $this->files($item->getPathname(), $recursive);
                foreach ($subFiles as $file) {
                    $result[]   = $file;
                }
            }
        }

        return $result;
    }
554210
public function listContents($directory = '', $recursive = false)
    {
        $directory = rtrim($this->applyPathPrefix($directory), '\\/');
        if ($directory) $directory.='/';

        $bucket = $this->bucket;
        $delimiter = '/';
        $nextMarker = '';
        $maxkeys = 1000;
        $options = [
            'delimiter' => $delimiter,
            'prefix'    => $directory,
            'max-keys'  => $maxkeys,
            'marker'    => $nextMarker,
        ];

        $listObjectInfo = $this->client->listObjects($bucket, $options);

        $objectList = $listObjectInfo->getObjectList(); // 文件列表
        $prefixList = $listObjectInfo->getPrefixList(); // 目录列表

        $result = [];
        foreach ($objectList as $objectInfo) {
            if ($objectInfo->getSize() === 0 && $directory === $objectInfo->getKey()) {
                $result[] = [
                    'type'      => 'dir',
                    'path'      => $this->removePathPrefix(rtrim($objectInfo->getKey(), '/')),
                    'timestamp' => strtotime($objectInfo->getLastModified()),
                ];
                continue;
            }

            $result[] = [
                'type'      => 'file',
                'path'      => $this->removePathPrefix($objectInfo->getKey()),
                'timestamp' => strtotime($objectInfo->getLastModified()),
                'size'      => $objectInfo->getSize(),
            ];
        }

        foreach ($prefixList as $prefixInfo) {
            if ($recursive) {
                $next = $this->listContents($this->removePathPrefix($prefixInfo->getPrefix()), $recursive);
                $result = array_merge($result, $next);
            } else {
                $result[] = [
                    'type'      => 'dir',
                    'path'      => $this->removePathPrefix(rtrim($prefixInfo->getPrefix(), '/')),
                    'timestamp' => 0,
                ];
            }
        }

        return $result;
    }
10540
public function listContents(string $directory = '', bool $recursive = false): array
    {
        $list = [];
        $location = $this->applyBasePath($directory);

        if (! is_dir($location)) {
            return $list;
        }

        $iterator = $recursive ?
                    $this->getRecursiveDirectoryIterator($location) :
                    $this->getDirectoryIterator($location);

        foreach ($iterator as $file) {
            $path = $this->getFilePath($file);

            if (preg_match('#(^|/|\\\\)\.{1,2}$#', $path)) {
                continue;
            }

            $list[] = $this->normalizeFileInfo($file);

            unset($path);
        }

        unset($location, $iterator);

        return array_filter($list);
    }
470039
public function listWith(array $keys = [], $directory = '', $recursive = false)
    {
        [$fs, $directory] = $this->getFilesystemAndPath($directory);

        return $fs->listWith($keys, $directory, $recursive);
    }
547170
protected function listDirectoryContents($directory, $recursive = true)
	{
		$result = [
			[]
		];
		$connection = $this->getConnection();
		$location = $this->prefix($directory);

		if (!$stream = @\ssh2_exec($connection, "ls {$location}")) {
			return [];
		}

		\stream_set_blocking($stream, true);
		$cmd = \fread($stream, 4096);
		$listing = \explode("\n", $cmd);

		foreach ($listing as $filename) {
			if (\in_array($filename, ['.', '..'], true)) {
				continue;
			}

			$path = empty($directory) ? $filename : ($directory . '/' . $filename);
			$stat = $this->getMetadata($path);
			$result[0][] = $stat;

			if ($recursive && $stat['type'] === 'dir') {
				$result[] = $this->listDirectoryContents($path);
			}
		}

		return !isset($result[1]) ? $result[0] : \array_merge(...$result);
	}
561427
public function listContents($directory = '', $recursive = false)
    {
        $directory = $this->applyPathPrefix($directory);

        $objects = $this->bucket->objects(
            [
                'prefix' => $directory,
            ]
        );

        $contents = [];
        foreach ($objects as $apiObject) {
            if (null !== $apiObject) {
                $contents[] = $this->convertObjectInfo($apiObject);
            }
        }

        // if directory, skip the directory object
        // if directory, truncate prefix + delimiter
        if ('' !== $directory) {
            foreach ($contents as $idx => $objectInfo) {
                if ('dir' === $objectInfo['type'] && $objectInfo['path'] === $directory) {
                    $contents[$idx] = false;
                }
            }
        }

        return array_filter($contents);
    }
172487
protected function getSchemas($directory, $recursive = false)
    {
        $finder = new Finder();
        $finder
            ->name('*schema.xml')
            ->sortByName()
            ->in($directory);
        if (!$recursive) {
            $finder->depth(0);
        }

        return iterator_to_array($finder->files());
    }
49401
public function getList( $path = "", $recursive = FALSE )
	{
		$this->connection->checkConnection();
		$parsed	= array();
		if( !$path )
			$path	= $this->getPath();
		$list	= ftp_rawlist( $this->connection->getResource(), $path );
		if( is_array( $list ) )
		{
			foreach( $list as $current )
			{
				$data	= $this->parseListEntry( $current );
				if( count( $data ) )
				{
					$parsed[]	= $data;
					if( $recursive && $data['isdir'] && $data['name'] != "." && $data['name'] != ".." )
					{
						$nested	= $this->getList( $path."/".$data['name'], TRUE );
						foreach( $nested as $entry )
						{
							$entry['name']	= $data['name']."/".$entry['name'];
							$parsed[]	= $entry;
						}
					}
				}
			}
		}
		return $parsed;
	}
691664
private function recursiveSearch($directory)
    {
        
		if (is_dir($directory)) {
	    	// We get the list of files and directories.
	    	if (($files = scandir($directory)) !== false) {
	    		
	    		foreach($files as $fd) {
	
	   		 		if (!preg_match("/^\./", $fd) &&  $fd != "ext") {
	   		 			// If it is a directory ...
	   		 			if (is_dir($directory . $fd. "/")) {
	   		 				$this->recursiveSearch($directory . $fd . "/");
		    			// If it is a file ...
	    				} else {
	    					// Retrieve from the file ...
	    					$this->getTranslationsInFile($directory . $fd);
	    				}
	   		 		}
	    			
	    		}
	    	}   	
		}
		
        
    }
17999
static public function getFolders( $dir, $recursive = false )
    {
        $subDirs = [];
        if ( ( $dh = opendir( $dir ) ) ) {
            while ( ( $file = readdir( $dh ) ) !== false ) {
                if ( $file !== '.' && $file !== '..' && is_dir( $dir . '/' . $file ) ) {
                    $subDirs[] = $file;
                    if ( $recursive ) {
                        $subDirs = array_merge( $subDirs, self::getFolders( $dir . DS . $file, true ) );
                    }
                }
            }
            closedir( $dh );
        }
        return $subDirs;
    }
786218
public function listFiles(bool $recursion = true): array {
		$filter = new class extends Filter {
			public function filter(File $dirOrPath): bool {
				/**
				 * @var File $dirOrPath
				 */
				return $dirOrPath->isFile();
			}
		};
		$index  = $this->addFilter($filter);
		$result = $this->listContents($recursion);
		$this->removeFilter($index);

		return $result;
	}
143258
public function listDir($key = '/', $recursive = false)
    {
        $query = array();
        if ($recursive === true) {
            $query['recursive'] = 'true';
        }
        $response = $this->guzzleclient->get(
            $this->buildKeyUri($key),
            array(
                'query' => $query
            )
        );
        $body = json_decode($response->getBody(), true);
        if (JSON_ERROR_NONE !== json_last_error()) {
            throw new RuntimeException('Unable to parse response body into JSON: ' . json_last_error());
        }

        if (isset($body['errorCode'])) {
            throw new KeyNotFoundException($body['message'], $body['errorCode']);
        }

        return $body;
    }
408660
public function listWith(array $keys = [], $directory = '', $recursive = false)
    {
        list($prefix, $directory) = $this->getPrefixAndPath($directory);
        $arguments = [$keys, $directory, $recursive];

        return $this->invokePluginOnFilesystem('listWith', $arguments, $prefix);
    }
196904
public function listFiles($directory = null, $recursive = false)
    {
        return $this->flysystem->listFiles($directory, $recursive);
    }