Returns the real path for the given additional path and the
file path which was given to the backend in the constructor.

@access public
@param string $additionalPath
@return string
329652
protected function realPath($additionalPath)
    {
        if (substr($additionalPath, 0, 1) === '/') {
            $path = $additionalPath;
        } else if ($additionalPath !== '') {
            $path = $this->path . $additionalPath;
        } else {
            $path = $this->path;
        }
    
        return $path;
    }
790186
private function resolvePath($path)
    {
        // Find and replace the @BundleName with the absolute path to the bundle.
        $matches = [];
        preg_match('/(^|\/)@(\w+)/', $path, $matches);
        if (isset($matches[0], $matches[2], $this->bundle_paths[$matches[2]])) {
            return realpath(str_replace($matches[0], $this->bundle_paths[$matches[2]], $path));
        }

        // The path doesn't contain a bundle name. In this case it must exist in %kernel.root_dir%/Resources/views
        $path = $this->root_dir . DIRECTORY_SEPARATOR . 'Resources' . DIRECTORY_SEPARATOR . $path;
        if (file_exists($path)) {
            return $path;
        }

        return false;
    }
692247
public function getRelativePath()
    {
        $templates = $this->config['directories']['templates'];

        $extension = $this->config['templates']['extension'];

        return $templates . '/' . $this->getFilename($extension);
    }
756515
public function findFile($filePath)
    {
        if (file_exists($filePath)) {
            return $filePath;
        }
        foreach ($this->supportedExtensions as $extension)
        {
            $extendedFilePath = $filePath.'.'.$extension;
            if (file_exists($extendedFilePath)) {
                return $extendedFilePath;
            }
            $extendedFilePath = $filePath.'.'.strtoupper($extension);
            if (file_exists($extendedFilePath)) {
                return $extendedFilePath;
            }
            $extendedFilePath = $filePath.'.'.ucfirst($extension);
            if (file_exists($extendedFilePath)) {
                return $extendedFilePath;
            }
        }
        return null;
    }
219607
private function getRealFilePath( string $filePath ) : string
	{
		$realFilePath = getcwd() . DIRECTORY_SEPARATOR . ltrim( $filePath, '/' );
		$outputDir    = dirname( $realFilePath );
		if ( !@mkdir( $outputDir, 0777, true ) && !is_dir( $outputDir ) )
		{
			throw new InvalidArgumentException( 'Invalid file path: ' . $realFilePath );
		}

		return $realFilePath;
	}
353315
protected static function getRelativePath($path)
	{
		preg_match('/([[:alpha:]]*):\/\/(.*)/', $path, $name);

		if (isset($name[2]) && $name[2])
		{
			return $name[2];
		}

		return $path;
	}
1221649
public function getPath($path)
    {
        if (! is_array($path)) {
            $path = [$path];
        }

        $search_for = [
            '%BASE',
            '%STORAGE',
        ];

        $replace_by = [
            base_path(),
            storage_path(),
        ];

        if (function_exists('app_path')) {
            $search_for[] = '%APP';
            $replace_by[] = app_path();
        }

        if (function_exists('public_path')) {
            $search_for[] = '%PUBLIC';
            $replace_by[] = public_path();
        }

        $folders = str_replace($search_for, $replace_by, $path);

        foreach ($folders as $k => $v) {
            $folders[$k] = realpath($v);
        }

        return $folders;
    }
338089
public static function formatDirectory($pathOrPaths, ...$additionalPaths)
    {
        $directory = self::formatPath($pathOrPaths, ...$additionalPaths);

        if ($directory) {
            $directory = rtrim($directory, "/") . "/";
        }

        return $directory;
    }
755794
public static function Make($path, $extras=array(), $sep="/")
	{
		$ext = "";

		if (sizeof($extras) > 0)
			foreach ($extras as $e)
				$ext .= (string) $e . $sep;


		/* dont seperate if no extras were provided */

		if ($ext != "")
			return $path . $sep . $ext;
		

		return $path;
	}
353054
static function getSymbolicPath($realpath)
    {
        $root = $_SERVER['DOCUMENT_ROOT'];
        $script = $_SERVER['SCRIPT_FILENAME'];
        $root = str_replace('\\', '/', $root);
        $script = str_replace('\\', '/', $script);
        $realpath = str_replace('\\', '/', $realpath);
        
        $dir = str_replace($root, '', $script);
        $pos = false;
        $dir = self::getDir($dir);
        while (! empty($dir)) {
            $pos = strpos($realpath, $dir);
            if ($pos) {
                break;
            }
            $dir = self::getDir($dir);
        }
        if ($pos) {
            $realpath = $root . substr($realpath, $pos);
        }
        return $realpath;
    }
1211931
static public function getRelPath(string $fullPath): string {
        $contDir = RC::get('containerDir');
        if (!strpos($fullPath, $contDir) === 0) {
            throw new InvalidArgumentException('path is outside the container');
        }
        $contDir = preg_replace('|/$|', '', $contDir);
        return substr($fullPath, strlen($contDir) + 1);
    }
723264
public static function getRootDirectoryPath($additional_path = null)
    {
        $root = \dirname(\dirname(\dirname(__DIR__)));

        return \is_string($additional_path) && ! empty($additional_path)
            ? $root . DIRECTORY_SEPARATOR . ltrim((string) $additional_path, ' \\/')
            : $root;
    }
1300808
public function get_path($path)
	{
		$pathinfo = is_dir($path) ? array('dirname' => $path, 'extension' => null, 'basename' => '') : pathinfo($path);

		// make sure we have a dirname to work with
		isset($pathinfo['dirname']) or $pathinfo['dirname'] = '';

		// do we have a basedir, and is the path already prefixed by the basedir? then just deal with the double dots...
		if ( ! empty($this->basedir) && substr($pathinfo['dirname'], 0, strlen($this->basedir)) == $this->basedir)
		{
			$pathinfo['dirname'] = realpath($pathinfo['dirname']);
		}
		else
		{
			// attempt to get the realpath(), otherwise just use path with any double dots taken out when basedir is set (for security)
			$pathinfo['dirname'] = ( ! empty($this->basedir) ? realpath($this->basedir.DS.$pathinfo['dirname']) : realpath($pathinfo['dirname']) )
					?: ( ! empty($this->basedir) ? $this->basedir.DS.str_replace('..', '', $pathinfo['dirname']) : $pathinfo['dirname']);
		}

		// basedir prefix is required when it is set (may cause unexpected errors when realpath doesn't work)
		if ( ! empty($this->basedir) && substr($pathinfo['dirname'], 0, strlen($this->basedir)) != $this->basedir)
		{
			throw new \OutsideAreaException('File operation not allowed: given path is outside the basedir for this area.');
		}

		// check file extension
		if ( ! empty(static::$extensions) && array_key_exists($pathinfo['extension'], static::$extensions))
		{
			throw new \FileAccessException('File operation not allowed: disallowed file extension.');
		}

		return $pathinfo['dirname'].DS.$pathinfo['basename'];
	}
252912
public static function realpath($path)
    {
        $path = str_replace(DIRECTORY_SEPARATOR, '/', $path);

        if (false === $parse_url = parse_url($path)) {
            return false;
        }

        if (!array_key_exists('host', $parse_url)) {
            return realpath($path);
        }

        if (!array_key_exists('scheme', $parse_url)) {
            return false;
        }

        $parts = [];
        $pathArray = explode('/', str_replace(DIRECTORY_SEPARATOR, '/', $parse_url['path']));

        foreach ($pathArray as $part) {
            if ('.' === $part) {
                continue;
            } elseif ('..' === $part) {
                array_pop($parts);
            } else {
                $parts[] = $part;
            }
        }

        $path = (isset($parse_url['scheme']) ? $parse_url['scheme'].'://' : '').
                (isset($parse_url['user']) ? $parse_url['user'] : '').
                (isset($parse_url['pass']) ? ':'.$parse_url['pass'] : '').
                (isset($parse_url['user']) || isset($parse_url['pass']) ? '@' : '').
                (isset($parse_url['host']) ? $parse_url['host'] : '').
                (isset($parse_url['port']) ? ':'.$parse_url['port'] : '').
                implode('/', $parts);

        if (!file_exists($path)) {
            return false;
        }

        return $path;
    }
819071
protected function getFilePath(string $path): string
    {
        if (empty($path)) {
            $path = $this->fileName;
        }

        return $path;
    }
981229
protected function getAbsolutePath($relativePath)
    {
        return rtrim($this->path, DIRECTORY_SEPARATOR)
             . DIRECTORY_SEPARATOR
             . ltrim($relativePath, DIRECTORY_SEPARATOR);
    }
879734
public function findByPath(string $path)
    {
        return $this->first(function(ExtensionContract $extension) use($path) {
                    return $extension->getPath() === $path;
                });
    }