--- /dev/null
+<?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
--- /dev/null
+<?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