PathResolver

A utility to resolve paths to their canonical location and handle path queries.

 class Winter\Storm\Filesystem\PathResolver

Methods

public static join (string $prefix, string $path = "") : string

Join two paths, making sure they use the correct directory separators.

Parameters
Property Description
$prefix
string
$path
string
Returns
string

public static resolve (string $path) : string | bool

Resolves a path to its canonical location.

This expands all symbolic links and resolves references to /./, /../ and extra / characters in the input path and returns the canonicalized absolute pathname.

This function operates very similar to the PHP realpath function, except it will also work for missing files and directories.

Returns canonical path if it can be resolved, otherwise false.

Parameters
Property Description
$path
string
Returns
string | bool

public static standardize (string $path) : string

Standardizes the path separators of a path back to the expected separator for the operating system.

Parameters
Property Description
$path
string
Returns
string

public static within (string $path, string $directory) : bool

Determines if the path is within the given directory.

Parameters
Property Description
$path
string
$directory
string
Returns
bool

protected static normalize (string $path, boolean $applyCwd = true) : string

Normalizes a given path.

Converts any type of path (Unix or Windows) into a Unix-style path, so that we have a consistent format to work with internally. All paths will be returned with no trailing path separator.

If $applyCwd is true, the current working directory will be prepended if the path is relative.

Parameters
Property Description
$path
string
$applyCwd
boolean
Returns
string

protected static resolveSymlink ($symlink) : string | bool

Resolves a symlink target.

Returns the resolved symlink path, or false if it cannot be resolved.

Parameters
Property Description
$symlink
mixed
Returns
string | bool

protected static withinOpenBaseDir (string $path) : bool

Checks if a given path is within "open_basedir" restrictions.

Parameters
Property Description
$path
string
Returns
bool
Copyright © 2024 Winter CMS