public function listDirectory($directory = '')
    {
        $this->ensureDirectoryExists($this->directory, $this->create);

        $directory = preg_replace('/^[\/]*([^\/].*)$/', '/$1', $directory);

        $items = $this->parseRawlist(
            ftp_rawlist($this->getConnection(), '-al '.$this->directory.$directory) ?: array()
        );

        $fileData = $dirs = array();
        foreach ($items as $itemData) {
            if ('..' === $itemData['name'] || '.' === $itemData['name']) {
                continue;
            }

            $item = array(
                'name' => $itemData['name'],
                'path' => trim(($directory ? $directory.'/' : '').$itemData['name'], '/'),
                'time' => $itemData['time'],
                'size' => $itemData['size'],
            );

            if ('-' === substr($itemData['perms'], 0, 1)) {
                $fileData[$item['path']] = $item;
            } elseif ('d' === substr($itemData['perms'], 0, 1)) {
                $dirs[] = $item['path'];
            }
        }

        $this->fileData = array_merge($fileData, $this->fileData);

        return array(
           'keys' => array_keys($fileData),
           'dirs' => $dirs,
        );
    }
public function listDirectory($directory = '')
    {
        $this->ensureDirectoryExists($this->directory, $this->create);

        $directory = preg_replace('/^[\/]*([^\/].*)$/', '/$1', $directory);

        $items = $this->parseRawlist(
            ftp_rawlist($this->getConnection(), '-al '.$this->directory.$directory) ?: array()
        );

        $fileData = $dirs = array();
        foreach ($items as $itemData) {
            if ('..' === $itemData['name'] || '.' === $itemData['name']) {
                continue;
            }

            $item = array(
                'name' => $itemData['name'],
                'path' => trim(($directory ? $directory.'/' : '').$itemData['name'], '/'),
                'time' => $itemData['time'],
                'size' => $itemData['size'],
            );

            if ('-' === substr($itemData['perms'], 0, 1)) {
                $fileData[$item['path']] = $item;
            } elseif ('d' === substr($itemData['perms'], 0, 1)) {
                $dirs[] = $item['path'];
            }
        }

        $this->fileData = array_merge($fileData, $this->fileData);

        return array(
           'keys' => array_keys($fileData),
           'dirs' => $dirs,
        );
    }
public function listDirectory ( $ directory = '' ) { $ this -> ensureDirectoryExists ( $ this -> directory , $ this -> create ) ; $ directory = preg_replace ( '/^[\/]*([^\/].*)$/' , '/$1' , $ directory ) ; $ items = $ this -> parseRawlist ( ftp_rawlist ( $ this -> getConnection ( ) , '-al ' . $ this -> directory . $ directory ) ? : array ( ) ) ; $ fileData = $ dirs = array ( ) ; foreach ( $ items as $ itemData ) { if ( '..' === $ itemData [ 'name' ] || '.' === $ itemData [ 'name' ] ) { continue ; } $ item = array ( 'name' => $ itemData [ 'name' ] , 'path' => trim ( ( $ directory ? $ directory . '/' : '' ) . $ itemData [ 'name' ] , '/' ) , 'time' => $ itemData [ 'time' ] , 'size' => $ itemData [ 'size' ] , ) ; if ( '-' === substr ( $ itemData [ 'perms' ] , 0 , 1 ) ) { $ fileData [ $ item [ 'path' ] ] = $ item ; } elseif ( 'd' === substr ( $ itemData [ 'perms' ] , 0 , 1 ) ) { $ dirs [ ] = $ item [ 'path' ] ; } } $ this -> fileData = array_merge ( $ fileData , $ this -> fileData ) ; return array ( 'keys' => array_keys ( $ fileData ) , 'dirs' => $ dirs , ) ; }
Lists files from the specified directory. If a pattern is
specified, it only returns files matching it.

@param string $directory The path of the directory to list from

@return array An array of keys and dirs
Lists files from the specified directory . If a pattern is specified it only returns files matching it .