Get items array of target dirctory

@param string $dirname
itemId path
@param bool $recursive
@param number $maxResults
@param string $query

@return array Items array
1733
protected function getItems($dirname, $recursive = false, $maxResults = 0, $query = '')
    {
        list (, $itemId) = $this->splitPath($dirname);

        $maxResults = min($maxResults, 1000);
        $results = [];
        $parameters = [
            'pageSize' => $maxResults ?: 1000,
            'fields' => $this->fetchfieldsList,
            'spaces' => $this->spaces,
            'q' => sprintf('trashed = false and "%s" in parents', $itemId)
        ];
        if ($query) {
            $parameters['q'] .= ' and (' . $query . ')';
        }
        $parameters = $this->applyDefaultParams($parameters, 'files.list');
        $pageToken = NULL;
        $gFiles = $this->service->files;
        $this->cacheHasDirs[$itemId] = false;
        $setHasDir = [];

        do {
            try {
                if ($pageToken) {
                    $parameters['pageToken'] = $pageToken;
                }
                $fileObjs = $gFiles->listFiles($parameters);
                if ($fileObjs instanceof Google_Service_Drive_FileList) {
                    foreach ($fileObjs as $obj) {
                        $id = $obj->getId();
                        $this->cacheFileObjects[$id] = $obj;
                        $result = $this->normaliseObject($obj, $dirname);
                        $results[$id] = $result;
                        if ($result['type'] === 'dir') {
                            if ($this->useHasDir) {
                                $setHasDir[$id] = $id;
                            }
                            if ($this->cacheHasDirs[$itemId] === false) {
                                $this->cacheHasDirs[$itemId] = true;
                                unset($setHasDir[$itemId]);
                            }
                            if ($recursive) {
                                $results = array_merge($results, $this->getItems($result['path'], true, $maxResults, $query));
                            }
                        }
                    }
                    $pageToken = $fileObjs->getNextPageToken();
                } else {
                    $pageToken = NULL;
                }
            } catch (Exception $e) {
                $pageToken = NULL;
            }
        } while ($pageToken && $maxResults === 0);

        if ($setHasDir) {
            $results = $this->setHasDir($setHasDir, $results);
        }
        return array_values($results);
    }
410450
static public function rmdir($dir, $recursive = false)
    {
        $dir = realpath($dir);
        if (!is_dir($dir)) return true;
        if (true !== $recursive) return @rmdir($dir);
        $dp = @opendir($dir);
        while ($file = @readdir($dp)) {
            if ('.' === $file || '..' === $file) continue;
            $cur_file = $dir . '/' . $file;
            if (is_dir($cur_file)) {
                self::rmdir($cur_file, true);
            } elseif (is_file($cur_file)) {
                @unlink($cur_file);
            }
        }
        @closedir($dp);
        return @rmdir($dir);
    }
373576
public function scanDir($directory = '.', $recursive = false)
    {
        return $this->parseRawList($this->rawlist($directory, $recursive));
    }
492542
public function listContents($directory = '', $recursive = false)
    {
        $list = [];

        $response = $this->listObjects($directory, $recursive);

        foreach ((array) $response->get('Contents') as $content) {
            $list[] = $this->normalizeFileInfo($content);
        }

        return $list;
    }
282616
static public function getFiles( $dir, $recursive = false )
    {
        $files = [];
        if ( ( $dh = opendir( $dir ) ) ) {
            while ( ( $file = readdir( $dh ) ) !== false ) {
                if ( is_file( $dir . '/' . $file ) ) {
                    $files[] = $file;
                }
                if ( $recursive && ( $file !== '.' && $file !== '..' && is_dir( $dir . '/' . $file ) ) ) {
                    $files = array_merge( $files, self::getFiles( $dir . DS . $file, true ) );
                }
            }
            closedir( $dh );
        }
        return $files;
    }
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;

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

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

        return $contents;
    }
113881
public function listContents($directory = '', $recursive = false)
    {
        $bucketMgr = $this->getBucketManager();

        list($items, $marker, $error) = $bucketMgr->listFiles($this->bucket, $directory);
        if ($error !== null) {
            $this->logQiniuError($error);

            return array();
        } else {
            $contents = array();
            foreach ($items as $item) {
                $normalized = [
                    'type' => 'file',
                    'path' => $item['key'],
                    'timestamp' => $item['putTime']
                ];

                if ($normalized['type'] === 'file') {
                    $normalized['size'] = $item['fsize'];
                }

                array_push($contents, $normalized);
            }

            return $contents;
        }
    }
146759
public function getFileList( $path = "", $recursive = FALSE )
	{
		$this->connection->checkConnection();
		$results	= array();
		$list		= $this->getList( $path, $recursive );
		foreach( $list as $entry )
			if( !preg_match( "@/?[.]{1,2}$@", $entry['name'] ) )
				if( !$entry['isdir'] )
					$results[]	= $entry;
		return $results;
	}
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) : [];
    }
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;
    }
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;
    }
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;
    }
796742
public function getTree($parentId = null, $recursive = true)
    {
        $queryBuilder = $this->driver->getSelectQueryBuilder();
        if ($parentId === null) {
            $queryBuilder->andWhere($this->getParentField() . " IS NULL");
        } else {
            $queryBuilder->andWhere($this->getParentField() . " = " . $parentId);
        }
        $statement  = $queryBuilder->execute();
        $rows       = $statement->fetchAll();
        $hasResults = count($rows) > 0;

        // Cast array to DataItem array list
        if ($hasResults) {
            $this->driver->prepareResults($rows);
        }

        if ($recursive) {
            /** @var DataItem $dataItem */
            foreach ($rows as $dataItem) {
                $dataItem->setChildren($this->getTree($dataItem->getId(), $recursive));
            }
        }

        return $rows;
    }
623938
public function listContents($dirname = '', $recursive = false)
	{
		if ($recursive) {
			throw new BadMethodCallException('Recursive listing is not yet implemented');
		}

		$keys = [];
		$cursor = $this->client->find([
			'filename' => new MongoRegex('/^' . $dirname . '/'),
		]);
		foreach ($cursor as $file) {
			$keys[] = $this->normalizeGridFSFile($file);
		}

		return Util::emulateDirectories($keys);
	}
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;
    }
698617
public function getFolders($recursive = false)
    {
        return $this->appendIterator(
            function ($path) use ($recursive) {
                return Filesystem::folders((string) $path, $recursive);
            }
        );
    }