#37070 [Opn->Bgs]: SplFileObject::isDir() returns false for empty dirs

From: Date: Thu, 13 Apr 2006 12:29:58 +0000
Subject: #37070 [Opn->Bgs]: SplFileObject::isDir() returns false for empty dirs
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-95747@lists.php.net to get a copy of this message
ID: 37070 User updated by: pornel at despammed dot com Reported By: pornel at despammed dot com -Status: Open +Status: Bogus Bug Type: SPL related Operating System: OS X PHP Version: 6CVS-2006-04-13 (snap) New Comment: My bad. Confused getPath with getPathname. Previous Comments: ------------------------------------------------------------------------ [2006-04-13 12:19:28] pornel at despammed dot com Description: ------------ I'm using RecursiveDirectoryIterator to scan directories. File objects returned by this iterator seem to threat isDir and hasChildren as the same thing. That is isDir returns true only when item has children. This assumption is invalid and causes empty directories to be reported as files. Reproduce code: --------------- <?php function scan(RecursiveDirectoryIterator $dir) { foreach($dir as $file) { var_dump($file->isDir()); if ($dir->hasChildren()) scan($dir->getChildren()); } } scan(new RecursiveDirectoryIterator('/some/path/that/has/empty/dirs')); Expected result: ---------------- isDir should not act as alias of hasChildren Actual result: -------------- empty directories have isFile()==true and isDir()==false ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=37070&edit=1

« previous php.bugs (#95747) next »