note 54668 added to ref.spl

From: Date: Tue, 12 Jul 2005 11:57:59 +0000
Subject: note 54668 added to ref.spl
Groups: php.notes 
Request: Send a blank email to php-notes+get-91797@lists.php.net to get a copy of this message
In addition to "mastabog at hotmail dot com"`s note about the recursive directory iterator, his method skips symlinked directories, because getChildren() doesn't return true if the directory is symlinked. To fix this, the script should always instanciate an innerInterator when dealing with symlinked directories like so: <? class DirectoriesOnlyIterator extends FilterIterator implements RecursiveIterator { public function __construct ($path) { parent::__construct(new RecursiveDirectoryIterator($path)); } public function accept() { return $this->getInnerIterator()->hasChildren(); } public function hasChildren () { return $this->hasChildren() || $this->isLink(); } public function getChildren () { return new self($this->getInnerIterator()->getPathname()); } } ---- Manual Page -- http://www.php.net/manual/en/ref.spl.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+54668 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54668&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54668&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54668&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54668&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54668&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54668&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+54668&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#91797) next »