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.

addPathElement

top

Returns $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

cd

top

Change 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

top

Change 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

top

Constructor.

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

top

Recursive directory copy.

Options

  • 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.
  • skip Files/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

correctSlashFor

top

Returns 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

create

top

Create 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

top

Recursively 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

dirsize

top

Returns the size in bytes of this Folder and its contents.

Method defined in:
Cake/Utility/Folder.php on line 506

errors

top

get error from latest method

Method defined in:
Cake/Utility/Folder.php on line 723

find

top

Returns 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

_findRecursive

top

Private 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

top

Returns 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

inCakePath

top

Returns 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

top

Returns 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

top

Returns 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

isSlashTerm

top

Returns 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

top

Returns 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

messages

top

get messages from latest method

Method defined in:
Cake/Utility/Folder.php on line 713

move

top

Recursive directory move.

Options

  • 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.

Parameters:
  • array $options required

    (to, from, chmod, skip)

Method defined in:
Cake/Utility/Folder.php on line 688

normalizePath

top

Returns 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

pwd

top

Return current path.

Method defined in:
Cake/Utility/Folder.php on line 110

read

top

Returns 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

top

Get 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

slashTerm

top

Returns $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

tree

top

Returns 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