Generate a list of all files in the specified directory.
@param  string  $disk
@param  string  $directory
@param  bool    $recursive
@return array
492147
protected function listFiles($disk, $directory = '', $recursive = true)
    {
        if ($recursive) {
            return $this->filesystem->disk($disk)->allFiles($directory);
        } else {
            return $this->filesystem->disk($disk)->files($directory);
        }
    }
955985
protected function listDirectoryContents($directory, $recursive = true)
    {
        $result = [];
        $connection = $this->getConnection();
        $location = $this->prefix($directory);
        $listing = $connection->rawlist($location);

        if ($listing === false) {
            return [];
        }

        foreach ($listing as $filename => $object) {
            if (in_array($filename, ['.', '..'])) {
                continue;
            }

            $path = empty($directory) ? $filename : ($directory.'/'.$filename);
            $result[] = $this->normalizeListingObject($path, $object);

            if ($recursive && isset($object['type']) && $object['type'] === NET_SFTP_TYPE_DIRECTORY) {
                $result = array_merge($result, $this->listDirectoryContents($path));
            }
        }

        return $result;
    }
309876
public function rawlistDirectory($parameters, $recursive = false)
    {
        $result = @ftp_rawlist($this->connection, $parameters, $recursive);

        if ($result === false) {
            throw new Exception('Unable to list directory');
        }

        return $result;
    }
795048
public function getFiles($recursive = false)
    {
        return $this->appendIterator(
            function ($path) use ($recursive) {
                return Filesystem::files((string) $path, $recursive);
            }
        );
    }
420809
protected function listDirectoryContents($directory, $recursive = true)
    {
        $directory = str_replace('*', '\\*', $directory);

        if ($recursive && $this->recurseManually) {
            return $this->listDirectoryContentsRecursive($directory);
        }

        $options = $recursive ? '-alnR' : '-aln';
        $listing = $this->ftpRawlist($options, $directory);

        return $listing ? $this->normalizeListing($listing, $directory) : [];
    }
292529
public function storeContents($directory, array $contents, $recursive = false)
    {
        $directories = [$directory];

        foreach ($contents as $object) {
            $this->updateObject($object['path'], $object);
            $object = $this->cache[$object['path']];

            if ($recursive && $this->pathIsInDirectory($directory, $object['path'])) {
                $directories[] = $object['dirname'];
            }
        }

        foreach (array_unique($directories) as $directory) {
            $this->setComplete($directory, $recursive);
        }

        $this->autosave();
    }
969812
public function listDirectories(bool $recursion = true): array {
		$filter = new class extends Filter {
			public function filter(File $dirOrPath): bool {
				/**
				 * @var File $dirOrPath
				 */
				return $dirOrPath->isDirectory();
			}
		};
		$index  = $this->addFilter($filter);
		$result = $this->listContents($recursion);
		$this->removeFilter($index);

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

        $directories = [ ];

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

        return $directories;
    }
1295904
protected function doListContents($directory, $recursive)
	{
		$filter = function ($path) use ($directory, $recursive) {
			// Remove the root directory from any listing.
			if ($path === '') {
				return false;
			}

			if (Util::dirname($path) === $directory) {
				return true;
			}

			return $recursive && $this->pathIsInDirectory($path, $directory);
		};

		return \array_filter(\array_keys($this->storage), $filter);
	}
189812
public function listPaths(string $path = '', bool $recursive = false)
    {
        $result = [];
        $contents = $this->listContents($path, $recursive);

        foreach ($contents as $object) {
            $result[] = $object['path'];
        }

        return $result;
    }
261436
public static List<File> listFiles(File dir, FileFilter filter, boolean recursive){
		List<File> list = new ArrayList<File>();
		listFilesInternal(list, dir, filter, recursive);
		return list;
	}
774089
public function handle($directory = '', $recursive = false)
    {
        $contents = $this->filesystem->listContents($directory, $recursive);

        $filter = function ($object) {
            return $object['type'] === 'file';
        };

        return array_values(array_filter($contents, $filter));
    }
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);
    }
53782
public static function recScandir($directory)
    {
        $arr = [];
        foreach (scandir($directory) as $f) {
            if ($f == '.' || $f == '..') {
                continue;
            } elseif (is_dir($directory . '/' . $f)) {
                $arr[$f] = self::recScandir($directory . '/' . $f);
            } else {
                $arr[$f] = 'file';
            }
        }
        return $arr;
    }
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;
    }
1295238
public static function directoryToArray($directory, $recursive = FALSE, $extension = NULL) {
    $array_items = array();
    if ($handle = opendir($directory)) {
      while (FALSE !== ($file = readdir($handle))) {
        if ($file != "." && $file != ".." && (empty($extension) ||
            (!empty($extension) && substr($file, -strlen($extension)) === $extension))
        ) {

          if (is_dir($directory . "/" . $file)) {
            if ($recursive) {
              $array_items = array_merge($array_items, self::directoryToArray($directory . "/" . $file, $recursive));
            }
          }
          else {
            $file = $directory . "/" . $file;
            $array_items[] = preg_replace("/\/\//si", "/", $file);
          }
        }
      }
      closedir($handle);
    }
    return $array_items;
  }
1355161
public static function files($path, $recursive = false, $pathType = self::PATH_ABSOLUTE)
    {
        $files = [];

        /** @var $file \SplFileInfo */
        foreach (Filesystem::files($path, $recursive) as $file) {
            switch ($pathType) {
                case ($pathType === self::PATH_BASENAME):
                    $name = $file->getBasename();
                    break;

                case ($pathType === static::PATH_RELATIVE):
                    $pathLength = strlen($path);
                    $name = $file->getRealPath();
                    $name = trim(substr($name, $pathLength), DIRECTORY_SEPARATOR);
                    break;

                case ($pathType === static::PATH_ABSOLUTE):
                default:
                    $name = $file->getPathname();
                    break;
            }

            $files[] = $name;
        }

        return $files;
    }