mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Merge pull request #317 from shama/2.0
Add @link to File and Folder utilities
This commit is contained in:
commit
9d82cd9417
2 changed files with 54 additions and 1 deletions
|
@ -80,6 +80,7 @@ class File {
|
||||||
* @param string $path Path to file
|
* @param string $path Path to file
|
||||||
* @param boolean $create Create file if it does not exist (if true)
|
* @param boolean $create Create file if it does not exist (if true)
|
||||||
* @param integer $mode Mode to apply to the folder holding the file
|
* @param integer $mode Mode to apply to the folder holding the file
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File
|
||||||
*/
|
*/
|
||||||
public function __construct($path, $create = false, $mode = 0755) {
|
public function __construct($path, $create = false, $mode = 0755) {
|
||||||
$this->Folder = new Folder(dirname($path), $create, $mode);
|
$this->Folder = new Folder(dirname($path), $create, $mode);
|
||||||
|
@ -102,6 +103,7 @@ class File {
|
||||||
* Creates the File.
|
* Creates the File.
|
||||||
*
|
*
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::create
|
||||||
*/
|
*/
|
||||||
public function create() {
|
public function create() {
|
||||||
$dir = $this->Folder->pwd();
|
$dir = $this->Folder->pwd();
|
||||||
|
@ -121,6 +123,7 @@ class File {
|
||||||
* @param string $mode A valid 'fopen' mode string (r|w|a ...)
|
* @param string $mode A valid 'fopen' mode string (r|w|a ...)
|
||||||
* @param boolean $force If true then the file will be re-opened even if its already opened, otherwise it won't
|
* @param boolean $force If true then the file will be re-opened even if its already opened, otherwise it won't
|
||||||
* @return boolean True on success, false on failure
|
* @return boolean True on success, false on failure
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::open
|
||||||
*/
|
*/
|
||||||
public function open($mode = 'r', $force = false) {
|
public function open($mode = 'r', $force = false) {
|
||||||
if (!$force && is_resource($this->handle)) {
|
if (!$force && is_resource($this->handle)) {
|
||||||
|
@ -147,6 +150,7 @@ class File {
|
||||||
* @param string $mode A `fread` compatible mode.
|
* @param string $mode A `fread` compatible mode.
|
||||||
* @param boolean $force If true then the file will be re-opened even if its already opened, otherwise it won't
|
* @param boolean $force If true then the file will be re-opened even if its already opened, otherwise it won't
|
||||||
* @return mixed string on success, false on failure
|
* @return mixed string on success, false on failure
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::read
|
||||||
*/
|
*/
|
||||||
public function read($bytes = false, $mode = 'rb', $force = false) {
|
public function read($bytes = false, $mode = 'rb', $force = false) {
|
||||||
if ($bytes === false && $this->lock === null) {
|
if ($bytes === false && $this->lock === null) {
|
||||||
|
@ -182,6 +186,7 @@ class File {
|
||||||
* @param mixed $offset The $offset in bytes to seek. If set to false then the current offset is returned.
|
* @param mixed $offset The $offset in bytes to seek. If set to false then the current offset is returned.
|
||||||
* @param integer $seek PHP Constant SEEK_SET | SEEK_CUR | SEEK_END determining what the $offset is relative to
|
* @param integer $seek PHP Constant SEEK_SET | SEEK_CUR | SEEK_END determining what the $offset is relative to
|
||||||
* @return mixed True on success, false on failure (set mode), false on failure or integer offset on success (get mode)
|
* @return mixed True on success, false on failure (set mode), false on failure or integer offset on success (get mode)
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::offset
|
||||||
*/
|
*/
|
||||||
public function offset($offset = false, $seek = SEEK_SET) {
|
public function offset($offset = false, $seek = SEEK_SET) {
|
||||||
if ($offset === false) {
|
if ($offset === false) {
|
||||||
|
@ -202,6 +207,7 @@ class File {
|
||||||
* @param string $data Data to prepare for writing.
|
* @param string $data Data to prepare for writing.
|
||||||
* @param boolean $forceWindows
|
* @param boolean $forceWindows
|
||||||
* @return string The with converted line endings.
|
* @return string The with converted line endings.
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::prepare
|
||||||
*/
|
*/
|
||||||
public static function prepare($data, $forceWindows = false) {
|
public static function prepare($data, $forceWindows = false) {
|
||||||
$lineBreak = "\n";
|
$lineBreak = "\n";
|
||||||
|
@ -218,6 +224,7 @@ class File {
|
||||||
* @param string $mode Mode of writing. {@link http://php.net/fwrite See fwrite()}.
|
* @param string $mode Mode of writing. {@link http://php.net/fwrite See fwrite()}.
|
||||||
* @param string $force force the file to open
|
* @param string $force force the file to open
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::write
|
||||||
*/
|
*/
|
||||||
public function write($data, $mode = 'w', $force = false) {
|
public function write($data, $mode = 'w', $force = false) {
|
||||||
$success = false;
|
$success = false;
|
||||||
|
@ -244,6 +251,7 @@ class File {
|
||||||
* @param string $data Data to write
|
* @param string $data Data to write
|
||||||
* @param string $force force the file to open
|
* @param string $force force the file to open
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::append
|
||||||
*/
|
*/
|
||||||
public function append($data, $force = false) {
|
public function append($data, $force = false) {
|
||||||
return $this->write($data, 'a', $force);
|
return $this->write($data, 'a', $force);
|
||||||
|
@ -253,6 +261,7 @@ class File {
|
||||||
* Closes the current file if it is opened.
|
* Closes the current file if it is opened.
|
||||||
*
|
*
|
||||||
* @return boolean True if closing was successful or file was already closed, otherwise false
|
* @return boolean True if closing was successful or file was already closed, otherwise false
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::close
|
||||||
*/
|
*/
|
||||||
public function close() {
|
public function close() {
|
||||||
if (!is_resource($this->handle)) {
|
if (!is_resource($this->handle)) {
|
||||||
|
@ -265,6 +274,7 @@ class File {
|
||||||
* Deletes the File.
|
* Deletes the File.
|
||||||
*
|
*
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::delete
|
||||||
*/
|
*/
|
||||||
public function delete() {
|
public function delete() {
|
||||||
clearstatcache();
|
clearstatcache();
|
||||||
|
@ -282,6 +292,7 @@ class File {
|
||||||
* Returns the File info.
|
* Returns the File info.
|
||||||
*
|
*
|
||||||
* @return string The File extension
|
* @return string The File extension
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::info
|
||||||
*/
|
*/
|
||||||
public function info() {
|
public function info() {
|
||||||
if ($this->info == null) {
|
if ($this->info == null) {
|
||||||
|
@ -297,6 +308,7 @@ class File {
|
||||||
* Returns the File extension.
|
* Returns the File extension.
|
||||||
*
|
*
|
||||||
* @return string The File extension
|
* @return string The File extension
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::ext
|
||||||
*/
|
*/
|
||||||
public function ext() {
|
public function ext() {
|
||||||
if ($this->info == null) {
|
if ($this->info == null) {
|
||||||
|
@ -312,6 +324,7 @@ class File {
|
||||||
* Returns the File name without extension.
|
* Returns the File name without extension.
|
||||||
*
|
*
|
||||||
* @return string The File name without extension.
|
* @return string The File name without extension.
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::name
|
||||||
*/
|
*/
|
||||||
public function name() {
|
public function name() {
|
||||||
if ($this->info == null) {
|
if ($this->info == null) {
|
||||||
|
@ -331,6 +344,7 @@ class File {
|
||||||
* @param string $name The name of the file to make safe if different from $this->name
|
* @param string $name The name of the file to make safe if different from $this->name
|
||||||
* @param string $ext The name of the extension to make safe if different from $this->ext
|
* @param string $ext The name of the extension to make safe if different from $this->ext
|
||||||
* @return string $ext the extension of the file
|
* @return string $ext the extension of the file
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::safe
|
||||||
*/
|
*/
|
||||||
public function safe($name = null, $ext = null) {
|
public function safe($name = null, $ext = null) {
|
||||||
if (!$name) {
|
if (!$name) {
|
||||||
|
@ -347,6 +361,7 @@ class File {
|
||||||
*
|
*
|
||||||
* @param mixed $maxsize in MB or true to force
|
* @param mixed $maxsize in MB or true to force
|
||||||
* @return string md5 Checksum {@link http://php.net/md5_file See md5_file()}
|
* @return string md5 Checksum {@link http://php.net/md5_file See md5_file()}
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::md5
|
||||||
*/
|
*/
|
||||||
public function md5($maxsize = 5) {
|
public function md5($maxsize = 5) {
|
||||||
if ($maxsize === true) {
|
if ($maxsize === true) {
|
||||||
|
@ -365,6 +380,7 @@ class File {
|
||||||
* Returns the full path of the File.
|
* Returns the full path of the File.
|
||||||
*
|
*
|
||||||
* @return string Full path to file
|
* @return string Full path to file
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::pwd
|
||||||
*/
|
*/
|
||||||
public function pwd() {
|
public function pwd() {
|
||||||
if (is_null($this->path)) {
|
if (is_null($this->path)) {
|
||||||
|
@ -377,6 +393,7 @@ class File {
|
||||||
* Returns true if the File exists.
|
* Returns true if the File exists.
|
||||||
*
|
*
|
||||||
* @return boolean true if it exists, false otherwise
|
* @return boolean true if it exists, false otherwise
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::exists
|
||||||
*/
|
*/
|
||||||
public function exists() {
|
public function exists() {
|
||||||
return (file_exists($this->path) && is_file($this->path));
|
return (file_exists($this->path) && is_file($this->path));
|
||||||
|
@ -386,6 +403,7 @@ class File {
|
||||||
* Returns the "chmod" (permissions) of the File.
|
* Returns the "chmod" (permissions) of the File.
|
||||||
*
|
*
|
||||||
* @return string Permissions for the file
|
* @return string Permissions for the file
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::perms
|
||||||
*/
|
*/
|
||||||
public function perms() {
|
public function perms() {
|
||||||
if ($this->exists()) {
|
if ($this->exists()) {
|
||||||
|
@ -398,6 +416,7 @@ class File {
|
||||||
* Returns the Filesize
|
* Returns the Filesize
|
||||||
*
|
*
|
||||||
* @return integer size of the file in bytes, or false in case of an error
|
* @return integer size of the file in bytes, or false in case of an error
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::size
|
||||||
*/
|
*/
|
||||||
public function size() {
|
public function size() {
|
||||||
if ($this->exists()) {
|
if ($this->exists()) {
|
||||||
|
@ -410,6 +429,7 @@ class File {
|
||||||
* Returns true if the File is writable.
|
* Returns true if the File is writable.
|
||||||
*
|
*
|
||||||
* @return boolean true if its writable, false otherwise
|
* @return boolean true if its writable, false otherwise
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::writable
|
||||||
*/
|
*/
|
||||||
public function writable() {
|
public function writable() {
|
||||||
return is_writable($this->path);
|
return is_writable($this->path);
|
||||||
|
@ -419,6 +439,7 @@ class File {
|
||||||
* Returns true if the File is executable.
|
* Returns true if the File is executable.
|
||||||
*
|
*
|
||||||
* @return boolean true if its executable, false otherwise
|
* @return boolean true if its executable, false otherwise
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::executable
|
||||||
*/
|
*/
|
||||||
public function executable() {
|
public function executable() {
|
||||||
return is_executable($this->path);
|
return is_executable($this->path);
|
||||||
|
@ -428,6 +449,7 @@ class File {
|
||||||
* Returns true if the File is readable.
|
* Returns true if the File is readable.
|
||||||
*
|
*
|
||||||
* @return boolean true if file is readable, false otherwise
|
* @return boolean true if file is readable, false otherwise
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::readable
|
||||||
*/
|
*/
|
||||||
public function readable() {
|
public function readable() {
|
||||||
return is_readable($this->path);
|
return is_readable($this->path);
|
||||||
|
@ -437,6 +459,7 @@ class File {
|
||||||
* Returns the File's owner.
|
* Returns the File's owner.
|
||||||
*
|
*
|
||||||
* @return integer the Fileowner
|
* @return integer the Fileowner
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::owner
|
||||||
*/
|
*/
|
||||||
public function owner() {
|
public function owner() {
|
||||||
if ($this->exists()) {
|
if ($this->exists()) {
|
||||||
|
@ -449,6 +472,7 @@ class File {
|
||||||
* Returns the File's group.
|
* Returns the File's group.
|
||||||
*
|
*
|
||||||
* @return integer the Filegroup
|
* @return integer the Filegroup
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::group
|
||||||
*/
|
*/
|
||||||
public function group() {
|
public function group() {
|
||||||
if ($this->exists()) {
|
if ($this->exists()) {
|
||||||
|
@ -461,6 +485,7 @@ class File {
|
||||||
* Returns last access time.
|
* Returns last access time.
|
||||||
*
|
*
|
||||||
* @return integer timestamp Timestamp of last access time
|
* @return integer timestamp Timestamp of last access time
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::lastAccess
|
||||||
*/
|
*/
|
||||||
public function lastAccess() {
|
public function lastAccess() {
|
||||||
if ($this->exists()) {
|
if ($this->exists()) {
|
||||||
|
@ -473,6 +498,7 @@ class File {
|
||||||
* Returns last modified time.
|
* Returns last modified time.
|
||||||
*
|
*
|
||||||
* @return integer timestamp Timestamp of last modification
|
* @return integer timestamp Timestamp of last modification
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::lastChange
|
||||||
*/
|
*/
|
||||||
public function lastChange() {
|
public function lastChange() {
|
||||||
if ($this->exists()) {
|
if ($this->exists()) {
|
||||||
|
@ -485,6 +511,7 @@ class File {
|
||||||
* Returns the current folder.
|
* Returns the current folder.
|
||||||
*
|
*
|
||||||
* @return Folder Current folder
|
* @return Folder Current folder
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::Folder
|
||||||
*/
|
*/
|
||||||
public function &Folder() {
|
public function &Folder() {
|
||||||
return $this->Folder;
|
return $this->Folder;
|
||||||
|
@ -495,7 +522,8 @@ class File {
|
||||||
*
|
*
|
||||||
* @param string $dest destination for the copy
|
* @param string $dest destination for the copy
|
||||||
* @param boolean $overwrite Overwrite $dest if exists
|
* @param boolean $overwrite Overwrite $dest if exists
|
||||||
* @return boolean Succes
|
* @return boolean Success
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::copy
|
||||||
*/
|
*/
|
||||||
public function copy($dest, $overwrite = true) {
|
public function copy($dest, $overwrite = true) {
|
||||||
if (!$this->exists() || is_file($dest) && !$overwrite) {
|
if (!$this->exists() || is_file($dest) && !$overwrite) {
|
||||||
|
|
|
@ -81,6 +81,7 @@ class Folder {
|
||||||
* @param string $path Path to folder
|
* @param string $path Path to folder
|
||||||
* @param boolean $create Create folder if not found
|
* @param boolean $create Create folder if not found
|
||||||
* @param mixed $mode Mode (CHMOD) to apply to created folder, false to ignore
|
* @param mixed $mode Mode (CHMOD) to apply to created folder, false to ignore
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder
|
||||||
*/
|
*/
|
||||||
public function __construct($path = false, $create = false, $mode = false) {
|
public function __construct($path = false, $create = false, $mode = false) {
|
||||||
if (empty($path)) {
|
if (empty($path)) {
|
||||||
|
@ -105,6 +106,7 @@ class Folder {
|
||||||
* Return current path.
|
* Return current path.
|
||||||
*
|
*
|
||||||
* @return string Current path
|
* @return string Current path
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::pwd
|
||||||
*/
|
*/
|
||||||
public function pwd() {
|
public function pwd() {
|
||||||
return $this->path;
|
return $this->path;
|
||||||
|
@ -115,6 +117,7 @@ class Folder {
|
||||||
*
|
*
|
||||||
* @param string $path Path to the directory to change to
|
* @param string $path Path to the directory to change to
|
||||||
* @return string The new path. Returns false on failure
|
* @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
|
||||||
*/
|
*/
|
||||||
public function cd($path) {
|
public function cd($path) {
|
||||||
$path = $this->realpath($path);
|
$path = $this->realpath($path);
|
||||||
|
@ -133,6 +136,7 @@ class Folder {
|
||||||
* @param mixed $exceptions Either an array or boolean true will not grab dot files
|
* @param mixed $exceptions Either an array or boolean true will not grab dot files
|
||||||
* @param boolean $fullPath True returns the full path
|
* @param boolean $fullPath True returns the full path
|
||||||
* @return mixed Contents of current directory as an array, an empty array on failure
|
* @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
|
||||||
*/
|
*/
|
||||||
public function read($sort = true, $exceptions = false, $fullPath = false) {
|
public function read($sort = true, $exceptions = false, $fullPath = false) {
|
||||||
$dirs = $files = array();
|
$dirs = $files = array();
|
||||||
|
@ -181,6 +185,7 @@ class Folder {
|
||||||
* @param string $regexpPattern Preg_match pattern (Defaults to: .*)
|
* @param string $regexpPattern Preg_match pattern (Defaults to: .*)
|
||||||
* @param boolean $sort Whether results should be sorted.
|
* @param boolean $sort Whether results should be sorted.
|
||||||
* @return array Files that match given pattern
|
* @return array Files that match given pattern
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::find
|
||||||
*/
|
*/
|
||||||
public function find($regexpPattern = '.*', $sort = false) {
|
public function find($regexpPattern = '.*', $sort = false) {
|
||||||
list($dirs, $files) = $this->read($sort);
|
list($dirs, $files) = $this->read($sort);
|
||||||
|
@ -193,6 +198,7 @@ class Folder {
|
||||||
* @param string $pattern Preg_match pattern (Defaults to: .*)
|
* @param string $pattern Preg_match pattern (Defaults to: .*)
|
||||||
* @param boolean $sort Whether results should be sorted.
|
* @param boolean $sort Whether results should be sorted.
|
||||||
* @return array Files matching $pattern
|
* @return array Files matching $pattern
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::findRecursive
|
||||||
*/
|
*/
|
||||||
public function findRecursive($pattern = '.*', $sort = false) {
|
public function findRecursive($pattern = '.*', $sort = false) {
|
||||||
if (!$this->pwd()) {
|
if (!$this->pwd()) {
|
||||||
|
@ -234,6 +240,7 @@ class Folder {
|
||||||
*
|
*
|
||||||
* @param string $path Path to check
|
* @param string $path Path to check
|
||||||
* @return boolean true if windows path, false otherwise
|
* @return boolean true if windows path, false otherwise
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::isWindowsPath
|
||||||
*/
|
*/
|
||||||
public static function isWindowsPath($path) {
|
public static function isWindowsPath($path) {
|
||||||
return (preg_match('/^[A-Z]:\\\\/i', $path) || substr($path, 0, 2) == '\\\\');
|
return (preg_match('/^[A-Z]:\\\\/i', $path) || substr($path, 0, 2) == '\\\\');
|
||||||
|
@ -244,6 +251,7 @@ class Folder {
|
||||||
*
|
*
|
||||||
* @param string $path Path to check
|
* @param string $path Path to check
|
||||||
* @return boolean true if path is absolute.
|
* @return boolean true if path is absolute.
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::isAbsolute
|
||||||
*/
|
*/
|
||||||
public static function isAbsolute($path) {
|
public static function isAbsolute($path) {
|
||||||
return !empty($path) && ($path[0] === '/' || preg_match('/^[A-Z]:\\\\/i', $path) || substr($path, 0, 2) == '\\\\');
|
return !empty($path) && ($path[0] === '/' || preg_match('/^[A-Z]:\\\\/i', $path) || substr($path, 0, 2) == '\\\\');
|
||||||
|
@ -254,6 +262,7 @@ class Folder {
|
||||||
*
|
*
|
||||||
* @param string $path Path to check
|
* @param string $path Path to check
|
||||||
* @return string Set of slashes ("\\" or "/")
|
* @return string Set of slashes ("\\" or "/")
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::normalizePath
|
||||||
*/
|
*/
|
||||||
public static function normalizePath($path) {
|
public static function normalizePath($path) {
|
||||||
return Folder::correctSlashFor($path);
|
return Folder::correctSlashFor($path);
|
||||||
|
@ -264,6 +273,7 @@ class Folder {
|
||||||
*
|
*
|
||||||
* @param string $path Path to check
|
* @param string $path Path to check
|
||||||
* @return string Set of slashes ("\\" or "/")
|
* @return string Set of slashes ("\\" or "/")
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::correctSlashFor
|
||||||
*/
|
*/
|
||||||
public static function correctSlashFor($path) {
|
public static function correctSlashFor($path) {
|
||||||
return (Folder::isWindowsPath($path)) ? '\\' : '/';
|
return (Folder::isWindowsPath($path)) ? '\\' : '/';
|
||||||
|
@ -274,6 +284,7 @@ class Folder {
|
||||||
*
|
*
|
||||||
* @param string $path Path to check
|
* @param string $path Path to check
|
||||||
* @return string Path with ending slash
|
* @return string Path with ending slash
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::slashTerm
|
||||||
*/
|
*/
|
||||||
public static function slashTerm($path) {
|
public static function slashTerm($path) {
|
||||||
if (Folder::isSlashTerm($path)) {
|
if (Folder::isSlashTerm($path)) {
|
||||||
|
@ -288,6 +299,7 @@ class Folder {
|
||||||
* @param string $path Path
|
* @param string $path Path
|
||||||
* @param string $element Element to and at end of path
|
* @param string $element Element to and at end of path
|
||||||
* @return string Combined path
|
* @return string Combined path
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::addPathElement
|
||||||
*/
|
*/
|
||||||
public static function addPathElement($path, $element) {
|
public static function addPathElement($path, $element) {
|
||||||
return rtrim($path, DS) . DS . $element;
|
return rtrim($path, DS) . DS . $element;
|
||||||
|
@ -298,6 +310,7 @@ class Folder {
|
||||||
*
|
*
|
||||||
* @param string $path The path to check.
|
* @param string $path The path to check.
|
||||||
* @return boolean
|
* @return boolean
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::inCakePath
|
||||||
*/
|
*/
|
||||||
public function inCakePath($path = '') {
|
public function inCakePath($path = '') {
|
||||||
$dir = substr(Folder::slashTerm(ROOT), 0, -1);
|
$dir = substr(Folder::slashTerm(ROOT), 0, -1);
|
||||||
|
@ -312,6 +325,7 @@ class Folder {
|
||||||
* @param string $path The path to check that the current pwd() resides with in.
|
* @param string $path The path to check that the current pwd() resides with in.
|
||||||
* @param boolean $reverse
|
* @param boolean $reverse
|
||||||
* @return boolean
|
* @return boolean
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::inPath
|
||||||
*/
|
*/
|
||||||
public function inPath($path = '', $reverse = false) {
|
public function inPath($path = '', $reverse = false) {
|
||||||
$dir = Folder::slashTerm($path);
|
$dir = Folder::slashTerm($path);
|
||||||
|
@ -333,6 +347,7 @@ class Folder {
|
||||||
* @param boolean $recursive chmod recursively, set to false to only change the current directory.
|
* @param boolean $recursive chmod recursively, set to false to only change the current directory.
|
||||||
* @param array $exceptions array of files, directories to skip
|
* @param array $exceptions array of files, directories to skip
|
||||||
* @return boolean Returns TRUE on success, FALSE on failure
|
* @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
|
||||||
*/
|
*/
|
||||||
public function chmod($path, $mode = false, $recursive = true, $exceptions = array()) {
|
public function chmod($path, $mode = false, $recursive = true, $exceptions = array()) {
|
||||||
if (!$mode) {
|
if (!$mode) {
|
||||||
|
@ -383,6 +398,7 @@ class Folder {
|
||||||
* @param mixed $exceptions Array of files to exclude, defaults to excluding hidden files.
|
* @param mixed $exceptions Array of files to exclude, defaults to excluding hidden files.
|
||||||
* @param string $type either file or dir. null returns both files and directories
|
* @param string $type either file or dir. null returns both files and directories
|
||||||
* @return mixed array of nested directories and files in each directory
|
* @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
|
||||||
*/
|
*/
|
||||||
public function tree($path = null, $exceptions = true, $type = null) {
|
public function tree($path = null, $exceptions = true, $type = null) {
|
||||||
if ($path == null) {
|
if ($path == null) {
|
||||||
|
@ -449,6 +465,7 @@ class Folder {
|
||||||
* @param string $pathname The directory structure to create
|
* @param string $pathname The directory structure to create
|
||||||
* @param integer $mode octal value 0755
|
* @param integer $mode octal value 0755
|
||||||
* @return boolean Returns TRUE on success, FALSE on failure
|
* @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
|
||||||
*/
|
*/
|
||||||
public function create($pathname, $mode = false) {
|
public function create($pathname, $mode = false) {
|
||||||
if (is_dir($pathname) || empty($pathname)) {
|
if (is_dir($pathname) || empty($pathname)) {
|
||||||
|
@ -487,6 +504,7 @@ class Folder {
|
||||||
* Returns the size in bytes of this Folder and its contents.
|
* Returns the size in bytes of this Folder and its contents.
|
||||||
*
|
*
|
||||||
* @return integer size in bytes of current folder
|
* @return integer size in bytes of current folder
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::dirsize
|
||||||
*/
|
*/
|
||||||
public function dirsize() {
|
public function dirsize() {
|
||||||
$size = 0;
|
$size = 0;
|
||||||
|
@ -523,6 +541,7 @@ class Folder {
|
||||||
*
|
*
|
||||||
* @param string $path Path of directory to delete
|
* @param string $path Path of directory to delete
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::delete
|
||||||
*/
|
*/
|
||||||
public function delete($path = null) {
|
public function delete($path = null) {
|
||||||
if (!$path) {
|
if (!$path) {
|
||||||
|
@ -579,6 +598,7 @@ class Folder {
|
||||||
*
|
*
|
||||||
* @param mixed $options Either an array of options (see above) or a string of the destination directory.
|
* @param mixed $options Either an array of options (see above) or a string of the destination directory.
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::copy
|
||||||
*/
|
*/
|
||||||
public function copy($options = array()) {
|
public function copy($options = array()) {
|
||||||
if (!$this->pwd()) {
|
if (!$this->pwd()) {
|
||||||
|
@ -664,6 +684,7 @@ class Folder {
|
||||||
*
|
*
|
||||||
* @param array $options (to, from, chmod, skip)
|
* @param array $options (to, from, chmod, skip)
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::move
|
||||||
*/
|
*/
|
||||||
public function move($options) {
|
public function move($options) {
|
||||||
$to = null;
|
$to = null;
|
||||||
|
@ -688,6 +709,7 @@ class Folder {
|
||||||
* get messages from latest method
|
* get messages from latest method
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::messages
|
||||||
*/
|
*/
|
||||||
public function messages() {
|
public function messages() {
|
||||||
return $this->_messages;
|
return $this->_messages;
|
||||||
|
@ -697,6 +719,7 @@ class Folder {
|
||||||
* get error from latest method
|
* get error from latest method
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::errors
|
||||||
*/
|
*/
|
||||||
public function errors() {
|
public function errors() {
|
||||||
return $this->_errors;
|
return $this->_errors;
|
||||||
|
@ -707,6 +730,7 @@ class Folder {
|
||||||
*
|
*
|
||||||
* @param string $path Path to resolve
|
* @param string $path Path to resolve
|
||||||
* @return string The resolved path
|
* @return string The resolved path
|
||||||
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::realpath
|
||||||
*/
|
*/
|
||||||
public function realpath($path) {
|
public function realpath($path) {
|
||||||
$path = str_replace('/', DS, trim($path));
|
$path = str_replace('/', DS, trim($path));
|
||||||
|
@ -747,6 +771,7 @@ class Folder {
|
||||||
*
|
*
|
||||||
* @param string $path Path to check
|
* @param string $path Path to check
|
||||||
* @return boolean true if path ends with slash, false otherwise
|
* @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
|
||||||
*/
|
*/
|
||||||
public static function isSlashTerm($path) {
|
public static function isSlashTerm($path) {
|
||||||
$lastChar = $path[strlen($path) - 1];
|
$lastChar = $path[strlen($path) - 1];
|
||||||
|
|
Loading…
Reference in a new issue