Retrieve information about a file

@param string $url   Url
@param int    $flags Flags

@return array
491022
public function url_stat($url, $flags)
  {
    $partition = self::getPartition($url);
    $path = self::getRelativePath($url);

    return $partition->getStat($path, $flags);
  }
1120103
static function FileGet($url, $data = "", $verify_cert = false, $timeout = 30)
	{
		$qs = HttpRequest::ArrayToQueryString($data);
		$full_url = $url . ($qs ? "?" . $qs : "");
		return file_get_contents( $full_url );
	}
212795
protected function _getMaildirFiles($dh, $dirname, $default_flags = array())
    {
        while (($entry = readdir($dh)) !== false) {
            if ($entry[0] == '.' || !is_file($dirname . $entry)) {
                continue;
            }

            @list($uniq, $info) = explode(':', $entry, 2);
            @list(,$size) = explode(',', $uniq, 2);
            if ($size && $size[0] == 'S' && $size[1] == '=') {
                $size = substr($size, 2);
            }
            if (!ctype_digit($size)) {
                $size = null;
            }
            @list($version, $flags) = explode(',', $info, 2);
            if ($version != 2) {
                $flags = '';
            }

            $named_flags = $default_flags;
            $length = strlen($flags);
            for ($i = 0; $i < $length; ++$i) {
                $flag = $flags[$i];
                $named_flags[$flag] = isset(self::$_knownFlags[$flag]) ? self::$_knownFlags[$flag] : $flag;
            }

            $data = array('uniq'       => $uniq,
                          'flags'      => $named_flags,
                          'flaglookup' => array_flip($named_flags),
                          'filename'   => $dirname . $entry);
            if ($size !== null) {
                $data['size'] = (int)$size;
            }
            $this->_files[] = $data;
        }
    }
32774
public function info($url)
    {
        $url = 'http://' . $this->ip . '/' . ltrim($url, '/');
        $options = [
            CURLOPT_URL            => $url,
            CURLOPT_PORT           => $this->port,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_VERBOSE        => WS::config()->get('debug', false)
        ];

        $ch = curl_init();
        curl_setopt_array($ch, $options);
        $response = curl_exec($ch);

        return $this->formatResponse($response);
    }
991028
public function retrieveCertsFromLocation($url)
  {
    // If we're retrieving a local file, just grab it.
    if ("http" != substr($url, 0, 4)) {
      $file = file_get_contents($url);
      if ($file) {
        return json_decode($file, true);
      } else {
        throw new Exception(
            "Failed to retrieve verification certificates: '" .
            $url . "'."
        );
      }
    }

    // This relies on makeRequest caching certificate responses.
    $request = $this->client->getIo()->makeRequest(
        new Request(
            $url
        )
    );
    if ($request->getResponseHttpCode() == 200) {
      $certs = json_decode($request->getResponseBody(), true);
      if ($certs) {
        return $certs;
      }
    }
    throw new Exception(
        "Failed to retrieve verification certificates: '" .
        $request->getResponseBody() . "'.",
        $request->getResponseHttpCode()
    );
  }
983433
public function url_stat($path, $flags)
    {
        $stat = [
            'dev'     => 0,
            'ino'     => 0,
            'mode'    => 0777,
            'nlink'   => 0,
            'uid'     => 0,
            'gid'     => 0,
            'rdev'    => 0,
            'size'    => 0,
            'atime'   => 0,
            'mtime'   => 0,
            'ctime'   => 0,
            'blksize' => 0,
            'blocks'  => 0,
        ];
        $name = $this->_getNamePart($path);

        try {
            $info = $this->_getOssClient($path)->getObjectMeta(AliyunOSS::getBucket(), $name);
            if (isset($info['info']) && !empty($info['info'])) {
                $info = $info['info'];
                $stat['size'] = $info['download_content_length'];
                $stat['atime'] = time();
                $stat['mtime'] = $info['filetime'];
                $stat['mode'] |= 0100000;
            }
        } catch (\OSS\Core\OssException $e) {
            $stat['mode'] |= 040000;
        }

        return $stat;
    }
1347313
public function file_get_contents_curl($url)
    {
        $ch = curl_init();

        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser.
        curl_setopt($ch, CURLOPT_URL, $url);

        $data = curl_exec($ch);
        curl_close($ch);

        return $data;
    }
325553
private static function getImageFlag(array $flags): int
    {
        $res = 0;
        foreach ($flags as $flag) {
            $res |= constant(Image::class . '::' . $flag);
        }
        return $res;
    }
442945
public function url_stat($path, $flags)
    {
        self::restore();
        $path = self::overlayPath($path);
        if ($flags & STREAM_URL_STAT_LINK) {
            $information = @lstat($path);
        } else {
            $information = @stat($path);
        }
        self::register();
        return $information;
    }
70974
public function getPath($flags = 0x000000) {
    $ds = $this->getDS();

    $trail = $flags & self::WITHOUT_TRAILINGSLASH ? '' : $ds;

    return $this->prefix.(empty($this->path) ? '' : implode($ds, $this->path).$trail);
  }
62020
private function dispatchImagesInfo($urls)
    {
        if (empty($urls)) {
            return [];
        }

        $requests = [];

        foreach ($urls as $url) {
            $requests[] = Url::create($url);
        }

        return array_map(
            function (ImageResponse $response) {
                return [
                    'url' => (string) $response->getUrl(),
                    'width' => $response->getWidth(),
                    'height' => $response->getHeight(),
                    'size' => $response->getWidth() * $response->getHeight(),
                    'mime' => $response->getContentType(),
                ];
            },
            $this->getDispatcher()->dispatchImages($requests)
        );
    }
38416
private function readFiltersAndFlags(array $options, $filter = DEFAULT_FILTER, $flags = [])
    {

        //Merge the flags
        $_flags = (isset($options['flags']) && is_array($options['flags']))
            ? array_merge($options['flags'], [])
            : $flags;

        unset($options['filters']);
        // unset($options['flags']);


        //The PHP default santize (filter) uses a defined option definition format
        // array("options"=>array(), "filters"=>array(), "flags"=>array())
        $parameters = array_merge_recursive($options, ["flags" => $_flags]);

        return [$filter, $_flags, $parameters];

    }
1237921
public static function glob(string $pattern, int $flags = 0): array
    {
        $pattern = Path::clean($pattern);

        if (strpos($pattern, '**') === false) {
            $files = glob($pattern, $flags);
        } else {
            $position = strpos($pattern, '**');
            $rootPattern = substr($pattern, 0, $position - 1);
            $restPattern = substr($pattern, $position + 2);
            $patterns = [$rootPattern . $restPattern];
            $rootPattern .= DIRECTORY_SEPARATOR . '*';

            while ($dirs = glob($rootPattern, GLOB_ONLYDIR)) {
                $rootPattern .= DIRECTORY_SEPARATOR . '*';

                foreach ($dirs as $dir) {
                    $patterns[] = $dir . $restPattern;
                }
            }

            $files = [];

            foreach ($patterns as $pat) {
                $files[] = static::glob($pat, $flags);
            }

            $files = array_merge(...$files);
        }

        $files = array_unique($files);

        sort($files);

        return $files;
    }
44076
public function url_stat($path, $flags)
    {
        $stat = array();
        $stat['dev'] = 0;
        $stat['ino'] = 0;
        $stat['mode'] = 0;
        $stat['nlink'] = 0;
        $stat['uid'] = 0;
        $stat['gid'] = 0;
        $stat['rdev'] = 0;
        $stat['size'] = 0;
        $stat['atime'] = 0;
        $stat['mtime'] = 0;
        $stat['ctime'] = 0;
        $stat['blksize'] = 0;
        $stat['blocks'] = 0;
        
        $info = null;
        try {
            $metadata = $this->getStorageClient($path)->getBlobProperties($this->getContainerName($path), $this->getFileName($path));
            $stat['size'] = $metadata->getProperties()->getContentLength();
            
            // Set the modification time and last modified to the Last-Modified header.
            $lastmodified = $metadata->getProperties()
                ->getLastModified()
                ->format('U');
            $stat['mtime'] = $lastmodified;
            $stat['ctime'] = $lastmodified;
            
            // Entry is a regular file.
            $stat['mode'] = 0100000;
            
            return array_values($stat) + $stat;
        } catch (Exception $ex) {
            // Unexisting file...
            return false;
        }
    }
411188
public function str($flags = 0)
    {
        $ret = false;

        if ($this->match(TextTokenizer::STRING, $matches, $flags)) {
            $delimiter = $matches[2];
            $str = $matches[3];
            $str = str_replace("\\$delimiter", "$delimiter", $str);
            $ret = array($str);
        }

        return $ret;
    }
545860
public static function getParamsAsArray($url)
    {
        $query = parse_url($url, PHP_URL_QUERY);
        if (!$query) {
            return [];
        }
        $params = [];
        parse_str($query, $params);

        return $params;
    }
1298787
public function getFilePath($url)
    {
        return isset($this->_file_paths[$url]) ? $this->_file_paths[$url] : null;
    }