|
|
@@ -13,6 +13,8 @@ class FolderLib extends Folder {
|
|
|
* Instead of deleting the folder itself as delete() does,
|
|
|
* this method only removes its content recursivly.
|
|
|
*
|
|
|
+ * Note: It skips hidden folders (starting with a . dot).
|
|
|
+ *
|
|
|
* @return boolean Success or null on invalid folder
|
|
|
* 2010-12-07 ms
|
|
|
*/
|
|
|
@@ -24,33 +26,29 @@ class FolderLib extends Folder {
|
|
|
return null;
|
|
|
}
|
|
|
$path = Folder::slashTerm($path);
|
|
|
- if (is_dir($path)) {
|
|
|
- $normalFiles = glob($path . '*');
|
|
|
- $hiddenFiles = glob($path . '\.?*');
|
|
|
+ if (!is_dir($path)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ $normalFiles = glob($path . '*');
|
|
|
+ $hiddenFiles = glob($path . '\.?*');
|
|
|
|
|
|
- $normalFiles = $normalFiles ? $normalFiles : array();
|
|
|
- $hiddenFiles = $hiddenFiles ? $hiddenFiles : array();
|
|
|
+ $normalFiles = $normalFiles ? $normalFiles : array();
|
|
|
+ $hiddenFiles = $hiddenFiles ? $hiddenFiles : array();
|
|
|
|
|
|
- $files = array_merge($normalFiles, $hiddenFiles);
|
|
|
- if (is_array($files)) {
|
|
|
- foreach ($files as $file) {
|
|
|
- if (preg_match('/(\.|\.\.)$/', $file)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- chmod($file, 0770);
|
|
|
- if (is_file($file)) {
|
|
|
- if (@unlink($file)) {
|
|
|
- $this->_messages[] = __('%s removed', $file);
|
|
|
- } else {
|
|
|
- $this->_errors[] = __('%s NOT removed', $file);
|
|
|
- }
|
|
|
- } elseif (is_dir($file) && $this->delete($file) === false) {
|
|
|
- return false;
|
|
|
- }
|
|
|
+ $files = array_merge($normalFiles, $hiddenFiles);
|
|
|
+ foreach ($files as $file) {
|
|
|
+ if (preg_match('/(\.|\.\.)$/', $file)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (is_file($file)) {
|
|
|
+ if (@unlink($file)) {
|
|
|
+ $this->_messages[] = __('%s removed', $file);
|
|
|
+ } else {
|
|
|
+ $this->_errors[] = __('%s NOT removed', $file);
|
|
|
}
|
|
|
+ } elseif (is_dir($file) && $this->delete($file) === false) {
|
|
|
+ return false;
|
|
|
}
|
|
|
- } else {
|
|
|
- unlink($path);
|
|
|
}
|
|
|
return true;
|
|
|
}
|