mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Removing unused function Folder::_tree(). Added exception handling in Folder::delete().
This commit is contained in:
parent
389072708a
commit
b84c9a1aaa
1 changed files with 11 additions and 19 deletions
|
@ -459,20 +459,6 @@ class Folder {
|
|||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Private method to list directories and files in each directory
|
||||
*
|
||||
* @param string $path The Path to read.
|
||||
* @param mixed $exceptions Array of files to exclude from the read that will be performed.
|
||||
* @return void
|
||||
*/
|
||||
protected function _tree($path, $exceptions) {
|
||||
$this->path = $path;
|
||||
list($dirs, $files) = $this->read(false, $exceptions, true);
|
||||
$this->_directories = array_merge($this->_directories, $dirs);
|
||||
$this->_files = array_merge($this->_files, $files);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a directory structure recursively. Can be used to create
|
||||
* deep path structures like `/foo/bar/baz/shoe/horn`
|
||||
|
@ -567,16 +553,22 @@ class Folder {
|
|||
}
|
||||
$path = Folder::slashTerm($path);
|
||||
if (is_dir($path)) {
|
||||
$iterator = new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS);
|
||||
foreach (new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::CHILD_FIRST) as $file) {
|
||||
$filePath = $file->getPathname();
|
||||
if ($file->isFile() || $file->isLink()) {
|
||||
try {
|
||||
$directory = new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS);
|
||||
$iterator = new RecursiveIteratorIterator($directory, RecursiveIteratorIterator::CHILD_FIRST);
|
||||
} catch (UnexpectedValueException $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($iterator as $item) {
|
||||
$filePath = $item->getPathname();
|
||||
if ($item->isFile() || $item->isLink()) {
|
||||
if (@unlink($filePath)) {
|
||||
$this->_messages[] = __d('cake_dev', '%s removed', $filePath);
|
||||
} else {
|
||||
$this->_errors[] = __d('cake_dev', '%s NOT removed', $filePath);
|
||||
}
|
||||
} elseif ($file->isDir()) {
|
||||
} elseif ($item->isDir()) {
|
||||
if (@rmdir($filePath)) {
|
||||
$this->_messages[] = __d('cake_dev', '%s removed', $filePath);
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue