class Filesystem (View source)

A collection of static methods for manipulating the filesystem.

Traits

Provides extensions to this object to integrate it with standard config API methods.

Config options

file_create_mask int
folder_create_mask int

Properties

protected static int $cache_folderModTime

Methods

public static 
config()

Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).

public
mixed
uninherited(string $name)

Gets the uninherited value for the given config option

public static 
makeFolder(string $folder)

Create a folder on the filesystem, recursively.

public static 
removeFolder(string $folder, bool $contentsOnly = false)

Remove a directory and all subdirectories and files.

public static 
bool
remove_folder_if_empty(string $folder, bool $recursive = true)

Remove a directory, but only if it is empty.

public static 
string
folderModTime(string $folder, array $extensionList = null)

Return the most recent modification time of anything in the folder.

public static 
bool
isAbsolute(string $filename)

Returns true if the given filename is an absolute file reference.

Details

static Config_ForClass config()

Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).

Return Value

Config_ForClass

mixed uninherited(string $name)

Gets the uninherited value for the given config option

Parameters

string $name

Return Value

mixed

static makeFolder(string $folder)

Create a folder on the filesystem, recursively.

Uses Filesystem::$folder_create_mask to set filesystem permissions. Use Folder::findOrMake()} to create a {@link Folder database record automatically.

Parameters

string $folder

Absolute folder path

static removeFolder(string $folder, bool $contentsOnly = false)

Remove a directory and all subdirectories and files.

Parameters

string $folder

Absolute folder path

bool $contentsOnly

If this is true then the contents of the folder will be removed but not the folder itself

static bool remove_folder_if_empty(string $folder, bool $recursive = true)

Remove a directory, but only if it is empty.

Parameters

string $folder

Absolute folder path

bool $recursive

Remove contained empty folders before attempting to remove this one

Return Value

bool

True on success, false on failure.

static string folderModTime(string $folder, array $extensionList = null)

Return the most recent modification time of anything in the folder.

Parameters

string $folder

The folder, relative to the site root

array $extensionList

An option array of file extensions to limit the search to

Return Value

string

Same as filemtime() format.

static bool isAbsolute(string $filename)

Returns true if the given filename is an absolute file reference.

Works on Linux and Windows.

Parameters

string $filename

Absolute or relative filename, with or without path.

Return Value

bool