\APIFolderHandler

Folder structure browser, lists folders and files.

Long description for class

Summary

Methods
Properties
Constants
__construct()
pwd()
cd()
read()
find()
findRecursive()
_findRecursive()
isWindowsPath()
isAbsolute()
normalizePath()
correctSlashFor()
slashTerm()
addPathElement()
inAPIPath()
inPath()
chmod()
tree()
create()
dirsize()
delete()
copy()
move()
messages()
errors()
realpath()
isSlashTerm()
$path
$sort
$mode
$messages
$errors
$directories
$files
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$path

$path : 

Path to Folder.

Type

$sort

$sort : 

Sortedness.

Type

$mode

$mode : 

mode to be used on create.

Type

$messages

$messages : mixed||string|int

holds messages from last method.

Type

mixed||string|int —

$errors

$errors : mixed||string|int

holds errors from last method.

Type

mixed||string|int —

$directories

$directories : mixed||string|int

holds array of complete directory paths.

Type

mixed||string|int —

$files

$files : mixed||string|int

holds array of complete file paths.

Type

mixed||string|int —

Methods

__construct()

__construct(bool|string  path = false,   create = true,   mode = false) : 

Constructor.

Parameters

bool|string path

Path to folder

create

Create folder if not found

mode

Mode (CHMOD) to apply to created folder, false to ignore

Returns

pwd()

pwd() : 

Return current path.

Returns

Current path

cd()

cd(  path) : 

Change directory to $desired_path.

Parameters

path

Path to the directory to change to

Returns

The new path. Returns false on failure

read()

read(  sort = true,   exceptions = false) : 

Returns an array of the contents of the current directory, or false on failure.

The returned array holds two arrays: one of dirs and one of files.

Parameters

sort
exceptions

either an array or boolean true will no grab dot files

Returns

Contents of current directory as an array, false on failure

find()

find(  regexp_pattern = .*,   sort = false) : mixed||string|int

Returns an array of all matching files in current directory.

Parameters

regexp_pattern

Preg_match pattern (Defaults to: .*)

sort

Returns

mixed||string|int —

Files that match given pattern

findRecursive()

findRecursive(  pattern = .*,   sort = false) : mixed||string|int

Returns an array of all matching files in and below current directory.

Parameters

pattern

Preg_match pattern (Defaults to: .*)

sort

Returns

mixed||string|int —

Files matching $pattern

_findRecursive()

_findRecursive(  pattern,   sort = false) : mixed||string|int

Private helper function for findRecursive.

Parameters

pattern

Pattern to match against

sort

Returns

mixed||string|int —

Files matching pattern

isWindowsPath()

isWindowsPath(  path) : 

Returns true if given $path is a Windows path.

Parameters

path

Path to check

Returns

true if windows path, false otherwise

isAbsolute()

isAbsolute(  path) : 

Returns true if given $path is an absolute path.

Parameters

path

Path to check

Returns

normalizePath()

normalizePath(  path) : 

Returns a correct set of slashes for given $path. (\\ for Windows paths and / for other paths.)

Parameters

path

Path to check

Returns

Set of slashes ("\" or "/")

correctSlashFor()

correctSlashFor(  path) : 

Returns a correct set of slashes for given $path. (\\ for Windows paths and / for other paths.)

Parameters

path

Path to check

Returns

Set of slashes ("\" or "/")

slashTerm()

slashTerm(  path) : 

Returns $path with added terminating slash (corrected for Windows or other OS).

Parameters

path

Path to check

Returns

Path with ending slash

addPathElement()

addPathElement(  path,   element) : 

Returns $path with $element added, with correct slash in-between.

Parameters

path

Path

element

Element to and at end of path

Returns

Combined path

inAPIPath()

inAPIPath(  path) : 

Returns true if the File is in a given APIPath.

Parameters

path

Returns

inPath()

inPath(  path,   reverse = false) : 

Returns true if the File is in given path.

Parameters

path
reverse

Returns

chmod()

chmod(  path, bool|int  mode = false,   recursive = true, mixed||string|int  exceptions = array()) : 

Change the mode on a directory structure recursively.

Parameters

path

The path to chmod

bool|int mode

octal value 0755

recursive

chmod recursively

mixed||string|int exceptions

array of files, directories to skip

Returns

Returns TRUE on success, FALSE on failure

tree()

tree(  path,   hidden = true,   type = null) : 

Returns an array of nested directories and files in each directory

Parameters

path

the directory path to build the tree from

hidden

return hidden files and directories

type

either file or dir. null returns both files and directories

Returns

array of nested directories and files in each directory

create()

create(  pathname, bool|int  mode = false) : 

Create a directory structure recursively.

Parameters

pathname

The directory structure to create

bool|int mode

octal value 0755

Returns

Returns TRUE on success, FALSE on failure

dirsize()

dirsize() : 

Returns the size in bytes of this Folder.

Returns

$size

delete()

delete(  path) : 

Recursively Remove directories if system allow.

Parameters

path

Path of directory to delete

Returns

Success

copy()

copy(array|string  options = array()) : 

Recursive directory copy.

Parameters

array|string options

(to, from, chmod, skip)

Returns

move()

move(array|string  options) : 

Recursive directory move.

Parameters

array|string options

(to, from, chmod, skip)

Returns

Success

messages()

messages() : mixed||string|int

get messages from latest method

Returns

mixed||string|int —

errors()

errors() : mixed||string|int

get error from latest method

Returns

mixed||string|int —

realpath()

realpath(  path) : 

Get the real path (taking ".." and such into account)

Parameters

path

Path to resolve

Returns

The resolved path

isSlashTerm()

isSlashTerm(  path) : 

Returns true if given $path ends in a slash (i.e. is slash-terminated).

Parameters

path

Path to check

Returns

true if path ends with slash, false otherwise