cvs: spl /examples cachingiterator.inc cachingrecursiveiterator.inc dba_array.php dba_dump.php dba_reader.inc directorytree.php
directorytreeiterator.inc findfile.php key_filter.inc recursiveiteratoriterator.inc tree.php
| From: | Marcus Boerger | Date: | Sat, 22 Nov 2003 20:51:16 +0000 |
| Subject: | cvs: spl /examples cachingiterator.inc cachingrecursiveiterator.inc dba_array.php dba_dump.php dba_reader.inc directorytree.php directorytreeiterator.inc findfile.php key_filter.inc recursiveiteratoriterator.inc tree.php |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-24627@lists.php.net to get a copy of this message | ||
helly Sat Nov 22 15:51:16 2003 EDT
Modified files:
/spl/examples cachingiterator.inc cachingrecursiveiterator.inc
dba_array.php dba_dump.php dba_reader.inc
directorytree.php directorytreeiterator.inc
findfile.php key_filter.inc
recursiveiteratoriterator.inc tree.php
Log:
Update examples
Index: spl/examples/cachingiterator.inc diff -u spl/examples/cachingiterator.inc:1.1 spl/examples/cachingiterator.inc:1.2 --- spl/examples/cachingiterator.inc:1.1 Tue Nov 18 17:18:38 2003 +++ spl/examples/cachingiterator.inc Sat Nov 22 15:51:15 2003 @@ -8,16 +8,19 @@ protected $more; protected $strvalue; - function __construct(Iterator $it) { + function __construct(Iterator $it) + { $this->it = $it; } - function rewind() { + function rewind() + { $this->it->rewind(); $this->next(); } - function next() { + function next() + { if ($this->more = $this->it->hasMore()) { $this->current = $this->it->current(); $this->key = $this->it->key(); @@ -30,27 +33,33 @@ $this->it->next(); } - function hasMore() { + function hasMore() + { return $this->more; } - function hasNext() { + function hasNext() + { return $this->it->hasMore(); } - function current() { + function current() + { return $this->current; } - function key() { + function key() + { return $this->key; } - function __call($func, $params) { + function __call($func, $params) + { return call_user_func_array(array($this->it, $func), $params); } - function __toString() { + function __toString() + { return $this->strvalue; } } Index: spl/examples/cachingrecursiveiterator.inc diff -u spl/examples/cachingrecursiveiterator.inc:1.2 spl/examples/cachingrecursiveiterator.inc:1.3 --- spl/examples/cachingrecursiveiterator.inc:1.2 Tue Nov 18 19:18:30 2003 +++ spl/examples/cachingrecursiveiterator.inc Sat Nov 22 15:51:15 2003 @@ -4,23 +4,25 @@ { protected $hasChildren; protected $getChildren; - protected $catch_get_child_exceptions; + protected $catch_get_child; - function __construct(RecursiveIterator $it, $catch_get_child_exceptions = false) { - $this->catch_get_child_exceptions = $catch_get_child_exceptions; + function __construct(RecursiveIterator $it, $catch_get_child = false) + { + $this->catch_get_child = $catch_get_child; parent::__construct($it); } - function next() { + function next() + { if ($this->hasChildren = $this->it->hasChildren()) { try { - //$this->getChildren = new CachingRecursiveIterator($this->it->getChildren(), $this->catch_get_child_exceptions); + //$this->getChildren = new CachingRecursiveIterator($this->it->getChildren(), $this->catch_get_child); // workaround memleaks... $child = $this->it->getChildren(); - $this->getChildren = new CachingRecursiveIterator($child, $this->catch_get_child_exceptions); + $this->getChildren = new CachingRecursiveIterator($child, $this->catch_get_child); } catch(Exception $e) { - if (!$this->catch_get_child_exceptions) { + if (!$this->catch_get_child) { throw $e; } $this->hasChildren = false; @@ -32,11 +34,13 @@ parent::next(); } - function hasChildren() { + function hasChildren() + { return $this->hasChildren; } - function getChildren() { + function getChildren() + { return $this->getChildren; } } Index: spl/examples/dba_array.php diff -u spl/examples/dba_array.php:1.1 spl/examples/dba_array.php:1.2 --- spl/examples/dba_array.php:1.1 Sun Jun 22 11:48:44 2003 +++ spl/examples/dba_array.php Sat Nov 22 15:51:15 2003 @@ -12,7 +12,7 @@ * (c) Marcus Boerger */ -class dba_array implements spl_array_access { +class DbaArray implements ArrayAccess { private $db; function __construct($file, $handler) @@ -35,7 +35,8 @@ if (ini_get('magic_quotes_runtime')) { $data = stripslashes($data); } - return unserialize($data); + //return unserialize($data); + return $data; } else { @@ -45,7 +46,8 @@ function set($name, $value) { - dba_replace($name, serialize($value), $this->db); + //dba_replace($name, serialize($value), $this->db); + dba_replace($name, $value, $this->db); return $value; } @@ -53,18 +55,23 @@ { return dba_exists($name, $this->db); } + + function del($name) + { + return dba_delete($name, $this->db); + } } try { if ($argc > 2) { - $dba = new dba_array($argv[1], $argv[2]); + $dba = new DbaArray($argv[1], $argv[2]); if ($dba && $argc > 3) { if ($argc > 4) { $dba[$argv[3]] = $argv[4]; } var_dump(array('Index' => $argv[3], 'Value' => $dba[$argv[3]])); } - $dba = NULL; + unset($dba); } else { Index: spl/examples/dba_dump.php diff -u spl/examples/dba_dump.php:1.3 spl/examples/dba_dump.php:1.4 --- spl/examples/dba_dump.php:1.3 Wed Jul 16 17:51:09 2003 +++ spl/examples/dba_dump.php Sat Nov 22 15:51:15 2003 @@ -15,10 +15,10 @@ require_once("dba_reader.inc"); require_once("key_filter.inc"); -$db = new dba_reader($argv[1], $argv[2]); +$db = new DbaReader($argv[1], $argv[2]); if ($argc>3) { - $db = new key_filter($db, $argv[3]); + $db = new keyFilter($db, $argv[3]); } foreach($db as $key => $val) { Index: spl/examples/dba_reader.inc diff -u spl/examples/dba_reader.inc:1.2 spl/examples/dba_reader.inc:1.3 --- spl/examples/dba_reader.inc:1.2 Thu Sep 4 10:44:54 2003 +++ spl/examples/dba_reader.inc Sat Nov 22 15:51:15 2003 @@ -1,11 +1,11 @@ <?php /** - * @brief This implements an dba iterator. + * @brief This implements a Dba Iterator. * @author Marcus Boerger * @version 1.0 */ -class dba_reader implements spl_sequence_assoc +class DbaReader implements Iterator { private $db = NULL; Index: spl/examples/directorytree.php diff -u spl/examples/directorytree.php:1.3 spl/examples/directorytree.php:1.4 --- spl/examples/directorytree.php:1.3 Tue Nov 18 17:18:38 2003 +++ spl/examples/directorytree.php Sat Nov 22 15:51:15 2003 @@ -11,8 +11,8 @@ $length = $argc > 3 ? $argv[3] : NULL; -foreach(new LimitIterator(new DirectoryTreeIterator($argv[1]), @$argv[2], $length) as $pathname => $file) { - echo "$file\n"; +foreach(new LimitIterator(new DirectoryTreeIterator($argv[1]), @$argv[2], $length) as $file) { + echo $file ."\n"; } ?> \ No newline at end of file Index: spl/examples/directorytreeiterator.inc diff -u spl/examples/directorytreeiterator.inc:1.3 spl/examples/directorytreeiterator.inc:1.4 --- spl/examples/directorytreeiterator.inc:1.3 Tue Nov 18 19:18:30 2003 +++ spl/examples/directorytreeiterator.inc Sat Nov 22 15:51:15 2003 @@ -10,12 +10,17 @@ function current() { $tree = ''; - for ($l=0; $l < $this->getLevel(); $l++) { + for ($l=0; $l < $this->getDepth(); $l++) { $tree .= $this->getSubIterator($l)->hasNext() ? '| ' : ' '; } return $tree . ($this->getSubIterator($l)->hasNext() ? '|-' : '\-') . $this->getSubIterator($l); } + + function __call($func, $params) + { + return call_user_func_array(array($this->getSubIterator(), $func), $params); + } } ?> \ No newline at end of file Index: spl/examples/findfile.php diff -u spl/examples/findfile.php:1.1 spl/examples/findfile.php:1.2 --- spl/examples/findfile.php:1.1 Sun Nov 9 09:05:36 2003 +++ spl/examples/findfile.php Sat Nov 22 15:51:15 2003 @@ -6,7 +6,7 @@ function __construct($path, $file) { $this->file = $file; - parent::__construct(new DirectoryTree($path)); + parent::__construct(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path))); } function accept() { return !strcmp($this->it->current(), $this->file); Index: spl/examples/key_filter.inc diff -u spl/examples/key_filter.inc:1.2 spl/examples/key_filter.inc:1.3 --- spl/examples/key_filter.inc:1.2 Thu Sep 4 10:44:54 2003 +++ spl/examples/key_filter.inc Sat Nov 22 15:51:15 2003 @@ -10,7 +10,7 @@ * and the instance will only return elements which match the given regular * expression. */ -class key_filter implements spl_forward_assoc +class KeyFilter implements Iterator { protected $it; protected $regex; @@ -25,14 +25,18 @@ * @param it Object that implements at least spl_forward * @patam regex Regular expression used as a filter. */ - function __construct(spl_forward $it, $regex) { - if ($it instanceof spl_sequence) { - $it->rewind(); - } + function __construct(Iterator $it, $regex) { $this->it = $it; $this->regex = $regex; $this->fetch(); } + + /** + * Rewind input iterator + */ + function rewind() { + $this->it->rewind(); + } /** * Destruct the iterator. Index: spl/examples/recursiveiteratoriterator.inc diff -u spl/examples/recursiveiteratoriterator.inc:1.1 spl/examples/recursiveiteratoriterator.inc:1.2 --- spl/examples/recursiveiteratoriterator.inc:1.1 Sun Nov 9 09:05:36 2003 +++ spl/examples/recursiveiteratoriterator.inc Sat Nov 22 15:51:15 2003 @@ -11,44 +11,50 @@ protected $ait = array(); protected $count = 0; - function __construct(RecursiveIterator $it) { - $this->count = 1; + function __construct(RecursiveIterator $it) + { $this->ait[0] = $it; } - function rewind() { - while ($this->count > 1) { - unset($this->ait[--$this->count]); + function rewind() + { + while ($this->count) { + unset($this->ait[$this->count--]); } $this->ait[0]->rewind(); $this->ait[0]->recursed = false; } - function hasMore() { + function hasMore() + { $count = $this->count; - while ($count--) { + while ($count) { $it = $this->ait[$count]; - if ($it->hasMore()) {// || (!$it->recursed && $it->isRecursive())) { + if ($it->hasMore()) { return true; } + $count--; } return false; } - function key() { - $it = $this->ait[$this->count-1]; + function key() + { + $it = $this->ait[$this->count]; return $it->key(); } - function current() { - $it = $this->ait[$this->count-1]; + function current() + { + $it = $this->ait[$this->count]; return $it->current(); } - function next() { + function next() + { while ($this->count) { - $it = $this->ait[$this->count-1]; + $it = $this->ait[$this->count]; if ($it->hasMore()) { if (!$it->recursed && $it->hasChildren()) { $it->recursed = true; @@ -56,8 +62,8 @@ $sub->recursed = false; $sub->rewind(); if ($sub->hasMore()) { - $this->ait[$this->count++] = $sub; - if (!is_a($sub, 'RecursiveIterator')) { + $this->ait[++$this->count] = $sub; + if (!$sub instanceof RecursiveIterator)) { throw new Exception(get_class($sub).'::getChildren() must return an object that implements RecursiveIterator'); } return; @@ -71,16 +77,24 @@ } $it->recursed = false; } - if ($this->count <= 1) { - return; + if ($this->count) { + unset($this->ait[$this->count--]); + $it = $this->ait[$this->count]; } - unset($this->ait[--$this->count]); - $it = $this->ait[$this->count-1]; } } - function getCurrentIterator() { - return $this->ait[$this->count-1]; + function getSubIterator($level = NULL) + { + if (is_null($level)) { + $level = $this->count; + } + return @$this->ait[$level]; + } + + function getDepth() + { + return $this->level; } } Index: spl/examples/tree.php diff -u spl/examples/tree.php:1.4 spl/examples/tree.php:1.5 --- spl/examples/tree.php:1.4 Thu Aug 14 17:44:38 2003 +++ spl/examples/tree.php Sat Nov 22 15:51:15 2003 @@ -1,18 +1,16 @@ <?php -/* tree view example +/** tree view example * - * Usage: php tree.php <path> + * Usage: php Tree.php <path> * * Simply specify the path to tree with parameter <path>. * * (c) Marcus Boerger */ -require_once("sub_dir.inc"); - -foreach(new sub_dir($argv[1], true, isset($argv[2]) ? $argv[2] : false) as $f) { - echo "$f\n"; +foreach(new DirectoryGraphIterator($argv[1]) as $file) { + echo $file . "\n"; } ?> \ No newline at end of file
Index: spl/examples/cachingiterator.inc diff -u spl/examples/cachingiterator.inc:1.1 spl/examples/cachingiterator.inc:1.2 --- spl/examples/cachingiterator.inc:1.1 Tue Nov 18 17:18:38 2003 +++ spl/examples/cachingiterator.inc Sat Nov 22 15:51:15 2003 @@ -8,16 +8,19 @@ protected $more; protected $strvalue; - function __construct(Iterator $it) { + function __construct(Iterator $it) + { $this->it = $it; } - function rewind() { + function rewind() + { $this->it->rewind(); $this->next(); } - function next() { + function next() + { if ($this->more = $this->it->hasMore()) { $this->current = $this->it->current(); $this->key = $this->it->key(); @@ -30,27 +33,33 @@ $this->it->next(); } - function hasMore() { + function hasMore() + { return $this->more; } - function hasNext() { + function hasNext() + { return $this->it->hasMore(); } - function current() { + function current() + { return $this->current; } - function key() { + function key() + { return $this->key; } - function __call($func, $params) { + function __call($func, $params) + { return call_user_func_array(array($this->it, $func), $params); } - function __toString() { + function __toString() + { return $this->strvalue; } } Index: spl/examples/cachingrecursiveiterator.inc diff -u spl/examples/cachingrecursiveiterator.inc:1.2 spl/examples/cachingrecursiveiterator.inc:1.3 --- spl/examples/cachingrecursiveiterator.inc:1.2 Tue Nov 18 19:18:30 2003 +++ spl/examples/cachingrecursiveiterator.inc Sat Nov 22 15:51:15 2003 @@ -4,23 +4,25 @@ { protected $hasChildren; protected $getChildren; - protected $catch_get_child_exceptions; + protected $catch_get_child; - function __construct(RecursiveIterator $it, $catch_get_child_exceptions = false) { - $this->catch_get_child_exceptions = $catch_get_child_exceptions; + function __construct(RecursiveIterator $it, $catch_get_child = false) + { + $this->catch_get_child = $catch_get_child; parent::__construct($it); } - function next() { + function next() + { if ($this->hasChildren = $this->it->hasChildren()) { try { - //$this->getChildren = new CachingRecursiveIterator($this->it->getChildren(), $this->catch_get_child_exceptions); + //$this->getChildren = new CachingRecursiveIterator($this->it->getChildren(), $this->catch_get_child); // workaround memleaks... $child = $this->it->getChildren(); - $this->getChildren = new CachingRecursiveIterator($child, $this->catch_get_child_exceptions); + $this->getChildren = new CachingRecursiveIterator($child, $this->catch_get_child); } catch(Exception $e) { - if (!$this->catch_get_child_exceptions) { + if (!$this->catch_get_child) { throw $e; } $this->hasChildren = false; @@ -32,11 +34,13 @@ parent::next(); } - function hasChildren() { + function hasChildren() + { return $this->hasChildren; } - function getChildren() { + function getChildren() + { return $this->getChildren; } } Index: spl/examples/dba_array.php diff -u spl/examples/dba_array.php:1.1 spl/examples/dba_array.php:1.2 --- spl/examples/dba_array.php:1.1 Sun Jun 22 11:48:44 2003 +++ spl/examples/dba_array.php Sat Nov 22 15:51:15 2003 @@ -12,7 +12,7 @@ * (c) Marcus Boerger */ -class dba_array implements spl_array_access { +class DbaArray implements ArrayAccess { private $db; function __construct($file, $handler) @@ -35,7 +35,8 @@ if (ini_get('magic_quotes_runtime')) { $data = stripslashes($data); } - return unserialize($data); + //return unserialize($data); + return $data; } else { @@ -45,7 +46,8 @@ function set($name, $value) { - dba_replace($name, serialize($value), $this->db); + //dba_replace($name, serialize($value), $this->db); + dba_replace($name, $value, $this->db); return $value; } @@ -53,18 +55,23 @@ { return dba_exists($name, $this->db); } + + function del($name) + { + return dba_delete($name, $this->db); + } } try { if ($argc > 2) { - $dba = new dba_array($argv[1], $argv[2]); + $dba = new DbaArray($argv[1], $argv[2]); if ($dba && $argc > 3) { if ($argc > 4) { $dba[$argv[3]] = $argv[4]; } var_dump(array('Index' => $argv[3], 'Value' => $dba[$argv[3]])); } - $dba = NULL; + unset($dba); } else { Index: spl/examples/dba_dump.php diff -u spl/examples/dba_dump.php:1.3 spl/examples/dba_dump.php:1.4 --- spl/examples/dba_dump.php:1.3 Wed Jul 16 17:51:09 2003 +++ spl/examples/dba_dump.php Sat Nov 22 15:51:15 2003 @@ -15,10 +15,10 @@ require_once("dba_reader.inc"); require_once("key_filter.inc"); -$db = new dba_reader($argv[1], $argv[2]); +$db = new DbaReader($argv[1], $argv[2]); if ($argc>3) { - $db = new key_filter($db, $argv[3]); + $db = new keyFilter($db, $argv[3]); } foreach($db as $key => $val) { Index: spl/examples/dba_reader.inc diff -u spl/examples/dba_reader.inc:1.2 spl/examples/dba_reader.inc:1.3 --- spl/examples/dba_reader.inc:1.2 Thu Sep 4 10:44:54 2003 +++ spl/examples/dba_reader.inc Sat Nov 22 15:51:15 2003 @@ -1,11 +1,11 @@ <?php /** - * @brief This implements an dba iterator. + * @brief This implements a Dba Iterator. * @author Marcus Boerger * @version 1.0 */ -class dba_reader implements spl_sequence_assoc +class DbaReader implements Iterator { private $db = NULL; Index: spl/examples/directorytree.php diff -u spl/examples/directorytree.php:1.3 spl/examples/directorytree.php:1.4 --- spl/examples/directorytree.php:1.3 Tue Nov 18 17:18:38 2003 +++ spl/examples/directorytree.php Sat Nov 22 15:51:15 2003 @@ -11,8 +11,8 @@ $length = $argc > 3 ? $argv[3] : NULL; -foreach(new LimitIterator(new DirectoryTreeIterator($argv[1]), @$argv[2], $length) as $pathname => $file) { - echo "$file\n"; +foreach(new LimitIterator(new DirectoryTreeIterator($argv[1]), @$argv[2], $length) as $file) { + echo $file ."\n"; } ?> \ No newline at end of file Index: spl/examples/directorytreeiterator.inc diff -u spl/examples/directorytreeiterator.inc:1.3 spl/examples/directorytreeiterator.inc:1.4 --- spl/examples/directorytreeiterator.inc:1.3 Tue Nov 18 19:18:30 2003 +++ spl/examples/directorytreeiterator.inc Sat Nov 22 15:51:15 2003 @@ -10,12 +10,17 @@ function current() { $tree = ''; - for ($l=0; $l < $this->getLevel(); $l++) { + for ($l=0; $l < $this->getDepth(); $l++) { $tree .= $this->getSubIterator($l)->hasNext() ? '| ' : ' '; } return $tree . ($this->getSubIterator($l)->hasNext() ? '|-' : '\-') . $this->getSubIterator($l); } + + function __call($func, $params) + { + return call_user_func_array(array($this->getSubIterator(), $func), $params); + } } ?> \ No newline at end of file Index: spl/examples/findfile.php diff -u spl/examples/findfile.php:1.1 spl/examples/findfile.php:1.2 --- spl/examples/findfile.php:1.1 Sun Nov 9 09:05:36 2003 +++ spl/examples/findfile.php Sat Nov 22 15:51:15 2003 @@ -6,7 +6,7 @@ function __construct($path, $file) { $this->file = $file; - parent::__construct(new DirectoryTree($path)); + parent::__construct(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path))); } function accept() { return !strcmp($this->it->current(), $this->file); Index: spl/examples/key_filter.inc diff -u spl/examples/key_filter.inc:1.2 spl/examples/key_filter.inc:1.3 --- spl/examples/key_filter.inc:1.2 Thu Sep 4 10:44:54 2003 +++ spl/examples/key_filter.inc Sat Nov 22 15:51:15 2003 @@ -10,7 +10,7 @@ * and the instance will only return elements which match the given regular * expression. */ -class key_filter implements spl_forward_assoc +class KeyFilter implements Iterator { protected $it; protected $regex; @@ -25,14 +25,18 @@ * @param it Object that implements at least spl_forward * @patam regex Regular expression used as a filter. */ - function __construct(spl_forward $it, $regex) { - if ($it instanceof spl_sequence) { - $it->rewind(); - } + function __construct(Iterator $it, $regex) { $this->it = $it; $this->regex = $regex; $this->fetch(); } + + /** + * Rewind input iterator + */ + function rewind() { + $this->it->rewind(); + } /** * Destruct the iterator. Index: spl/examples/recursiveiteratoriterator.inc diff -u spl/examples/recursiveiteratoriterator.inc:1.1 spl/examples/recursiveiteratoriterator.inc:1.2 --- spl/examples/recursiveiteratoriterator.inc:1.1 Sun Nov 9 09:05:36 2003 +++ spl/examples/recursiveiteratoriterator.inc Sat Nov 22 15:51:15 2003 @@ -11,44 +11,50 @@ protected $ait = array(); protected $count = 0; - function __construct(RecursiveIterator $it) { - $this->count = 1; + function __construct(RecursiveIterator $it) + { $this->ait[0] = $it; } - function rewind() { - while ($this->count > 1) { - unset($this->ait[--$this->count]); + function rewind() + { + while ($this->count) { + unset($this->ait[$this->count--]); } $this->ait[0]->rewind(); $this->ait[0]->recursed = false; } - function hasMore() { + function hasMore() + { $count = $this->count; - while ($count--) { + while ($count) { $it = $this->ait[$count]; - if ($it->hasMore()) {// || (!$it->recursed && $it->isRecursive())) { + if ($it->hasMore()) { return true; } + $count--; } return false; } - function key() { - $it = $this->ait[$this->count-1]; + function key() + { + $it = $this->ait[$this->count]; return $it->key(); } - function current() { - $it = $this->ait[$this->count-1]; + function current() + { + $it = $this->ait[$this->count]; return $it->current(); } - function next() { + function next() + { while ($this->count) { - $it = $this->ait[$this->count-1]; + $it = $this->ait[$this->count]; if ($it->hasMore()) { if (!$it->recursed && $it->hasChildren()) { $it->recursed = true; @@ -56,8 +62,8 @@ $sub->recursed = false; $sub->rewind(); if ($sub->hasMore()) { - $this->ait[$this->count++] = $sub; - if (!is_a($sub, 'RecursiveIterator')) { + $this->ait[++$this->count] = $sub; + if (!$sub instanceof RecursiveIterator)) { throw new Exception(get_class($sub).'::getChildren() must return an object that implements RecursiveIterator'); } return; @@ -71,16 +77,24 @@ } $it->recursed = false; } - if ($this->count <= 1) { - return; + if ($this->count) { + unset($this->ait[$this->count--]); + $it = $this->ait[$this->count]; } - unset($this->ait[--$this->count]); - $it = $this->ait[$this->count-1]; } } - function getCurrentIterator() { - return $this->ait[$this->count-1]; + function getSubIterator($level = NULL) + { + if (is_null($level)) { + $level = $this->count; + } + return @$this->ait[$level]; + } + + function getDepth() + { + return $this->level; } } Index: spl/examples/tree.php diff -u spl/examples/tree.php:1.4 spl/examples/tree.php:1.5 --- spl/examples/tree.php:1.4 Thu Aug 14 17:44:38 2003 +++ spl/examples/tree.php Sat Nov 22 15:51:15 2003 @@ -1,18 +1,16 @@ <?php -/* tree view example +/** tree view example * - * Usage: php tree.php <path> + * Usage: php Tree.php <path> * * Simply specify the path to tree with parameter <path>. * * (c) Marcus Boerger */ -require_once("sub_dir.inc"); - -foreach(new sub_dir($argv[1], true, isset($argv[2]) ? $argv[2] : false) as $f) { - echo "$f\n"; +foreach(new DirectoryGraphIterator($argv[1]) as $file) { + echo $file . "\n"; } ?> \ No newline at end of file