class Folder (View source)

A Folder handling class

Constants

PATH_ABSOLUTE

PATH_RELATIVE

PATH_BASENAME

Methods

static boolean
copy(string $src, string $dest, boolean $force = false)

Copy a folder.

static boolean
create(string $path = '', integer $mode = 493)

Create a folder -- and all necessary parent folders.

static boolean
delete(string $path)

Delete a folder.

static mixed
move(string $src, string $dest, bool $override = false)

Moves a folder.

static array
files(string $path, boolean $recursive = false, integer $pathType = self::PATH_ABSOLUTE)

files

static array
items(string $path, boolean $recursive = false, integer $pathType = self::PATH_ABSOLUTE)

items

static array
folders(string $path, boolean $recursive = false, integer $pathType = self::PATH_ABSOLUTE)

folders

static array
listFolderTree(string $path, integer $maxLevel = 3, integer $level, integer $parent)

Lists folder in format suitable for tree display.

static string
makeSafe(string $path)

Makes path name safe to use.

Details

at line line 38
static boolean copy(string $src, string $dest, boolean $force = false)

Copy a folder.

Parameters

string $src The path to the source folder.
string $dest The path to the destination folder.
boolean $force Force copy.

Return Value

boolean True on success.

Exceptions

FilesystemException

at line line 94
static boolean create(string $path = '', integer $mode = 493)

Create a folder -- and all necessary parent folders.

Parameters

string $path A path to create from the base path.
integer $mode Directory permissions to set for folders created. 0755 by default.

Return Value

boolean True if successful.

Exceptions

FilesystemException

at line line 178
static boolean delete(string $path)

Delete a folder.

Parameters

string $path The path to the folder to delete.

Return Value

boolean True on success.

Exceptions

FilesystemException
UnexpectedValueException

at line line 246
static mixed move(string $src, string $dest, bool $override = false)

Moves a folder.

Parameters

string $src The path to the source folder.
string $dest The path to the destination folder.
bool $override Override files.

Return Value

mixed Error message on false or boolean true on success.

Exceptions

FilesystemException

at line line 294
static array files(string $path, boolean $recursive = false, integer $pathType = self::PATH_ABSOLUTE)

files

Parameters

string $path
boolean $recursive
integer $pathType

Return Value

array

at line line 334
static array items(string $path, boolean $recursive = false, integer $pathType = self::PATH_ABSOLUTE)

items

Parameters

string $path
boolean $recursive
integer $pathType

Return Value

array

at line line 375
static array folders(string $path, boolean $recursive = false, integer $pathType = self::PATH_ABSOLUTE)

folders

Parameters

string $path
boolean $recursive
integer $pathType

Return Value

array

at line line 418
static array listFolderTree(string $path, integer $maxLevel = 3, integer $level, integer $parent)

Lists folder in format suitable for tree display.

Parameters

string $path The path of the folder to read.
integer $maxLevel The maximum number of levels to recursively read, defaults to three.
integer $level The current level, optional.
integer $parent Unique identifier of the parent folder, if any.

Return Value

array Folders in the given folder.

at line line 469
static string makeSafe(string $path)

Makes path name safe to use.

Parameters

string $path The full path to sanitise.

Return Value

string The sanitised string.