Folder Class Reference

Inheritance diagram for Folder:

Object List of all members.

Public Member Functions

 __construct ($path=false, $create=false, $mode=false)
 __tree ($path, $exceptions)
 _findRecursive ($pattern, $sort=false)
 cd ($path)
 chmod ($path, $mode=false, $recursive=true, $exceptions=array())
 copy ($options=array())
 cp ($options)
 create ($pathname, $mode=false)
 delete ($path=null)
 dirsize ()
 errors ()
 find ($regexpPattern= '.*', $sort=false)
 findRecursive ($pattern= '.*', $sort=false)
 inCakePath ($path= '')
 inPath ($path= '', $reverse=false)
 ls ($sort=true, $exceptions=false)
 messages ()
 mkdir ($pathname, $mode=0755)
 move ($options)
 mv ($options)
 pwd ()
 read ($sort=true, $exceptions=false, $fullPath=false)
 realpath ($path)
 rm ($path)
 tree ($path, $exceptions=true, $type=null)

Static Public Member Functions

 addPathElement ($path, $element)
 correctSlashFor ($path)
 isAbsolute ($path)
 isSlashTerm ($path)
 isWindowsPath ($path)
 normalizePath ($path)
 slashTerm ($path)

Public Attributes

 $__directories
 $__errors = false
 $__files
 $__messages = array()
 $mode = 0755
 $path = null
 $sort = false

Detailed Description

Definition at line 40 of file folder.php.


Constructor & Destructor Documentation

Folder::__construct ( path = false,
create = false,
mode = false 
)

Constructor.

Parameters:
string $path Path to folder
boolean $create Create folder if not found
mixed $mode Mode (CHMOD) to apply to created folder, false to ignore

Definition at line 97 of file folder.php.

References $mode, $path, __construct(), cd(), create(), isAbsolute(), and realpath().


Member Function Documentation

Folder::__tree ( path,
exceptions 
)

Private method to list directories and files in each directory

Parameters:
string $path
= boolean $hidden private

Definition at line 433 of file folder.php.

References $path, cd(), and read().

Referenced by tree().

Folder::_findRecursive ( pattern,
sort = false 
)

Private helper function for findRecursive.

Parameters:
string $pattern Pattern to match against
Returns:
array Files matching pattern private

Definition at line 213 of file folder.php.

References $sort, addPathElement(), cd(), findRecursive(), and read().

Referenced by findRecursive().

Folder::addPathElement ( path,
element 
) [static]

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

Parameters:
string $path Path
string $element Element to and at end of path
Returns:
string Combined path public

Definition at line 304 of file folder.php.

References $path, and slashTerm().

Referenced by _findRecursive(), copy(), read(), and realpath().

Folder::cd ( path  ) 

Change directory to $path.

Parameters:
string $path Path to the directory to change to
Returns:
string The new path. Returns false on failure public

Definition at line 132 of file folder.php.

References $path, and realpath().

Referenced by __construct(), __tree(), _findRecursive(), copy(), findRecursive(), move(), and tree().

Folder::chmod ( path,
mode = false,
recursive = true,
exceptions = array() 
)

Change the mode on a directory structure recursively. This includes changing the mode on files as well.

Parameters:
string $path The path to chmod
integer $mode octal value 0755
boolean $recursive chmod recursively
array $exceptions array of files, directories to skip
Returns:
boolean Returns TRUE on success, FALSE on failure public

Definition at line 350 of file folder.php.

References $mode, $path, __(), and tree().

Referenced by copy().

Folder::copy ( options = array()  ) 

Recursive directory copy.

Parameters:
array $options (to, from, chmod, skip)
Returns:
bool public

Definition at line 568 of file folder.php.

References $handle, $mode, __(), addPathElement(), cd(), chmod(), mkdir(), and writable().

Referenced by cp(), and move().

Folder::correctSlashFor ( path  )  [static]

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

Parameters:
string $path Path to check
Returns:
string Set of slashes ("\\" or "/") public

Definition at line 275 of file folder.php.

References $path, and isWindowsPath().

Referenced by normalizePath(), and slashTerm().

Folder::cp ( options  ) 

nix flavored alias

See also:
copy public

Definition at line 700 of file folder.php.

References copy().

Folder::create ( pathname,
mode = false 
)

Create a directory structure recursively.

Parameters:
string $pathname The directory structure to create
integer $mode octal value 0755
Returns:
boolean Returns TRUE on success, FALSE on failure public

Definition at line 448 of file folder.php.

References $mode, __(), a(), and mkdir().

Referenced by __construct(), and mkdir().

Folder::delete ( path = null  ) 

Recursively Remove directories if system allow.

Parameters:
string $path Path of directory to delete
Returns:
boolean Success public

Definition at line 522 of file folder.php.

References $path, __(), pwd(), and slashTerm().

Folder::dirsize (  ) 

Returns the size in bytes of this Folder.

Parameters:
string $directory Path to directory
Returns:
int size in bytes of current folder public

Definition at line 486 of file folder.php.

References read(), and slashTerm().

Folder::errors (  ) 

get error from latest method

Returns:
array public

Definition at line 673 of file folder.php.

Folder::find ( regexpPattern = '.*',
sort = false 
)

Returns an array of all matching files in current directory.

Parameters:
string $pattern Preg_match pattern (Defaults to: .*)
Returns:
array Files that match given pattern public

Definition at line 189 of file folder.php.

References $sort, and read().

Folder::findRecursive ( pattern = '.*',
sort = false 
)

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

Parameters:
string $pattern Preg_match pattern (Defaults to: .*)
Returns:
array Files matching $pattern public

Definition at line 200 of file folder.php.

References $out, $sort, _findRecursive(), and cd().

Referenced by _findRecursive().

Folder::inCakePath ( path = ''  ) 

Returns true if the File is in a given CakePath.

Returns:
bool public

Definition at line 313 of file folder.php.

References $path, inPath(), and slashTerm().

Folder::inPath ( path = '',
reverse = false 
)

Returns true if the File is in given path.

Returns:
bool public

Definition at line 325 of file folder.php.

References $path, pwd(), and slashTerm().

Referenced by inCakePath().

Folder::isAbsolute ( path  )  [static]

Returns true if given $path is an absolute path.

Parameters:
string $path Path to check
Returns:
bool public

Definition at line 252 of file folder.php.

Referenced by __construct(), and realpath().

Folder::isSlashTerm ( path  )  [static]

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

Parameters:
string $path Path to check
Returns:
boolean true if path ends with slash, false otherwise public

Definition at line 768 of file folder.php.

References $path.

Referenced by slashTerm().

Folder::isWindowsPath ( path  )  [static]

Returns true if given $path is a Windows path.

Parameters:
string $path Path to check
Returns:
boolean true if windows path, false otherwise public

Definition at line 238 of file folder.php.

References $path.

Referenced by correctSlashFor().

Folder::ls ( sort = true,
exceptions = false 
)

nix flavored alias

See also:
read public

Definition at line 682 of file folder.php.

References $sort, and read().

Folder::messages (  ) 

get messages from latest method

Returns:
array public

Definition at line 664 of file folder.php.

Folder::mkdir ( pathname,
mode = 0755 
)

nix flavored alias

See also:
create public

Definition at line 691 of file folder.php.

References $mode, and create().

Referenced by copy(), and create().

Folder::move ( options  ) 

Recursive directory move.

Parameters:
array $options (to, from, chmod, skip)
Returns:
boolean Success public

Definition at line 643 of file folder.php.

References cd(), and copy().

Referenced by mv().

Folder::mv ( options  ) 

nix flavored alias

See also:
move public

Definition at line 709 of file folder.php.

References move().

Folder::normalizePath ( path  )  [static]

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

Parameters:
string $path Path to check
Returns:
string Set of slashes ("\\" or "/") public

Definition at line 264 of file folder.php.

References $path, and correctSlashFor().

Folder::pwd (  ) 

Return current path.

Returns:
string Current path public

Definition at line 122 of file folder.php.

Referenced by delete(), and inPath().

Folder::read ( sort = true,
exceptions = false,
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.

Parameters:
boolean $sort
mixed $exceptions Either an array or boolean true will not grab dot files
boolean $fullPath True returns the full path
Returns:
mixed Contents of current directory as an array, an empty array on failure public

Definition at line 149 of file folder.php.

References $path, $sort, and addPathElement().

Referenced by __tree(), _findRecursive(), dirsize(), find(), and ls().

Folder::realpath ( path  ) 

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

Parameters:
string $path Path to resolve
Returns:
string The resolved path

Definition at line 727 of file folder.php.

References $path, addPathElement(), isAbsolute(), and slashTerm().

Referenced by __construct(), and cd().

Folder::rm ( path  ) 

nix flavored alias

See also:
delete public

Definition at line 718 of file folder.php.

References $path.

Folder::slashTerm ( path  )  [static]

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

Parameters:
string $path Path to check
Returns:
string Path with ending slash public

Definition at line 289 of file folder.php.

References $path, correctSlashFor(), and isSlashTerm().

Referenced by addPathElement(), delete(), dirsize(), ProjectTask::execute(), inCakePath(), inPath(), and realpath().

Folder::tree ( path,
exceptions = true,
type = null 
)

Returns an array of nested directories and files in each directory

Parameters:
string $path the directory path to build the tree from
boolean $hidden return hidden files and directories
string $type either file or dir. null returns both files and directories
Returns:
mixed array of nested directories and files in each directory public

Definition at line 400 of file folder.php.

References $path, __tree(), and cd().

Referenced by chmod().


Member Data Documentation

Folder::$__directories

Definition at line 82 of file folder.php.

Folder::$__errors = false

Definition at line 75 of file folder.php.

Folder::$__files

Definition at line 89 of file folder.php.

Folder::$__messages = array()

Definition at line 68 of file folder.php.

Folder::$mode = 0755

Definition at line 61 of file folder.php.

Referenced by __construct(), chmod(), copy(), create(), and mkdir().

Folder::$path = null

Definition at line 47 of file folder.php.

Referenced by __construct(), __tree(), addPathElement(), cd(), chmod(), correctSlashFor(), delete(), inCakePath(), inPath(), isSlashTerm(), isWindowsPath(), normalizePath(), read(), realpath(), rm(), slashTerm(), and tree().

Folder::$sort = false

Definition at line 54 of file folder.php.

Referenced by _findRecursive(), find(), findRecursive(), ls(), and read().


The documentation for this class was generated from the following file:
Generated on Sun Nov 22 00:30:56 2009 for CakePHP 1.2.x.x (v1.2.4.8284) by doxygen 1.4.7