class Filesystem extends Filesystem

File helper

Adapted from october\rain\filesystem\Filesystem

Properties

string $filePermissions
string $folderPermissions
array $pathSymbols
$symlinks

Methods

bool
isDirectoryEmpty(string $directory)

Determine if the given path contains no files.

string
sizeToString(int $bytes)

Converts a file size in bytes to human readable format.

string
localToPublic(string $path)

Returns a public file path from an absolute one eg: /home/mysite/public_html/welcome -> /welcome

bool
isLocalPath(string $path, bool $realpath = true)

Returns true if the specified path is within the path of the application

bool
isLocalDisk(FilesystemAdapter $disk)

Returns true if the provided disk is using the "local" driver

string
fromClass(mixed $className)

Finds the path to a class

mixed
existsInsensitive(string $path)

Determine if a file exists with case insensitivity supported for the file only.

string
normalizePath(string $path)

Normalizes the directory separator, often used by Win systems.

string
symbolizePath(string $path, mixed $default = false)

Converts a path using path symbol. Returns the original path if no symbol is used and no default is specified.

bool
isPathSymbol(string $path)

Returns true if the path uses a symbol.

addPathSymbol($symbol, $path)

No description

int
put(string $path, string $contents, $lock = false)

Write the contents of a file.

bool
copy(string $path, string $target)

Copy a file to a new location.

bool
makeDirectory(string $path, int $mode = 0777, bool $recursive = false, bool $force = false)

Create a directory.

mixed
chmod(string $path, octal $mask = null)

Modify file/folder permissions

mixed
chmodRecursive(string $path, octal $fileMask = null, octal $directoryMask = null)

Modify file/folder permissions recursively

string
getFilePermissions()

Returns the default file permission mask to use.

string
getFolderPermissions()

Returns the default folder permission mask to use.

bool
fileNameMatch(string|array $fileName, string $pattern)

Match filename against a pattern.

void
findSymlinks()

Finds symlinks within the base path and provides a source => target array of symlinks.

Details

at line 44
bool isDirectoryEmpty(string $directory)

Determine if the given path contains no files.

Parameters

string $directory

Return Value

bool

at line 69
string sizeToString(int $bytes)

Converts a file size in bytes to human readable format.

Parameters

int $bytes

Return Value

string

at line 100
string localToPublic(string $path)

Returns a public file path from an absolute one eg: /home/mysite/public_html/welcome -> /welcome

Parameters

string $path

Absolute path

Return Value

string

at line 138
bool isLocalPath(string $path, bool $realpath = true)

Returns true if the specified path is within the path of the application

Parameters

string $path

The path to

bool $realpath

Default true, uses realpath() to resolve the provided path before checking location. Set to false if you need to check if a potentially non-existent path would be within the application path

Return Value

bool

at line 155
bool isLocalDisk(FilesystemAdapter $disk)

Returns true if the provided disk is using the "local" driver

Parameters

FilesystemAdapter $disk

Return Value

bool

at line 165
string fromClass(mixed $className)

Finds the path to a class

Parameters

mixed $className

Class name or object

Return Value

string

The file path

at line 178
mixed existsInsensitive(string $path)

Determine if a file exists with case insensitivity supported for the file only.

Parameters

string $path

Return Value

mixed

Sensitive path or false

at line 205
string normalizePath(string $path)

Normalizes the directory separator, often used by Win systems.

Parameters

string $path

Path name

Return Value

string

Normalized path

at line 217
string symbolizePath(string $path, mixed $default = false)

Converts a path using path symbol. Returns the original path if no symbol is used and no default is specified.

Parameters

string $path
mixed $default

Return Value

string

at line 242
bool isPathSymbol(string $path)

Returns true if the path uses a symbol.

Parameters

string $path

Return Value

bool

at line 252
addPathSymbol($symbol, $path)

No description

Parameters

$symbol
$path

at line 266
int put(string $path, string $contents, $lock = false)

Write the contents of a file.

Parameters

string $path
string $contents
$lock

Return Value

int

at line 280
bool copy(string $path, string $target)

Copy a file to a new location.

Parameters

string $path
string $target

Return Value

bool

at line 296
bool makeDirectory(string $path, int $mode = 0777, bool $recursive = false, bool $force = false)

Create a directory.

Parameters

string $path
int $mode
bool $recursive
bool $force

Return Value

bool

at line 347
mixed chmod(string $path, octal $mask = null)

Modify file/folder permissions

Parameters

string $path
octal $mask

Return Value

mixed

at line 369
mixed chmodRecursive(string $path, octal $fileMask = null, octal $directoryMask = null)

Modify file/folder permissions recursively

Parameters

string $path
octal $fileMask
octal $directoryMask

Return Value

mixed

at line 404
string getFilePermissions()

Returns the default file permission mask to use.

Return Value

string

Permission mask as octal (0777) or null

at line 415
string getFolderPermissions()

Returns the default folder permission mask to use.

Return Value

string

Permission mask as octal (0777) or null

at line 428
bool fileNameMatch(string|array $fileName, string $pattern)

Match filename against a pattern.

Parameters

string|array $fileName
string $pattern

Return Value

bool

Finds symlinks within the base path and provides a source => target array of symlinks.

Return Value

void