Writes found URLs to a List File and returns Number of written Bytes.
@access		public
@param		string		$uri		File Name of Block Log File
@return		int
19611
public function saveUrls( $uri )
	{
		$list	= array();
		foreach( $this->links as $link )
			$list[]	= $link['url'];
		$writer	= new FS_File_Writer( $uri );
		$writer->writeArray( $list );
	}
1374396
static public function escapeUri(string $uri): string {
        self::initSerializer();
        return self::$serializer->serialiseValue(new Resource($uri));
    }
42635
private function getCompleteUrl($uri = '')
    {
        $uri = $uri === '' ? $this->urlResolver->getPath() : $uri;
        $url = sprintf('%s%s', $this->urlResolver->getDomain(), $uri);

        if ($this->isGet() && $this->GET) {
            $url = sprintf('%s?%s', $url, http_build_query($this->GET->getAll()));
        }

        return $url;
    }
1074123
private function base64Encode($uri) {

        if (null === $uri) {
            return null;
        }

        $splFileObject = new SplFileObject($uri);

        if (30100 < Kernel::VERSION_ID) {
            return (new DataUriNormalizer())->normalize($splFileObject);
        }

        $data = "";
        while (false === $splFileObject->eof()) {
            $data .= $splFileObject->fgets();
        }

        return sprintf("data:%s;base64,%s", mime_content_type($uri), base64_encode($data));
    }
1197553
private function abridgeUri($uri)
    {
        $i = 30;
        $j = 12;

        if (mb_strlen($uri) <= $i) {
            return $uri;
        }

        $host = rtrim(parse_url($uri, PHP_URL_HOST), '/');
        $path = '/'.ltrim(parse_url($uri, PHP_URL_PATH), '/');

        if ($host === getenv('HTTP_HOST')) {
            $i = 50;
            $j = 22;

            $host = '';
        } else {
            if (mb_strlen($host) > $i && mb_strlen($path) > $i) {
                return $this->abridgeStr($uri, 50, 22);
            }

            $host = $this->abridgeStr($host, 20, 7);
        }

        $path = $this->abridgeStr($path, $i, $j);

        return $host.$path;
    }
653352
public static function addTrailingSlash($uri)
    {
        $uri = self::filterUri($uri);
        $path = $uri->getPath();
        if ('/' !== substr($path, -1)) {
            $path .= '/';
        }

        return self::normalizePath($uri, $path);
    }
357389
static function pageAction($uri)
    {
        $write = R::is('POST') and R::get('confirm');
        $page = page($uri);
        $builder = new Builder();
        $data = [
            'mode'    => 'page',
            'error'   => false,
            'confirm' => $write,
            'summary' => []
        ];
        if (!$page) {
            $data['error'] = "Error: Cannot find page for \"$uri\"";
        }
        else {
            $builder->run($page, $write);
            $data['summary'] = $builder->summary;
        }
        return $builder->htmlReport($data);
    }
866359
public function read(string $uri): Response
    {
        $contents = @file_get_contents($uri);

        if (false === $contents) {
            throw new ResourceNotReadableException("Failed reading '$uri'");
        }

        return new Response(
            preg_match('/\b(yml|yaml|raml)\b/', $uri) ? self::CONTENT_TYPE_YAML : self::CONTENT_TYPE_JSON,
            $contents
        );
    }
221487
public static function findRoute($uri) {
		if(self::$routes === array())
			self::load();

		$count = count($uri);

		$position = &self::$routes;
		for($i = 0; $i < $count; $i++) {
			if($i == $count - 1) {
				if(isset($position[$uri[$i]]) && isset($position[$uri[$i]]["route"])) {
					return $position[$uri[$i]]["route"];
				} else if(isset($position["*"]) && isset($position["*"]["route"])) {
					return $position["*"]["route"];
				} else {
					throw new ValidRouteNotFoundException;
				}
			} else {
				if(isset($position[$uri[$i]])) {
					$position = &$position[$uri[$i]]["children"];
				} elseif(isset($position["*"])) {
					$position = &$position["*"]["children"];
				} else {
					throw new ValidRouteNotFoundException;
				}
			}
		}

		throw new ValidRouteNotFoundException;
	}
61112
protected function writeCache()
    {
        $chunkSize = 1024 * 8;

        // open remote file
        $arrContextOptions = array(
            "ssl" => array(
                "verify_peer" => false,
                "verify_peer_name" => false,
            ),
        );
        $remoteFile = fopen(
            $this->pathFile,
            'rb',
            null,
            stream_context_create($arrContextOptions)
        );
        if (!$remoteFile) {
            throw new \RuntimeException(
                sprintf(
                    "Couldn't open file at %s",
                    $this->pathFile
                )
            );
        }

        // open cache file
        $cacheFile = fopen($this->pathCache, 'wb');
        if (!$cacheFile) {
            fclose($remoteFile);
            throw new \RuntimeException(
                sprintf(
                    "Couldn't open cache file at %s",
                    $this->pathCache
                )
            );
        }

        // write file to cache
        while (!feof($remoteFile)) {
            fwrite(
                $cacheFile,
                fread($remoteFile, $chunkSize),
                $chunkSize
            );
        }

        // close cache file
        fclose($cacheFile);

        // close remote file
        fclose($remoteFile);
    }
131530
public function findURI(string $uri)
    {
        foreach ($this->members as $offset => $member) {
            if ($member->uri == $uri) {
                return $offset;
            }
        }
        return -1;
    }
712860
static public function getBaseUrl($uri='')
	{
		$baseUrl  = static::getRootUrl();
		$baseUrl .= isset($_SERVER['SCRIPT_NAME']) ? dirname($_SERVER['SCRIPT_NAME']) : dirname(getenv('SCRIPT_NAME'));
		
		return rtrim(str_replace('\\', '/', $baseUrl), '/');
	}
486768
public function toRequestString(string $uri = ''): string
    {
        return !empty($this->raw) ? self::kvToRequestString($this->toRequestArray($uri)) : '';
    }
243290
protected function prepareUrlForRequest($uri)
    {
        if (Str::startsWith($uri, '/')) {
            $uri = substr($uri, 1);
        }

        if (! Str::startsWith($uri, 'http')) {
            $uri = ($this->baseUrl ?? config('app.url')) . '/' . $uri;
        }

        return trim($uri, '/');
    }
872067
private function uriToDirectoryName($uri)
    {
        $parts = parse_url($uri);

        $return = [];

        if (!empty($parts['port']) && 80 !== $parts['port']) {
            $return[] = $parts['port'];
        }
        $return[] = $parts['host'];
        if (!empty($parts['path'])) {
            $return[] = str_replace('/', '.', trim($parts['path'], '/'));
        }

        return implode('.', array_filter($return));
    }
807776
public function writeUri($uri)
    {
        try {
            $this->writeString($uri);
        } catch (BinaryStreamAccessException $e) {
            $msg = "An error occured while writing a URI.";
            throw new QtiBinaryStreamAccessException($msg, $this, QtiBinaryStreamAccessException::URI, $e);
        }
    }
580560
public function fillCache($uri)
    {
        $cacheKey = $uri . '@cache';

        if (!isset($this->cache[$cacheKey])) {
            $this->cache[$cacheKey] = true;

            $iterator = new \RecursiveIteratorIterator($this->getRecursiveIterator($uri), \RecursiveIteratorIterator::SELF_FIRST);

            /** @var UniformResourceIterator $uri */
            foreach ($iterator as $item) {
                $key = $item->getUrl() . '@010';
                $this->cache[$key] = $item->getPathname();
            }
        }

        return $this;
    }