Revision 1676
Added by Dietmar over 12 years ago
functions.php | ||
---|---|---|
30 | 30 |
* @param string $directory : |
31 | 31 |
* @param bool $empty : true if you want the folder just emptied, but not deleted |
32 | 32 |
* false, or just simply leave it out, the given directory will be deleted, as well |
33 |
* @return boolean: list of ro-dirs
|
|
33 |
* @return boolean: true/false
|
|
34 | 34 |
* @from http://www.php.net/manual/de/function.rmdir.php#98499 |
35 | 35 |
*/ |
36 |
function rm_full_dir($directory, $empty = false) {
|
|
37 |
|
|
36 |
function rm_full_dir($directory, $empty = false) |
|
37 |
{ |
|
38 | 38 |
if(substr($directory,-1) == "/") { |
39 | 39 |
$directory = substr($directory,0,-1); |
40 | 40 |
} |
41 | 41 |
// If suplied dirname is a file then unlink it |
42 |
if (is_file( $directory )) { |
|
42 |
if (is_file( $directory )&& is_writable( $directory )) {
|
|
43 | 43 |
$retval = unlink($directory); |
44 | 44 |
clearstatcache(); |
45 | 45 |
return $retval; |
46 | 46 |
} |
47 |
if(!file_exists($directory) || !is_dir($directory)) {
|
|
47 |
if(!is_writable($directory) || !is_dir($directory)) {
|
|
48 | 48 |
return false; |
49 | 49 |
} elseif(!is_readable($directory)) { |
50 | 50 |
return false; |
... | ... | |
65 | 65 |
} |
66 | 66 |
closedir($directoryHandle); |
67 | 67 |
if($empty == false) { |
68 |
if(!rmdir($directory)) { |
|
69 |
return false; |
|
68 |
if(is_dir($directory) && is_writable(dirname($directory))) { |
|
69 |
return rmdir($directory); |
|
70 |
} else { |
|
71 |
return false; |
|
70 | 72 |
} |
71 | 73 |
} |
72 | 74 |
return true; |
... | ... | |
419 | 421 |
* the function also prevents the owner to loose rw-rights |
420 | 422 |
* @param string $sName |
421 | 423 |
* @param int rights in dec-value. 0= use wb-defaults |
422 |
* @return bool
|
|
424 |
* @return bool |
|
423 | 425 |
*/ |
424 | 426 |
function change_mode($sName, $iMode = 0) |
425 | 427 |
{ |
Also available in: Unified diff
! update function rm_full_dir in /framework/functions.php
! To disable Run-time notices and receive warnings