{
protected $hasChildren;
protected $getChildren;
+ protected $catch_get_child_exceptions;
- function __construct(RecursiveIterator $it) {
+ function __construct(RecursiveIterator $it, $catch_get_child_exceptions = false) {
+ $this->catch_get_child_exceptions = $catch_get_child_exceptions;
parent::__construct($it);
}
function next() {
if ($this->hasChildren = $this->it->hasChildren()) {
- $this->getChildren = new CachingRecursiveIterator($this->it->getChildren());
+ try {
+ //$this->getChildren = new CachingRecursiveIterator($this->it->getChildren(), $this->catch_get_child_exceptions);
+ // workaround memleaks...
+ $child = $this->it->getChildren();
+ $this->getChildren = new CachingRecursiveIterator($child, $this->catch_get_child_exceptions);
+ }
+ catch(Exception $e) {
+ if (!$this->catch_get_child_exceptions) {
+ throw $e;
+ }
+ $this->hasChildren = false;
+ $this->getChildren = NULL;
+ }
} else {
$this->getChildren = NULL;
}
{
function __construct($path)
{
- parent::__construct(new CachingRecursiveIterator(new RecursiveDirectoryIterator($path)), 1);
+ parent::__construct(new CachingRecursiveIterator(new RecursiveDirectoryIterator($path), true), 1);
}
function current()