Browse files

Removed constant available only in php 5.3 and changed exception type…

… to fix errors on php 5.2. Fixes #2487
  • Loading branch information...
1 parent 2a9e677 commit d61b6dc7d348414ab084cf6487a41a57ee2d8c89 @ADmad ADmad committed Jan 19, 2012
Showing with 7 additions and 7 deletions.
  1. +7 −7 lib/Cake/Utility/Folder.php
View
14 lib/Cake/Utility/Folder.php
@@ -154,7 +154,7 @@ public function read($sort = true, $exceptions = false, $fullPath = false) {
try {
$iterator = new DirectoryIterator($this->path);
- } catch (UnexpectedValueException $e) {
+ } catch (Exception $e) {
return array($dirs, $files);
}
@@ -427,9 +427,9 @@ public function tree($path = null, $exceptions = false, $type = null) {
}
try {
- $directory = new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::KEY_AS_PATHNAME | RecursiveDirectoryIterator::CURRENT_AS_SELF | RecursiveDirectoryIterator::SKIP_DOTS);
+ $directory = new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::KEY_AS_PATHNAME | RecursiveDirectoryIterator::CURRENT_AS_SELF);
$iterator = new RecursiveIteratorIterator($directory, RecursiveIteratorIterator::SELF_FIRST);
- } catch (UnexpectedValueException $e) {
+ } catch (Exception $e) {
if ($type === null) {
return array(array(), array());
}
@@ -450,7 +450,7 @@ public function tree($path = null, $exceptions = false, $type = null) {
if ($item->isFile()) {
$files[] = $itemPath;
- } elseif ($item->isDir()) {
+ } elseif ($item->isDir() && !$item->isDot()) {
$directories[] = $itemPath;
}
}
@@ -558,9 +558,9 @@ public function delete($path = null) {
$path = Folder::slashTerm($path);
if (is_dir($path)) {
try {
- $directory = new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS);
+ $directory = new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::CURRENT_AS_SELF);
$iterator = new RecursiveIteratorIterator($directory, RecursiveIteratorIterator::CHILD_FIRST);
- } catch (UnexpectedValueException $e) {
+ } catch (Exception $e) {
return false;
}
@@ -572,7 +572,7 @@ public function delete($path = null) {
} else {
$this->_errors[] = __d('cake_dev', '%s NOT removed', $filePath);
}
- } elseif ($item->isDir()) {
+ } elseif ($item->isDir() && !$item->isDot()) {
if (@rmdir($filePath)) {
$this->_messages[] = __d('cake_dev', '%s removed', $filePath);
} else {

0 comments on commit d61b6dc

Please sign in to comment.