Permalink
Browse files

Fix Folder::tree() when excluding dot files or folders.

When 'exclude' param is array('.') files/folders are not skipped. Added test.
  • Loading branch information...
1 parent 1dbafe1 commit c40d132f815f8abb422e59ef30d1c86466a99c2d @majna majna committed Feb 17, 2012
Showing with 4 additions and 5 deletions.
  1. +3 −0 lib/Cake/Test/Case/Utility/FolderTest.php
  2. +1 −5 lib/Cake/Utility/Folder.php
@@ -476,6 +476,9 @@ public function testFolderTreeWithHiddenFiles() {
$result = $Folder->tree(null, true);
$this->assertEquals($expected, $result);
+ $result = $Folder->tree(null, array('.'));
+ $this->assertEquals($expected, $result);
+
$expected = array(
array(
$Folder->path,
@@ -413,10 +413,6 @@ public function tree($path = null, $exceptions = false, $type = null) {
if (is_array($exceptions)) {
$exceptions = array_flip($exceptions);
- if (isset($exceptions['.'])) {
- $skipHidden = true;
- unset($exceptions['.']);
- }
}
$skipHidden = false;
if ($exceptions === true) {
@@ -435,7 +431,7 @@ public function tree($path = null, $exceptions = false, $type = null) {
}
return array();
}
- $pathLength = strlen($path);
+
foreach ($iterator as $itemPath => $fsIterator) {
if ($skipHidden) {
$subPathName = $fsIterator->getSubPathname();

0 comments on commit c40d132

Please sign in to comment.