Asserts that the given path is readable.

@param string $path The path to check that must be readable.
@param Throwable $exception The exception to throw if the assertion fails.
@return string The path if the assertion does not fail.
193019
public static function assertIsReadable(string $path, Throwable $exception): string
    {
        static::makeAssertion(\is_readable($path), $exception);
        return $path;
    }
131362
public function setPath($path)
        {
            if ($this->validatePath($path) === false) {
                throw new Exception("Path \"$path\" is not a valid HTTP path");
            }

            $oldPath     = $this->_path;
            $this->_path = $path;

            return $oldPath;
        }
925251
public function setPath($path)
    {
        $this->path = $path;
        $fileFullPath = "{$this->rootPath}/{$this->path}";
        // readable ?
        if (file_exists($fileFullPath)) {
            $this->file = $fileFullPath;
            return $this;
        }
        // absolute path ?
        if (file_exists($path) && strpos($path, $this->rootPath) === 0) {
            $this->file = $path;
            $this->rootPath = '/';
        } else {
            error_log("[BEAR.Ace] 404: {$fileFullPath}");
            throw new Exception('Not found ' . $fileFullPath, 404);
        }

        return $this;
    }
823227
public function render(\Throwable $exception): string
    {
        \ob_start();
        if (Helpers::isAjax() && \session_status() === PHP_SESSION_ACTIVE) {
            $this->renderTemplate($exception, __DIR__ . '/assets/BlueScreen/content.phtml');
            $contentId = $_SERVER['HTTP_X_TRACY_AJAX'];
            $_SESSION['_tracy']['bluescreen'][$contentId] = [
                'content' => \ob_get_clean(),
                'dumps' => Dumper::fetchLiveData(),
                'time' => \time(),
            ];

            return '';
        }

        $this->renderTemplate($exception, __DIR__ . '/assets/BlueScreen/page.phtml');

        return \ob_get_clean();
    }
437689
public static function assertTrue($condition, Throwable $exception): bool
    {
        static::makeAssertion(true === $condition, $exception);
        return true;
    }
1210759
public static function assertNotTrue($condition, Throwable $exception): bool
    {
        static::makeAssertion(true !== $condition, $exception);
        return false;
    }
28590
private function createWritablePathIfNotExists($path)
    {
        if (!is_dir($path)) {
            // check if parentdir exists, and create this first.
            $parentdir = dirname($path);
            if (!is_dir($parentdir)) {
                $this->createWritablePathIfNotExists($parentdir);
            }

            if (!is_writable($parentdir)) {
                throw new \InvalidArgumentException(sprintf(
                    'The parent directory "%s" is not writable.',
                    $parentdir
                ));
            }
            if (!mkdir($path, $this->dirMode)) {
                return false;
            }
        }

        if (!is_writable($path)) {
            throw new \InvalidArgumentException(sprintf(
                'The path "%s" is not writable.',
                $path
            ));
        }

        return true;
    }
965077
static function GetMimeType($path)
    {
        if (!self::IsReadable($path))
            throw new Exceptions\PathNoAccessException("File $path cannot be read");
        
        $finfo = \finfo_open(FILEINFO_MIME_TYPE);
        $mime = @\finfo_file($finfo, $path);
        if (!$mime)
            throw new \Exception("File info of $path not readable");
        
        return $mime;
    }
518030
public static function check($path)
	{
		if (strpos($path, '..') !== false)
		{
			throw new \Exception('JPath::check Use of relative paths not permitted', 20);
		}

		$path = self::clean($path);

		if ((JPATH_ROOT != '') && strpos($path, self::clean(JPATH_ROOT)) !== 0)
		{
			throw new \Exception('JPath::check Snooping out of bounds @ ' . $path, 20);
		}

		return $path;
	}
1348218
protected static function validatePath($path)
    {
        if (realpath($path) === false) {
            throw new Exception(
                'Path "' . $path . '" does not exist.'
            );
        }

        if (is_dir($path) === false || is_writable($path) === false) {
            throw new Exception(
                'Make sure path "' . $path . '" exists and that it\'s writable.'
            );
        }

        // Make full usable with trailing slash
        $path = realpath($path) . DIRECTORY_SEPARATOR;

        return $path;
    }
1192199
protected function isWritable($path) {
        if (!is_dir($path)) {
            // Path does not exist, check parent
            return $this->isWritable(dirname($path));
        }

        // Dir exists, check if it's writable
        return is_writable($path);
    }
1028655
protected function parsePath($path)
    {
        $path = parse_url(substr(strstr(";" . $path, ";" . $this->basepath), strlen(";" . $this->basepath)), PHP_URL_PATH);

        if ($path === false) {
            throw new Exception("Seriously malformed URL passed to route matcher.");
        }

        return $path;
    }
1369037
public function reads( $path )
	{
		try {
			$content = $this->fs->get( $path );
		} catch( \Exception $e ) {
			throw new Exception( $e->getMessage(), 0, $e );
		}

		if( ( $stream = tmpfile() ) === false ) {
			throw new Exception( 'Couldn\'t create temporary file' );
		}

		if( fwrite( $stream, $content ) === false ) {
			throw new Exception( 'Couldn\'t write to temporary file' );
		}

		if( rewind( $stream ) === false ) {
			throw new Exception( 'Couldn\'t rewind temporary file' );
		}

		return $stream;
	}
1365572
public function read($path)
    {
        $path = $this->getPath($path);
        if (!is_readable($path) || !is_file($path)) {
            throw new RuntimeException($path . ' is not readable file');
        }

        return file_get_contents($path);
    }
1369899
public function validateFile($file)
    {
        if (file_exists($file) !== true) {
            throw new Exception('File not found');
        }
        if (is_readable($file) !== true) {
            throw new Exception('File not readable');
        }

        $data = file_get_contents($file);
        if ($data === false) {
            throw new Exception('Failed get file');
        }

        return $this->validateFragment($data);
    }
1226568
protected function getExceptionAsRenderedView(Throwable $exception): string
	{
		$view = 'error';

		if($exception instanceof HttpException)
		{
			$code = $exception->getCode();

			if($this->view->exists('mako-error::' . $code))
			{
				$view = $code;
			}
		}

		return $this->view->render('mako-error::' . $view);
	}
643658
protected function checkPath($path)
    {
        // provide compatibility with objects such as \SplFileInfo
        if (is_object($path) && method_exists($path, '__toString')) {
            $path = (string) $path;
        }

        $handle = @fopen($path, 'r');

        if (false === $handle) {
            throw new InvalidArgumentException(sprintf('File %s does not exist.', $path));
        }

        fclose($handle);

        return $path.'[0]';
    }