List all paths.

@param string $path
@param bool   $recursive

@return array paths
189812
public function listPaths(string $path = '', bool $recursive = false)
    {
        $result = [];
        $contents = $this->listContents($path, $recursive);

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

        return $result;
    }
226974
public function listContents($path = '/', $recursive = false)
    {
        $contents = $this->getApi()->getTreeMetadata($path, $recursive);

        if ($this->isDirectoryContents($contents) === false) {
            $contents = [];
        }

        return $contents;
    }
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);
    }
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;
    }
795048
public function getFiles($recursive = false)
    {
        return $this->appendIterator(
            function ($path) use ($recursive) {
                return Filesystem::files((string) $path, $recursive);
            }
        );
    }
1092847
static function recursiveList( $dir, $path, &$fileList )
    {
        if ( $handle = @opendir( $dir ) )
        {
            while ( ( $file = readdir( $handle ) ) !== false )
            {
                if ( ( $file == "." ) || ( $file == ".." ) )
                {
                    continue;
                }
                if ( is_dir( $dir . '/' . $file ) )
                {
                    $fileList[] = array( 'path' => $path, 'name' => $file, 'type' => 'dir' );
                    eZDir::recursiveList( $dir . '/' . $file, $path . '/' . $file, $fileList );
                }
                else
                {
                    $fileList[] = array( 'path' => $path, 'name' => $file, 'type' => 'file'  );
                }
            }
            @closedir( $handle );
        }
    }
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;
    }
553140
protected function _list($path, $prefix = '', $mode = 'file', $recursive = false, $filter = null)
    {
        $files  = [];
        $ignore = ['.', '..', '.DS_Store', '.svn', '.git', '.gitignore', '.gitmodules', 'cgi-bin'];

        if ($scan = @scandir($path)) {
            foreach ($scan as $file) {
                // continue if ignore match
                if (Arr::in($file, $ignore)) {
                    continue;
                }

                if (is_dir($path . '/' . $file)) {
                    // add dir
                    if ($mode === 'dir') {
                        // continue if no regex filter match
                        if ($filter && !preg_match($filter, $file)) {
                            continue;
                        }

                        $files[] = $prefix . $file;
                    }

                    // continue if not recursive
                    if (!$recursive) {
                        continue;
                    }

                    // read subdirectory
                    $files = array_merge(
                        $files,
                        $this->_list($path . '/' . $file, $prefix . $file . '/', $mode, $recursive, $filter)
                    );

                } else {
                    // add file
                    if ($mode === 'file') {
                        // continue if no regex filter match
                        if ($filter && !preg_match($filter, $file)) {
                            continue;
                        }

                        $files[] = $prefix.$file;
                    }
                }
            }
        }

        return $files;
    }
24336
public function listContents($directory = '', $recursive = false)
    {
        // get resources array
        $resources = ((array) $this->api->resources([
            'type' => 'upload',
            'prefix' => $directory
        ])['resources']);

        // parse resourses
        foreach ($resources as $i => $resource) {
            $resources[$i] = $this->prepareResourceMetadata($resource);
        }

        return $resources;
    }
1073148
public function getAllChildren($recursive = false)
    {
        return $this->appendIterator(
            function ($path) use ($recursive) {
                return $path->getIterator($recursive);
            }
        );
    }
1058739
public static function delete($path, $recursive = false)
    {
        Path::validatePath($path);

        if ($recursive) {
            Path::purge($path);
        }

        if (@rmdir($path)) {
            return;
        }

        throw new IOException(sprintf("Cannot delete path %s.", $path));
    }
503402
public function listContents($directory = '', $recursive = false)
    {
        $files = [];
        foreach($this->listDirContents($directory) as $k => $file) {
            $pathInfo = pathinfo($file['key']);
            $files[] = array_merge($pathInfo, $this->normalizeData($file), [
                'type' => isset($pathInfo['extension']) ? 'file' : 'dir',
            ]);
        }
        return $files;
    }
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());
    }
1200843
public function listContents($directory = '', $recursive = false)
    {
        $directory = Util::normalizePath($directory);
        $contents = $this->adapter->listContents($directory, $recursive);

        return ContentListingFormatter::formatListing($directory, $recursive, $contents);
    }
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;
    }
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;
    }
910377
public function mkdir($path, $mode = 0777, $recursive = false)
    {
        if (null !== $this->at($path)) {
            trigger_error("mkdir(): File exists");
            return false;
        }

        $parts = explode('/', $this->realpath($path));
        $filesCount = 0;
        $missing = [];
        $item = array_shift($parts);
        foreach ($parts as $part) {
            $item .= "/{$part}";
            $node = $this->at($item);
            if ($node === null) {
                $missing[] = $item;
            } else if ($node->type == 'file') {
                $filesCount ++;
            }
        }

        if ($filesCount > 0) {
            trigger_error("mkdir(): Not a directory");
            return false;
        }

        if (count($missing) > 1 && !$recursive) {
            trigger_error("mkdir(): No such file or directory");
            return false;
        }

        foreach ($missing as $path) {
            $this->at($path, (object) [
                'type' => 'dir',
                'perms' => $mode
            ]);
        }

        return true;
   }