List all files in the directory.

@param string $directory
@param bool   $recursive

@return array
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));
    }
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);
    }
84976
public function listContents($directory = '', $recursive = false)
	{
		$contents = parent::listContents($directory, $recursive);

		return $this->encapsulate($contents);
	}
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;
    }
214877
public function hydrateCommands(array $commands, string $directory, bool $recursive): array
    {
        return $this->getFactory()->createCommandHydrator($directory, $recursive)->hydrateCommands($commands);
    }
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);
    }
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;

   }
530013
public function dirs($resource, $recursive = false, $filter = null)
    {
        return $this->ls($resource, self::LS_MODE_DIR, $recursive, $filter);
    }
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;
	}
1073148
public function getAllChildren($recursive = false)
    {
        return $this->appendIterator(
            function ($path) use ($recursive) {
                return $path->getIterator($recursive);
            }
        );
    }
1370590
public function listFolder(string $path, bool $recursive = false) : array
	{
		$path = $this->normalizePath($path);
			
		$requestUrl = $this->siteUrl.'/sites/'.$this->siteName.'/_api/Web/GetFolderByServerRelativeUrl(\''.$this->folderPath.$path.'\')/Folders';
		
		$options = [
			'headers' => $this->requestHeaders,
		];
			
		$response = $this->send('GET', $requestUrl, $options);
			
		$folders = json_decode($response->getBody())->d ?? ['results' => []];
			
		// Making sure we convert the object to an array
		if (!is_array($folders)) {
			$folders = json_decode(json_encode($folders), true);
		}
			
		return $folders['results'];
	}
201046
public function listContents($path = '', $recursive = false)
    {
        $location = $this->applyPathPrefix($path);

        try {
            $files = $this->share->dir($location);
        } catch (InvalidTypeException $e) {
            return [];
        } catch (NotFoundException $e) {
            return [];
        }

        $result = [];

        foreach ($files as $file) {
            $result[] = $this->normalizeFileInfo($file);

            if ($file->isDirectory() && $recursive) {
                $result = array_merge($result, $this->listContents($this->getFilePath($file), true));
            }
        }

        return $result;
    }
191818
public function listFiles(string $path = '', bool $recursive = false)
    {
        $contents = $this->listContents($path, $recursive);

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

        return \array_values(\array_filter($contents, $filter));
    }
620954
public function ls($dir = '/.', $recursive = false, $ignore = array())
    {
        return $this->listItem('file', $dir, $recursive, $ignore);
    }
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;
    }
810981
public function listFiles($directory)
    {
        if (!file_exists($directory)) {
            return collect([]);
        }

        return $this->scanDir($directory)->reject(function ($item) {
            return !$this->isAllowedDirectory($item) && !$this->isYamlFile($item);
        })->mapWithKeys(function ($item) {
            if (is_dir($item)) {
                return [basename($item) => $this->listFiles($item)->toArray()];
            }

            return [$this->cleanKey($item) => $item];
        });
    }
282161
public function getDirectoryContents($dir, $ignoreFiles = [], $recursive = false)
    {
        $aDir = [];
        if (is_dir($dir)) {
            $handle = opendir($dir);
            while (($file = readdir($handle)) !== false) {
                if (substr($file, 0, 1) != '.' && (!in_array($file, $ignoreFiles))) {
                    if (is_dir($dir . '/' . $file)) {
                        if ($recursive) {
                            $aDir = array_merge($aDir, $this->getDirectoryContents($dir . '/' . $file, $ignoreFiles, $recursive));
                            $file = $dir . '/' . $file;
                        }
                        $aDir[] = preg_replace("/\/\//si", '/', $file);
                    } else {
                        if ($recursive) {
                            $file = $dir . '/' . $file;
                        }
                        $aDir[] = preg_replace("/\/\//si", '/', $file);
                    }
                }
            }
            closedir($handle);
        }

        return $aDir;
    }