Path

A Path handling class

since

1.0

package

Joomla Framework

Methods

canChmod

Checks if a path's permissions can be changed.

canChmod(string path) : bool
static
since

1.0

Arguments

path

stringPath to check.

Response

boolTrue if path can have mode changed.

check

Checks for snooping outside of the file system root.

check(string path, string basePath = '') : string
static
since

1.0

throws

\Joomla\Filesystem\Exception\FilesystemException

Arguments

path

stringA file system path to check.

basePath

stringThe base path of the system

Response

stringA cleaned version of the path or exit on error.

clean

Function to strip additional / or \ in a path name.

clean(string path, string ds = DIRECTORY_SEPARATOR) : string
static
since

1.0

throws

\UnexpectedValueExceptionIf $path is not a string.

Arguments

path

stringThe path to clean.

ds

stringDirectory separator (optional).

Response

stringThe cleaned path.

find

Searches the directory paths for a given file.

find(mixed paths, string file) : string|bool
static
since

1.0

Arguments

paths

mixedA path string or array of path strings to search in

file

stringThe file name to look for.

Response

string|boolThe full path and file name for the target file, or boolean false if the file is not found in any of the paths.

getPermissions

Get the permissions of the file/folder at a give path.

getPermissions(string path) : string
static
since

1.0

Arguments

path

stringThe path of a file/folder.

Response

stringFilesystem permissions.

isOwner

Method to determine if script owns the path.

isOwner(string path) : bool
static
since

1.0

Arguments

path

stringPath to check ownership.

Response

boolTrue if the php script owns the path passed.

removeRoot

Remove all references to root directory path and the system tmp path from a message

removeRoot(string message, string rootDirectory = null) : string
static
since

2.0.1

Arguments

message

stringThe message to be cleaned

rootDirectory

stringOptional root directory, defaults to JPATH_ROOT

Response

string

resolve

Resolves /./, /../ and multiple / in a string and returns the resulting absolute path, inspired by Flysystem Removes trailing slashes

resolve(string path) : string
static
since

1.6.0

Arguments

path

stringA path to resolve

Response

stringThe resolved path

setPermissions

Chmods files and directories recursively to given permissions.

setPermissions(string path, string filemode = '0644', string foldermode = '0755') : bool
static
since

1.0

Arguments

path

stringRoot path to begin changing mode [without trailing slash].

filemode

stringOctal representation of the value to change file mode to [null = no change].

foldermode

stringOctal representation of the value to change folder mode to [null = no change].

Response

boolTrue if successful [one fail means the whole operation failed].