mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Adding Folder::rmdir().
Removed empty lines from basics file git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4101 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
b5face3516
commit
b8a46e14d7
2 changed files with 34 additions and 7 deletions
|
@ -1217,11 +1217,11 @@
|
|||
if (!function_exists('array_diff_key')) {
|
||||
function array_diff_key() {
|
||||
$valuesDiff = array();
|
||||
|
||||
|
||||
if (func_num_args() < 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
foreach (func_get_args() as $param) {
|
||||
if (!is_array($param)) {
|
||||
return false;
|
||||
|
|
|
@ -117,7 +117,7 @@ class Folder extends Object{
|
|||
sort ($files);
|
||||
}
|
||||
closedir ($dir);
|
||||
}
|
||||
}
|
||||
return array($dirs,$files);
|
||||
}
|
||||
/**
|
||||
|
@ -164,7 +164,7 @@ class Folder extends Object{
|
|||
*/
|
||||
function _findRecursive($pattern) {
|
||||
list($dirs, $files) = $this->ls();
|
||||
|
||||
|
||||
$found = array();
|
||||
foreach($files as $file) {
|
||||
if (preg_match("/^{$pattern}$/i", $file)) {
|
||||
|
@ -281,9 +281,9 @@ function slashTerm($path) {
|
|||
trigger_error('chmodr() File exists', E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$nextPathname = substr($pathname, 0, strrpos($pathname, DS));
|
||||
|
||||
|
||||
if ($this->chmodr($nextPathname, $mode)) {
|
||||
if(file_exists($pathname)) {
|
||||
umask (0);
|
||||
|
@ -292,7 +292,7 @@ function slashTerm($path) {
|
|||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Create a directory structure recursively.
|
||||
*
|
||||
|
@ -352,5 +352,32 @@ function slashTerm($path) {
|
|||
}
|
||||
return $size;
|
||||
}
|
||||
/**
|
||||
* Recursively Remove directories if system allow.
|
||||
*
|
||||
* @param string $path
|
||||
* @return boolean
|
||||
*/
|
||||
function rmdir($path) {
|
||||
if (substr($path, -1, 1) != "/") {
|
||||
$path .= "/";
|
||||
}
|
||||
foreach (glob($path . "*") as $file) {
|
||||
if (is_file($file) === true) {
|
||||
@unlink($file);
|
||||
}
|
||||
elseif (is_dir($file) === true) {
|
||||
if($this->rmdir($file) === false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is_dir($path) === true) {
|
||||
if(rmdir($path) === false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in a new issue