Folder Class Info:
- Class Declaration:
class Folder
- File name:
- Cake/Utility/Folder.php
- Description:
Folder structure browser, lists folders and files. Provides an Object interface for Common directory related tasks.
- Package
- Cake.Utility
Properties:
-
_directories array
Holds array of complete directory paths.
-
_errors array
Holds errors from last method.
-
_files array
Holds array of complete file paths.
-
_messages array
Holds messages from last method.
-
mode integer
Mode to be used on create. Does nothing on windows platforms.
http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::$mode
-
path string
Path to Folder.
-
sort boolean
Sortedness. Whether or not list results should be sorted by name.
Method Summary:
- addPathElement( $path, $element )
- cd( $path )
- chmod( $path, $mode = false, $recursive = true, $exceptions = array ( ) )
- __construct( $path = false, $create = false, $mode = false )
- copy( $options = array ( ) )
- correctSlashFor( $path )
- create( $pathname, $mode = false )
- delete( $path = NULL )
- dirsize( )
- errors( )
- find( $regexpPattern = '.*', $sort = false )
- _findRecursive( $pattern, $sort = false )
- findRecursive( $pattern = '.*', $sort = false )
- inCakePath( $path = '' )
- inPath( $path = '', $reverse = false )
- isAbsolute( $path )
- isSlashTerm( $path )
- isWindowsPath( $path )
- messages( )
- move( $options )
- normalizePath( $path )
- pwd( )
- read( $sort = true, $exceptions = false, $fullPath = false )
- realpath( $path )
- slashTerm( $path )
- tree( $path = NULL, $exceptions = false, $type = NULL )
addPathElement
topReturns $path with $element added, with correct slash in-between.
- Parameters:
-
-
string $path required
Path
-
string $element required
Element to and at end of path
-
- Method defined in:
- Cake/Utility/Folder.php on line 303
- Return
string Combined path
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::addPathElement
cd
topChange directory to $path.
- Parameters:
-
-
string $path required
Path to the directory to change to
-
- Method defined in:
- Cake/Utility/Folder.php on line 121
- Return
string The new path. Returns false on failure
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::cd
chmod
topChange the mode on a directory structure recursively. This includes changing the mode on files as well.
- Parameters:
-
-
string $path required
The path to chmod
-
integer $mode optional false
octal value 0755
-
boolean $recursive optional true
chmod recursively, set to false to only change the current directory.
-
array $exceptions optional array ( )
array of files, directories to skip
-
- Method defined in:
- Cake/Utility/Folder.php on line 351
- Return
boolean Returns TRUE on success, FALSE on failure
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::chmod
__construct
topConstructor.
- Parameters:
-
-
string $path optional false
Path to folder
-
boolean $create optional false
Create folder if not found
-
mixed $mode optional false
Mode (CHMOD) to apply to created folder, false to ignore
-
- Method defined in:
- Cake/Utility/Folder.php on line 85
copy
topRecursive directory copy.
Options
toThe directory to copy to.fromThe directory to copy from, this will cause a cd() to occur, changing the results of pwd().modeThe mode to copy the files/directories with.skipFiles/directories to skip.
- Parameters:
-
-
mixed $options optional array ( )
Either an array of options (see above) or a string of the destination directory.
-
- Method defined in:
- Cake/Utility/Folder.php on line 602
- Return
boolean Success
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::copy
correctSlashFor
topReturns a correct set of slashes for given $path. (\\ for Windows paths and / for other paths.)
- Parameters:
-
-
string $path required
Path to check
-
- Method defined in:
- Cake/Utility/Folder.php on line 277
- Return
string Set of slashes ("\\" or "/")
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::correctSlashFor
create
topCreate a directory structure recursively. Can be used to create
deep path structures like /foo/bar/baz/shoe/horn
- Parameters:
-
-
string $pathname required
The directory structure to create
-
integer $mode optional false
octal value 0755
-
- Method defined in:
- Cake/Utility/Folder.php on line 467
- Return
boolean Returns TRUE on success, FALSE on failure
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::create
delete
topRecursively Remove directories if the system allows.
- Parameters:
-
-
string $path optional NULL
Path of directory to delete
-
- Method defined in:
- Cake/Utility/Folder.php on line 543
- Return
boolean Success
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::delete
dirsize
topReturns the size in bytes of this Folder and its contents.
- Method defined in:
- Cake/Utility/Folder.php on line 506
- Return
integer size in bytes of current folder
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::dirsize
find
topReturns an array of all matching files in current directory.
- Parameters:
-
-
string $regexpPattern optional '.*'
Preg_match pattern (Defaults to: .*)
-
boolean $sort optional false
Whether results should be sorted.
-
- Method defined in:
- Cake/Utility/Folder.php on line 189
- Return
array Files that match given pattern
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::find
_findRecursive
topPrivate helper function for findRecursive.
- Parameters:
-
-
string $pattern required
Pattern to match against
-
boolean $sort optional false
Whether results should be sorted.
-
- Method defined in:
- Cake/Utility/Folder.php on line 219
- Return
array Files matching pattern
findRecursive
topReturns an array of all matching files in and below current directory.
- Parameters:
-
-
string $pattern optional '.*'
Preg_match pattern (Defaults to: .*)
-
boolean $sort optional false
Whether results should be sorted.
-
- Method defined in:
- Cake/Utility/Folder.php on line 202
- Return
array Files matching $pattern
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::findRecursive
inCakePath
topReturns true if the File is in a given CakePath.
- Parameters:
-
-
string $path optional ''
The path to check.
-
- Method defined in:
- Cake/Utility/Folder.php on line 314
inPath
topReturns true if the File is in given path.
- Parameters:
-
-
string $path optional ''
The path to check that the current pwd() resides with in.
-
boolean $reverse optional false
Reverse the search, check that pwd() resides within $path.
-
- Method defined in:
- Cake/Utility/Folder.php on line 329
isAbsolute
topReturns true if given $path is an absolute path.
- Parameters:
-
-
string $path required
Path to check
-
- Method defined in:
- Cake/Utility/Folder.php on line 255
- Return
boolean true if path is absolute.
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::isAbsolute
isSlashTerm
topReturns true if given $path ends in a slash (i.e. is slash-terminated).
- Parameters:
-
-
string $path required
Path to check
-
- Method defined in:
- Cake/Utility/Folder.php on line 775
- Return
boolean true if path ends with slash, false otherwise
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::isSlashTerm
isWindowsPath
topReturns true if given $path is a Windows path.
- Parameters:
-
-
string $path required
Path to check
-
- Method defined in:
- Cake/Utility/Folder.php on line 244
- Return
boolean true if windows path, false otherwise
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::isWindowsPath
move
topRecursive directory move.
Options
toThe directory to copy to.fromThe directory to copy from, this will cause a cd() to occur, changing the results of pwd().chmodThe mode to copy the files/directories with.skipFiles/directories to skip.
- Parameters:
-
-
array $options required
(to, from, chmod, skip)
-
- Method defined in:
- Cake/Utility/Folder.php on line 688
- Return
boolean Success
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::move
normalizePath
topReturns a correct set of slashes for given $path. (\\ for Windows paths and / for other paths.)
- Parameters:
-
-
string $path required
Path to check
-
- Method defined in:
- Cake/Utility/Folder.php on line 266
- Return
string Set of slashes ("\\" or "/")
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::normalizePath
pwd
topReturn current path.
- Method defined in:
- Cake/Utility/Folder.php on line 110
- Return
string Current path
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::pwd
read
topReturns an array of the contents of the current directory. The returned array holds two arrays: One of directories and one of files.
- Parameters:
-
-
boolean $sort optional true
Whether you want the results sorted, set this and the sort property to false to get unsorted results.
-
mixed $exceptions optional false
Either an array or boolean true will not grab dot files
-
boolean $fullPath optional false
True returns the full path
-
- Method defined in:
- Cake/Utility/Folder.php on line 140
- Return
mixed Contents of current directory as an array, an empty array on failure
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::read
realpath
topGet the real path (taking ".." and such into account)
- Parameters:
-
-
string $path required
Path to resolve
-
- Method defined in:
- Cake/Utility/Folder.php on line 734
- Return
string The resolved path
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::realpath
slashTerm
topReturns $path with added terminating slash (corrected for Windows or other OS).
- Parameters:
-
-
string $path required
Path to check
-
- Method defined in:
- Cake/Utility/Folder.php on line 288
- Return
string Path with ending slash
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::slashTerm
tree
topReturns an array of nested directories and files in each directory
- Parameters:
-
-
string $path optional NULL
the directory path to build the tree from
-
mixed $exceptions optional false
Either an array of files/folder to exclude or boolean true to not grab dot files/folders
-
string $type optional NULL
either 'file' or 'dir'. null returns both files and directories
-
- Method defined in:
- Cake/Utility/Folder.php on line 403
- Return
mixed array of nested directories and files in each directory
- Link
- http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::tree
