Asserts that the given path is a link path.

@param string $path The path to check that must be a link.
@param Throwable $exception The exception to throw if the assertion fails.
@return string The link path if the assertion does not fail.
432208
public static function assertIsLink(string $path, Throwable $exception): string
    {
        static::makeAssertion(\is_link($path), $exception);
        return $path;
    }
766166
public function mkdir( $path )
	{
		try {
			$this->fs->makeDirectory( $path );
		} catch( \Exception $e ) {
			throw new Exception( $e->getMessage(), 0, $e );
		}
	}
683332
public function mapPathEntityId($path)
    {

        // query whether or not a entity ID for the passed path has been mapped
        if (isset($this->pathEntityIdMapping[$path])) {
            return $this->pathEntityIdMapping[$path];
        }

        // throw an exception if not
        throw new \Exception(sprintf('Can\'t map path %s to any entity ID', $path));
    }
1073233
private function resolveRemotePath($path)
    {
        if (!isset($this->resolvedRemotePath[$path])) {
            $resolvedPath = $this->volatileFolder->getNewPath();
            if ($this->remoteFilesystem->copy($path, $path, $resolvedPath) !== true) {
                throw new Exception\PathNotFound($path);
            }
            $this->resolvedRemotePath[$path] = $resolvedPath;
        }

        return $this->resolvedRemotePath[$path];
    }
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;
	}
295898
public final function withPath($path): UriInterface
   {
       try {
           $uri = parent::withPath($path);
       } catch (InvalidArgumentException $e) {
           throw $e;
       }
       if ($uri->redirect) {
           $uri->redirect = "";
       }
       return $uri;
   }
217671
public function url( $path )
	{
		$adapter = $this->driver->getAdapter();

		if ( $adapter instanceof AwsS3Adapter )
		{
			$path = $adapter->getPathPrefix() . $path;

			return $adapter->getClient()->getObjectUrl( $adapter->getBucket(), $path );
		}
		elseif ( $adapter instanceof LocalAdapter )
		{
			return '/storage/' . $path;
		}
		elseif ( method_exists( $adapter, 'getUrl' ) )
		{
			return $adapter->getUrl( $path );
		}
		else
		{
			throw new RuntimeException( 'This driver does not support retrieving URLs.' );
		}
	}
729560
protected static function tryDelete($path)
    {
        $success = true;

        try
        {
            if ( ! @unlink($path))
            {
                $success = false;
            }
        } catch (ErrorException $e)
        {
            $success = false;
        }

        return $success;
    }
515905
public function tryPath($path, $flags = 0x000000) {
    $flags |= self::VALIDATE;
    try {
      return $this->getPath($path, $flags);
    } catch (Exception $e) {
      if ($e->getCode() === self::VALIDATE) {
        return FALSE;
// @codeCoverageIgnoreStart
      } else {
        throw $e;
      }
// @codeCoverageIgnoreEnd
    }
  }
56265
public function isException($path)
    {
        $isException = false;
        foreach ($this->exceptions as $exception) {
            if ($isException === false) {
                if ($path === $exception || preg_match('/^'.$exception.'$/', $path) !== 0) {
                    $isException = true;
                }
            }
        }

        return $isException;
    }
218558
protected function detect(string $path): ?Detection
    {
        $process = $this->createProcess($path);
        $returnCode = $process->run();
        $output = trim($process->getOutput());
        if (0 !== $returnCode && false === strpos($output, ' FOUND')) {
            throw AdapterException::fromProcess($process);
        }

        foreach (explode("\n", $output) as $line) {
            if (substr($line, -6) === ' FOUND') {
                $file = substr($line, 0, strrpos($line, ':'));
                $description = substr(substr($line, strrpos($line, ':') + 2), 0, -6);

                return $this->createDetection($file, Detection::TYPE_VIRUS, $description);
            }
        }

        return null;
    }
132201
public function readf( $path )
	{
		if( ( $filename = tempnam( $this->tempdir, 'ai-' ) ) === false ) {
			throw new Exception( sprintf( 'Unable to create file in "%1$s"', $this->tempdir ) );
		}

		if( @file_put_contents( $filename, $this->fs->get( $path ) ) === false ) {
			throw new Exception( sprintf( 'Couldn\'t write file "%1$s"', $filename ) );
		}

		return $filename;
	}
43778
public function url($path)
    {
        $adapter = $this->driver->getAdapter();

        if (method_exists($adapter, 'getUrl')) {
            return $adapter->getUrl($path);
        } elseif ($adapter instanceof AwsS3Adapter) {
            return $this->getAwsUrl($adapter, $path);
        } elseif ($adapter instanceof RackspaceAdapter) {
            return $this->getRackspaceUrl($adapter, $path);
        } elseif ($adapter instanceof LocalAdapter) {
            return $this->getLocalUrl($path);
        } else {
            throw new RuntimeException('This driver does not support retrieving URLs.');
        }
    }
289107
public function getRealpath($path)
    {
        $adapter = $this->getAdapter();
        if (!$adapter instanceof FindableAdapterInterface) {
            throw new NotSupportedException(
                "Adapter doesn't support getRealpath action. Adapter in use is: "
                . get_class($adapter)
            );
        }

        return $adapter->getRealpath($path);
    }
79775
public static function assertIsDir(string $path, Throwable $exception): string
    {
        static::makeAssertion(\is_dir($path), $exception);
        return $path;
    }
697060
public static function symlink($path, $link_path, $is_file = true, $area = null)
	{
		$path      = rtrim(static::instance($area)->get_path($path), '\\/');
		$link_path = rtrim(static::instance($area)->get_path($link_path), '\\/');

		if ($is_file and ! is_file($path))
		{
			throw new \InvalidPathException('Cannot symlink: given file: "'.$path.'" does not exist.');
		}
		elseif ( ! $is_file and ! is_dir($path))
		{
			throw new \InvalidPathException('Cannot symlink: given directory: "'.$path.'" does not exist.');
		}
		elseif (file_exists($link_path))
		{
			throw new \FileAccessException('Cannot symlink: link: "'.$link_path.'" already exists.');
		}

		return symlink($path, $link_path);
	}
1044418
public function route($path)
    {
        $route = $this->configureSlice()->atData($path);

        if (empty($route))
        {
            throw new Exceptions\NotFound('Route `' . $path . '` not found');
        }

        return $route;
    }