]> granicus.if.org Git - php/commitdiff
Add missing files
authorMarcus Boerger <helly@php.net>
Sat, 22 Nov 2003 20:52:06 +0000 (20:52 +0000)
committerMarcus Boerger <helly@php.net>
Sat, 22 Nov 2003 20:52:06 +0000 (20:52 +0000)
ext/spl/examples/directorygraphiterator.inc [new file with mode: 0644]
ext/spl/examples/parentiterator.inc [new file with mode: 0644]

diff --git a/ext/spl/examples/directorygraphiterator.inc b/ext/spl/examples/directorygraphiterator.inc
new file mode 100644 (file)
index 0000000..190aba9
--- /dev/null
@@ -0,0 +1,11 @@
+<?php
+
+class DirectoryGraphIterator extends DirectoryTreeIterator
+{
+       function __construct($path)
+       {
+               RecursiveIteratorIterator::__construct(new CachingRecursiveIterator(new ParentIterator(new RecursiveDirectoryIterator($path)), true), 1);
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/ext/spl/examples/parentiterator.inc b/ext/spl/examples/parentiterator.inc
new file mode 100644 (file)
index 0000000..74299ee
--- /dev/null
@@ -0,0 +1,21 @@
+<?php
+
+class ParentIterator extends FilterIterator implements RecursiveIterator
+{
+       function accept()
+       {
+               return $this->it->hasChildren();
+       }
+
+       function hasChildren()
+       {
+               return $this->it->hasChildren();
+       }
+
+       function getChildren()
+       {
+               return new ParentIterator($this->it->getChildren());
+       }
+}
+
+?>
\ No newline at end of file