Folder Class Reference

Inheritance diagram for Folder:

Object

List of all members.


Public Member Functions

 _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 ($regexp_pattern= '.*', $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)
 realpath ($path)
 rm ($path)
 tree ($path, $hidden=true, $type=null)

Static Public Member Functions

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

Public Attributes

 $mode = '0755'
 $path = null
 $sort = false

Detailed Description

Definition at line 42 of file folder.php.


Member Function Documentation

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 225 of file folder.php.

References $file, $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 315 of file folder.php.

References $path, and slashTerm().

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

Folder::cd ( path  ) 

Change directory to $desired_path.

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

Definition at line 134 of file folder.php.

References $path, and realpath().

Referenced by _findRecursive(), copy(), findRecursive(), and move().

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

Change the mode on a directory structure recursively.

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 361 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 578 of file folder.php.

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

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 289 of file folder.php.

References $path, and normalizePath().

Referenced by slashTerm().

Folder::cp ( options  ) 

nix flavored alias

See also:
copy public

Definition at line 707 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 463 of file folder.php.

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

Referenced by 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 533 of file folder.php.

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

Folder::dirsize (  ) 

Returns the size in bytes of this Folder.

Parameters:
string $directory Path to directory public

Definition at line 497 of file folder.php.

References read(), and slashTerm().

Folder::errors (  ) 

get error from latest method

Returns:
array public

Definition at line 680 of file folder.php.

Folder::find ( regexp_pattern = '.*',
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 188 of file folder.php.

References $file, $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 212 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 324 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 336 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 263 of file folder.php.

Referenced by 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 775 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 249 of file folder.php.

References $path.

Referenced by normalizePath().

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

nix flavored alias

See also:
read public

Definition at line 689 of file folder.php.

References $sort, and read().

Folder::messages (  ) 

get messages from latest method

Returns:
array public

Definition at line 671 of file folder.php.

Folder::mkdir ( pathname,
mode = 0755 
)

nix flavored alias

See also:
create public

Definition at line 698 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 650 of file folder.php.

References cd(), and copy().

Referenced by mv().

Folder::mv ( options  ) 

nix flavored alias

See also:
move public

Definition at line 716 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 275 of file folder.php.

References $path, and isWindowsPath().

Referenced by correctSlashFor().

Folder::pwd (  ) 

Return current path.

Returns:
string Current path public

Definition at line 124 of file folder.php.

Referenced by delete(), and inPath().

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

Returns an array of the contents of the current directory, or false on failure. The returned array holds two arrays: one of dirs and one of files.

Parameters:
boolean $sort
mixed $exceptions either an array or boolean true will no grab dot files
Returns:
mixed Contents of current directory as an array, false on failure public

Definition at line 150 of file folder.php.

References $sort, and addPathElement().

Referenced by _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 734 of file folder.php.

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

Referenced by cd().

Folder::rm ( path  ) 

nix flavored alias

See also:
delete public

Definition at line 725 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 300 of file folder.php.

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

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

Folder::tree ( path,
hidden = 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 408 of file folder.php.

References $path.

Referenced by chmod().


Member Data Documentation

Folder::$mode = '0755'

Definition at line 63 of file folder.php.

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

Folder::$sort = false

Definition at line 56 of file folder.php.

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


The documentation for this class was generated from the following file: