note 101654 modified in class.recursivedirectoryiterator by aharvey
| From: | aharvey@php.net | Date: | Wed, 19 Dec 2012 01:19:27 +0000 |
| Subject: | note 101654 modified in class.recursivedirectoryiterator by aharvey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-192592@lists.php.net to get a copy of this message | ||
If you use RecursiveDirectoryIterator with RecursiveIteratorIterator and run into
UnexpectedValueException you may use this little hack to ignore those directories, such as
lost+found on linux.
<?php
class IgnorantRecursiveDirectoryIterator extends RecursiveDirectoryIterator {
function getChildren() {
try {
return new IgnorantRecursiveDirectoryIterator($this->getPathname());
} catch(UnexpectedValueException $e) {
return new RecursiveArrayIterator(array());
}
}
}
?>
Use just like the normal RecursiveDirectoryIterator.
--was--
If you use RecursiveDirectoryIterator with RecursiveIteratorIterator and run into
UnexpectedValueException you may use this little hack to ignore those directories, such as
lost+found on linux.
<?php
class IgnorantRecursiveDirectoryIterator extends RecursiveDirectoryIterator {
function getChildren() {
try {
return parent::getChildren();
} catch(UnexpectedValueException $e) {
return new RecursiveArrayIterator(array());
}
}
}
?>
Use just like the normal RecursiveDirectoryIterator.
http://php.net/manual/en/class.recursivedirectoryiterator.php