diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2014-06-23 15:33:55 +0400 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2014-06-23 15:54:27 +0400 |
commit | f83821c388120eda258a968cc6be3e1a875ce34c (patch) | |
tree | 35ced3b488f929d40694243c663fc611a86d5527 /lib/private/helper.php | |
parent | 65e4348080c81282b1a700f093fc4b880db60c50 (diff) |
fix recursion on rmdirr
Diffstat (limited to 'lib/private/helper.php')
-rw-r--r-- | lib/private/helper.php | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/private/helper.php b/lib/private/helper.php index 243baa46948..206c20d9169 100644 --- a/lib/private/helper.php +++ b/lib/private/helper.php @@ -405,15 +405,19 @@ class OC_Helper { */ static function rmdirr($dir) { if (is_dir($dir)) { - $files = scandir($dir); - // FIXME: use flat array instead of recursion to avoid - // too many levels - foreach ($files as $file) { - if ($file !== '' && $file !== "." && $file !== "..") { - self::rmdirr("$dir/$file"); + $files = new RecursiveIteratorIterator( + new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS), + RecursiveIteratorIterator::CHILD_FIRST + ); + + foreach ($files as $fileInfo) { + /** @var FilesystemIterator $fileInfo */ + if ($fileInfo->isDir()) { + rmdir($fileInfo->getRealPath()); + } else { + unlink($fileInfo->getRealPath()); } } - rmdir($dir); } elseif (file_exists($dir)) { unlink($dir); } |