Airship\Hangar\SessionCommand::getRealPath PHP Method

getRealPath() protected method

If a file path is relative to the root, return it. Otherwise, thorw an error!
protected getRealPath ( string $file ) : string
$file string
return string
    protected function getRealPath(string $file) : string
    {
        if (!\file_exists($file)) {
            throw new \Error('File not found: ' . $file);
        }
        if (\strpos($file, $this->session['dir']) === 0) {
            $x = Binary::safeStrlen($this->session['dir']);
            return Binary::safeSubstr($file, $x + 1);
        } elseif ($file[0] !== DIRECTORY_SEPARATOR) {
            return $file;
        } else {
            throw new \Error('File path is outside the root directory: ' . $file);
        }
    }