helly Tue Nov 18 19:18:30 2003 EDT Modified files: /spl/examples cachingrecursiveiterator.inc directorytreeiterator.inc Log: Dont't stop if directory can't be openedbecause of user rights etc Index: spl/examples/cachingrecursiveiterator.inc diff -u spl/examples/cachingrecursiveiterator.inc:1.1 spl/examples/cachingrecursiveiterator.inc:1.2 --- spl/examples/cachingrecursiveiterator.inc:1.1 Tue Nov 18 17:18:38 2003 +++ spl/examples/cachingrecursiveiterator.inc Tue Nov 18 19:18:30 2003 @@ -4,14 +4,28 @@ { 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; } Index: spl/examples/directorytreeiterator.inc diff -u spl/examples/directorytreeiterator.inc:1.2 spl/examples/directorytreeiterator.inc:1.3 --- spl/examples/directorytreeiterator.inc:1.2 Tue Nov 18 17:34:51 2003 +++ spl/examples/directorytreeiterator.inc Tue Nov 18 19:18:30 2003 @@ -4,7 +4,7 @@ { function __construct($path) { - parent::__construct(new CachingRecursiveIterator(new RecursiveDirectoryIterator($path)), 1); + parent::__construct(new CachingRecursiveIterator(new RecursiveDirectoryIterator($path), true), 1); } function current()
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php