Folder structure browser, lists folders and files. Provides an Object interface for Common directory related tasks.
__construct( string $path false , boolean $create false , string|boolean $mode false )
Constructor.
$path
optional false $create
optional false $mode
optional false _findRecursive( string $pattern , boolean $sort false )
Private helper function for findRecursive.
$pattern
$sort
optional false array
addPathElement( string $path , string|array $element )
Returns $path with $element added, with correct slash in-between.
$path
$element
string
cd( string $path )
Change directory to $path.
$path
string
chmod( string $path , integer $mode false , boolean $recursive true , array $exceptions array() )
Change the mode on a directory structure recursively. This includes changing the mode on files as well.
$path
$mode
optional false $recursive
optional true $exceptions
optional array() boolean
copy( array|string $options )
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::SKIP$options
boolean
correctSlashFor( string $path )
Returns a correct set of slashes for given $path. (\\ for Windows paths and / for other paths.)
$path
string
create( string $pathname , integer $mode false )
Create a directory structure recursively.
Can be used to create deep path structures like /foo/bar/baz/shoe/horn
$pathname
$mode
optional false boolean
delete( string $path null )
Recursively Remove directories if the system allows.
$path
optional null boolean
dirsize( )
Returns the size in bytes of this Folder and its contents.
integer
errors( boolean $reset true )
get error from latest method
$reset
optional true array
find( string $regexpPattern '.*' , boolean $sort false )
Returns an array of all matching files in current directory.
$regexpPattern
optional '.*' $sort
optional false array
findRecursive( string $pattern '.*' , boolean $sort false )
Returns an array of all matching files in and below current directory.
$pattern
optional '.*' $sort
optional false array
inCakePath( string $path '' )
Returns true if the File is in a given CakePath.
$path
optional '' boolean
inPath( string $path '' , boolean $reverse false )
Returns true if the File is in given path.
$path
optional '' $reverse
optional false boolean
isAbsolute( string $path )
Returns true if given $path is an absolute path.
$path
boolean
isRegisteredStreamWrapper( string $path )
Returns true if given $path is a registered stream wrapper.
$path
boo
isSlashTerm( string $path )
Returns true if given $path ends in a slash (i.e. is slash-terminated).
$path
boolean
isWindowsPath( string $path )
Returns true if given $path is a Windows path.
$path
boolean
messages( boolean $reset true )
get messages from latest method
$reset
optional true array
move( array $options )
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::SKIP$options
boolean
normalizePath( string $path )
Returns a correct set of slashes for given $path. (\\ for Windows paths and / for other paths.)
$path
string
pwd( )
Return current path.
string
read( boolean $sort true , array|boolean $exceptions false , boolean $fullPath false )
Returns an array of the contents of the current directory. The returned array holds two arrays: One of directories and one of files.
$sort
optional true $exceptions
optional false $fullPath
optional false mixed
realpath( string $path )
Get the real path (taking ".." and such into account)
$path
string
slashTerm( string $path )
Returns $path with added terminating slash (corrected for Windows or other OS).
$path
string
tree( string $path null , array|boolean $exceptions false , string $type null )
Returns an array of nested directories and files in each directory
$path
optional null $exceptions
optional false $type
optional null mixed
string | MERGE Default scheme for Folder::copy Recursively merges subfolders with the same name | 'merge' |
string | OVERWRITE Overwrite scheme for Folder::copy subfolders with the same name will be replaced | 'overwrite' |
string | SKIP Skip scheme for Folder::copy if a subfolder with the same name exists it will be skipped | 'skip' |
© 2005–2016 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
http://api.cakephp.org/2.7/class-Folder.html