Get the contents listing.

@param string $dirname
@param bool   $recursive

@return array contents listing
195763
public function listContents($dirname = '', $recursive = false)
    {
        $result = [];

        foreach ($this->cache as $object) {
            if ($object === false) {
                continue;
            }
            if ($object['dirname'] === $dirname) {
                $result[] = $object;
            } elseif ($recursive && $this->pathIsInDirectory($dirname, $object['path'])) {
                $result[] = $object;
            }
        }

        return $result;
    }
201898
public static function simpleInfo($dir, $ext = null, $recursive = false): array
    {
        $list = [];
        $dir = self::pathFormat($dir);
        $ext = \is_array($ext) ? implode('|', $ext) : trim($ext);

        if (!is_dir($dir)) {
            throw new NotFoundException("directory not exists! DIR: $dir");
        }

        // glob()寻找与模式匹配的文件路径 $file is pull path
        foreach (glob($dir . '*') as $file) {

            // 匹配文件 如果没有传入$ext 则全部遍历，传入了则按传入的类型来查找
            if (is_file($file) && (!$ext || preg_match("/\.($ext)$/i", $file))) {
                //basename — 返回路径中的 文件名部分
                $list[] = basename($file);

                // is directory
            } else {
                $list[] = '/' . basename($file);

                if ($recursive) {
                    $list = array_merge($list, self::simpleInfo($file, $ext, $recursive));
                }
            }
        }

        return $list;
    }
1009688
protected function doRawList($dir, $recursive = false)
    {
        $connection = $this->connection;

        return $this->retry(function () use ($connection, $dir, $recursive) {
            $res = @ftp_rawlist($connection, $dir, $recursive);

            if (false === $res) {
                throw new \RuntimeException("Rawlist failed: ".$dir);
            }

            $items = array();

            foreach ($res as $child) {
                $chunks = preg_split("/\s+/", $child);
                list($item['rights'], $item['number'], $item['user'], $item['group'], $item['size'], $item['month'], $item['day'], $item['time']) = $chunks;
                $item['type'] = $chunks[0]{0}
                === 'd' ? 'directory' : 'file';
                array_splice($chunks, 0, 8);
                $item['name'] = implode(" ", $chunks);
                $item['pathname'] = \rtrim($dir, '/').'/'.$item['name'];
                $items[] = $item;
            }

            return $items;
        });
    }
536500
public function listContents($directory = '', $recursive = false): array
    {
        $result = parent::listContents($directory, $recursive);

        list(, $directory) = $this->getPrefixAndPath($directory);
        $relativePathPos = strlen(trim($directory, '/')) + 1;

        foreach ($result as &$file) {
            $file['relative_path'] = substr($file['path'], $relativePathPos);
        }

        return $result;
    }
628768
protected function listItem($type, $dir = '/.', $recursive = false, $ignore = array())
    {
        if ($type == 'dir') {
            $bool = true;
        } elseif ($type == 'file') {
            $bool = false;
        } else {
            throw new \InvalidArgumentException('$type must "file" or "dir"');
        }
        
        $parseDir = $this->parseLastDirectory($dir);
        $sDir = $this->getWrapper($parseDir);
        $fileList = array_diff(scandir($sDir), array('..', '.'));
        
        $fileInfo = array();
        foreach ($fileList as $file) {
            if ($this->ignoreItem($type, $file, $ignore) !== true && is_dir("$sDir/$file") === $bool) {
                $fileInfo[] = $file;
            }
            if ($recursive === true && is_dir("$sDir/$file") === true) {
                $fileInfo = array_merge($fileInfo, $this->listItem($type, "$dir/$file", $recursive, $ignore));
            }
        }
        
        return $fileInfo;
    }
84976
public function listContents($directory = '', $recursive = false)
	{
		$contents = parent::listContents($directory, $recursive);

		return $this->encapsulate($contents);
	}
373477
public function listDirectory($directory, $recursive = false)
    {
        $results = $this->scanDirectory($directory, $recursive);

        if (false === $results) {
            throw new \RuntimeException(sprintf(
                'Unable to list directory "%s", maybe it is not a directory '.
                'or it does not exist.',
                $directory
            ));
        }

        return array(
            'files'       => $results[0],
            'directories' => $results[1]
        );
    }
1059645
private function scanFolders(string $dir, bool $recursive): array
    {
        $files = [];

        // $dir comes from the database. The actual folder may not exist.
        if (is_dir($dir)) {
            foreach (scandir($dir, SCANDIR_SORT_NONE) as $path) {
                if (is_dir($dir . $path)) {
                    // What if there are user-defined subfolders “thumbs” or “watermarks”?
                    if ($path !== '.' && $path !== '..' && $path !== 'thumbs' && $path !== 'watermark' && $recursive) {
                        foreach ($this->scanFolders($dir . $path . '/', $recursive) as $subpath) {
                            $files[] = $path . '/' . $subpath;
                        }
                    }
                } else {
                    $files[] = $path;
                }
            }
        }

        return $files;
    }
873704
public function listSubdirs($key = '/', $recursive = false)
    {
        try {
            $data = $this->dirInfo($key, $recursive);
        } catch (EtcdException $e) {
            throw $e;
        }

        $iterator = new RecursiveArrayIterator($data);

        return $this->traversalDir($iterator);
    }
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;
    }
109549
public function getFiles($regex = null, $recursive = false)
    {
        //argument test
        Argument::i()
            //argument 1 must be a string
            ->test(1, 'string', 'null')
            //argument 2 must be a boolean
            ->test(2, 'bool');

        $this->absolute();

        $files = array();

        if ($handle = opendir($this->data)) {
            //for each file
            while (false !== ($file = readdir($handle))) {
                // If this is infact a file
                if (filetype($this->data . '/' . $file) == 'file'
                    && (!$regex || preg_match($regex, $file))) {
                    //add it
                    $files[] = File::i($this->data . '/' . $file);
                // recursive and this is infact a directory
                } else if ($recursive && $file != '.' && $file != '..'
                    && filetype($this->data .'/'. $file) == 'dir') {
                    $subfiles = self::i($this->data.'/'.$file);
                    $files = array_merge($files, $subfiles->getFiles($regex, $recursive));
                }
            }

            closedir($handle);
        }

        return $files;
    }
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;
    }
865626
public static function ListAllFiles( string $folder, bool $recursive = false ) : array
   {

      // Init the array that should contain the resulting file paths
      $files = [];

      if ( ! @\is_dir( $folder ) )
      {
         // No folder = we are done here
         return $files;
      }

      if ( ! $recursive )
      {
         // List only files directly contained inside $folder (none from sub folders)

         // Open the directory pointer
         $d = \dir( $folder );
         // Ignore . and ..
         $d->read(); $d->read();
         // loop the rest
         while ( false !== ( $entry = $d->read() ) )
         {
            $tmp = Path::Combine( $folder, $entry );
            if ( ! \is_file( $tmp ) )
            {
               // Ignore sub folders
               continue;
            }
            $files[] = $tmp;
         }
         $d->close();
         return $files;
      }

      // List all files, also from sub folders
      static::_listRecursive( $files, $folder );

      return $files;

   }
121139
public function listContents(string $directory = '', bool $recursive = false): array
    {
        list($prefix, $directory) = $this->getPrefixAndPath($directory);

        $fs     = $this->getFileSystem($prefix);
        $list   = $fs->listContents($directory, $recursive);

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

        unset($prefix, $directory, $fs);

        return $list;
    }
1151371
public function listContents($recursive = false)
	{
		return $this->hasAdapterOrFail()->adapter->listContents($this->getPath(), $recursive);
	}
1081758
public function mkdir($dir, $recursive = false)
    {
        $dir = $this->_getAbsoluteRemotePath($dir);
        if (false === @mkdir($dir, 0777, $recursive)) {
            return $this->_trigger_error(sprintf('Unable to make directory: %s.', $dir));
        }

        return true;
    }
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;
    }