MERGE
MERGE = 'merge' : string
Default scheme for Folder::copy Recursively merges subfolders with the same name
Folder structure browser, lists folders and files.
Provides an Object interface for Common directory related tasks.
read(string|boolean $sort = self::SORT_NAME, array|boolean $exceptions = false, boolean $fullPath = false) : array
Returns an array of the contents of the current directory.
The returned array holds two arrays: One of directories and one of files.
string|boolean | $sort | Whether you want the results sorted, set this and the sort property to false to get unsorted results. |
array|boolean | $exceptions | Either an array or boolean true will not grab dot files |
boolean | $fullPath | True returns the full path |
Contents of current directory as an array, an empty array on failure
findRecursive(string $pattern = '.*', boolean $sort = false) : array
Returns an array of all matching files in and below current directory.
string | $pattern | Preg_match pattern (Defaults to: .*) |
boolean | $sort | Whether results should be sorted. |
Files matching $pattern
normalizeFullPath(string $path) : string
Returns a correct set of slashes for given $path. (\\ for Windows paths and / for other paths.)
string | $path | Path to transform |
Path with the correct set of slashes ("\" or "/")
None found |
correctSlashFor(string $path) : string
Returns a correct set of slashes for given $path. (\\ for Windows paths and / for other paths.)
string | $path | Path to check |
Set of slashes ("\" or "/")
None found |
slashTerm(string $path) : string
Returns $path with added terminating slash (corrected for Windows or other OS).
string | $path | Path to check |
Path with ending slash
None found |
addPathElement(string $path, string|array $element) : string
Returns $path with $element added, with correct slash in-between.
string | $path | Path |
string|array | $element | Element to add at end of path |
Combined path
None found |
inCakePath(string $path = '') : boolean
Returns true if the Folder is in the given Cake path.
string | $path | The path to check. |
None found |
inPath(string $path, boolean $reverse = false) : boolean
Returns true if the Folder is in the given path.
string | $path | The absolute path to check that the current |
boolean | $reverse | Reverse the search, check if the given |
When the given $path
argument is not an absolute path.
None found |
chmod(string $path, integer|boolean $mode = false, boolean $recursive = true, array $exceptions = array()) : boolean
Change the mode on a directory structure recursively. This includes changing the mode on files as well.
string | $path | The path to chmod. |
integer|boolean | $mode | Octal value, e.g. 0755. |
boolean | $recursive | Chmod recursively, set to false to only change the current directory. |
array | $exceptions | Array of files, directories to skip. |
Success.
None found |
subdirectories(string|null $path = null, boolean $fullPath = true) : array
Returns an array of subdirectories for the provided or current path.
string|null | $path | The directory path to get subdirectories for. |
boolean | $fullPath | Whether to return the full path or only the directory name. |
Array of subdirectories for the provided or current path.
None found |
tree(string|null $path = null, array|boolean $exceptions = false, string|null $type = null) : array
Returns an array of nested directories and files in each directory
string|null | $path | the directory path to build the tree from |
array|boolean | $exceptions | Either an array of files/folder to exclude or boolean true to not grab dot files/folders |
string|null | $type | either 'file' or 'dir'. Null returns both files and directories |
Array of nested directories and files in each directory
None found |
create(string $pathname, integer|boolean $mode = false) : boolean
Create a directory structure recursively.
Can be used to create deep path structures like /foo/bar/baz/shoe/horn
string | $pathname | The directory structure to create. Either an absolute or relative path. If the path is relative and exists in the process' cwd it will not be created. Otherwise relative paths will be prefixed with the current pwd(). |
integer|boolean | $mode | octal value 0755 |
Returns TRUE on success, FALSE on failure
None found |
dirsize() : integer
Returns the size in bytes of this Folder and its contents.
size in bytes of current folder
None found |
delete(string|null $path = null) : boolean
Recursively Remove directories if the system allows.
string|null | $path | Path of directory to delete |
Success
None found |
copy(array|string $options) : boolean
Recursive directory copy.
to
The directory to copy to.from
The directory to copy from, this will cause a cd() to occur, changing the results of pwd().mode
The mode to copy the files/directories with as integer, e.g. 0775.skip
Files/directories to skip.scheme
Folder::MERGE, Folder::OVERWRITE, Folder::SKIPrecursive
Whether to copy recursively or not (default: true - recursive)array|string | $options | Either an array of options (see above) or a string of the destination directory. |
Success.
None found |
move(array|string $options) : boolean
Recursive directory move.
to
The directory to copy to.from
The directory to copy from, this will cause a cd() to occur, changing the results of pwd().chmod
The mode to copy the files/directories with.skip
Files/directories to skip.scheme
Folder::MERGE, Folder::OVERWRITE, Folder::SKIPrecursive
Whether to copy recursively or not (default: true - recursive)array|string | $options | (to, from, chmod, skip, scheme) |
Success
None found |
messages(boolean $reset = true) : array
get messages from latest method
boolean | $reset | Reset message stack after reading |
None found |
errors(boolean $reset = true) : array
get error from latest method
boolean | $reset | Reset error stack after reading |
None found |
realpath(string $path) : string|false
Get the real path (taking ".
." and such into account)
string | $path | Path to resolve |
The resolved path
None found |
isSlashTerm(string $path) : boolean
Returns true if given $path ends in a slash (i.e. is slash-terminated).
string | $path | Path to check |
true if path ends with slash, false otherwise
None found |
_findRecursive(string $pattern, boolean $sort = false) : array
Private helper function for findRecursive.
string | $pattern | Pattern to match against |
boolean | $sort | Whether results should be sorted. |
Files matching pattern
None found |