summaryrefslogtreecommitdiff
path: root/ext/spl/examples
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2004-11-01 22:31:11 +0000
committerMarcus Boerger <helly@php.net>2004-11-01 22:31:11 +0000
commit36a9455a48ef2902894f0b8641d6b339332ac7ff (patch)
tree5feacf7e1443035d6da1a0fd9c775f284a8713d6 /ext/spl/examples
parentc18e248e606f87c92bf1c06239fa2b85650bc432 (diff)
downloadphp-git-36a9455a48ef2902894f0b8641d6b339332ac7ff.tar.gz
- Update examples
Diffstat (limited to 'ext/spl/examples')
-rw-r--r--ext/spl/examples/directorygraphiterator.inc25
-rwxr-xr-xext/spl/examples/tree.php3
2 files changed, 27 insertions, 1 deletions
diff --git a/ext/spl/examples/directorygraphiterator.inc b/ext/spl/examples/directorygraphiterator.inc
new file mode 100644
index 0000000000..6847de4a19
--- /dev/null
+++ b/ext/spl/examples/directorygraphiterator.inc
@@ -0,0 +1,25 @@
+<?php
+
+/** @file directorygraphiterator.inc
+ * @ingroup Examples
+ * @brief class DirectoryGraphIterator
+ * @author Marcus Boerger
+ * @date 2003 - 2004
+ *
+ * SPL - Standard PHP Library
+ */
+
+/** @ingroup Examples
+ * @brief A tree iterator that only shows directories.
+ * @author Marcus Boerger
+ * @version 1.0
+ */
+class DirectoryGraphIterator extends DirectoryTreeIterator
+{
+ function __construct($path)
+ {
+ RecursiveIteratorIterator::__construct(new CachingRecursiveIterator(new ParentIterator(new RecursiveDirectoryIterator($path)), CIT_CALL_TOSTRING|CIT_CATCH_GET_CHILD), 1);
+ }
+}
+
+?> \ No newline at end of file
diff --git a/ext/spl/examples/tree.php b/ext/spl/examples/tree.php
index a9f6d8beaf..d7a321dffc 100755
--- a/ext/spl/examples/tree.php
+++ b/ext/spl/examples/tree.php
@@ -29,9 +29,10 @@ EOF;
}
if (!class_exists("DirectoryTreeIterator", false)) require_once("directorytreeiterator.inc");
+if (!class_exists("DirectoryGraphIterator", false)) require_once("directorygraphiterator.inc");
echo $argv[1]."\n";
-foreach(new DirectoryTreeIterator($argv[1]) as $file)
+foreach(new DirectoryGraphIterator($argv[1]) as $file)
{
echo $file . "\n";
}