summaryrefslogtreecommitdiff
path: root/ext/spl/examples/cachingrecursiveiterator.inc
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2003-11-19 00:18:30 +0000
committerMarcus Boerger <helly@php.net>2003-11-19 00:18:30 +0000
commita16ca5a1c283f2410120b3fe771b0b7948c8acb7 (patch)
treeaaeb233890e9501dc5c2f3e23ee02c0782ec34cf /ext/spl/examples/cachingrecursiveiterator.inc
parent9964911cb730fb7e0a8e04342ecf59639a105d07 (diff)
downloadphp-git-a16ca5a1c283f2410120b3fe771b0b7948c8acb7.tar.gz
Dont't stop if directory can't be openedbecause of user rights etc
Diffstat (limited to 'ext/spl/examples/cachingrecursiveiterator.inc')
-rw-r--r--ext/spl/examples/cachingrecursiveiterator.inc18
1 files changed, 16 insertions, 2 deletions
diff --git a/ext/spl/examples/cachingrecursiveiterator.inc b/ext/spl/examples/cachingrecursiveiterator.inc
index cb89fdb6d8..55acd1e195 100644
--- a/ext/spl/examples/cachingrecursiveiterator.inc
+++ b/ext/spl/examples/cachingrecursiveiterator.inc
@@ -4,14 +4,28 @@ class CachingRecursiveIterator extends CachingIterator implements RecursiveItera
{
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;
}