[PHP-CVS] cvs: spl /examples tree.php
helly Thu Aug 14 17:44:38 2003 EDT Modified files: /spl/examples tree.php Log: Upds Index: spl/examples/tree.php diff -u spl/examples/tree.php:1.3 spl/examples/tree.php:1.4 --- spl/examples/tree.php:1.3 Thu Aug 14 17:14:04 2003 +++ spl/examples/tree.php Thu Aug 14 17:44:38 2003 @@ -11,7 +11,7 @@ require_once(sub_dir.inc); -foreach(new sub_dir($argv[1], true, isset($argv[1]) ? $argv[1] : false) as $f) { +foreach(new sub_dir($argv[1], true, isset($argv[2]) ? $argv[2] : false) as $f) { echo $f\n; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: spl /examples tree.php
Hello Marcus, Thursday, August 14, 2003, 11:44:38 PM, you wrote: MB helly Thu Aug 14 17:44:38 2003 EDT MB Modified files: MB /spl/examples tree.php MB Log: MB Upds MB Index: spl/examples/tree.php MB diff -u spl/examples/tree.php:1.3 spl/examples/tree.php:1.4 MB --- spl/examples/tree.php:1.3 Thu Aug 14 17:14:04 2003 MB +++ spl/examples/tree.php Thu Aug 14 17:44:38 2003 MB @@ -11,7 +11,7 @@ MB require_once(sub_dir.inc); MB -foreach(new sub_dir($argv[1], true, isset($argv[1]) ? $argv[1] : false) as $f) { MB +foreach(new sub_dir($argv[1], true, isset($argv[2]) ? $argv[2] : false) as $f) { MB echo $f\n; MB } My thanks go to rob :-) -- Best regards, Marcusmailto:[EMAIL PROTECTED] -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: spl /examples tree.php
helly Wed Jul 16 14:47:26 2003 EDT Added files: /spl/examples tree.php Log: Add tree example Index: spl/examples/tree.php +++ spl/examples/tree.php ?php /* tree view example * * Usage: php tree.php path * * Simply specify the path to tree with parameter path. * * (c) Marcus Boerger */ class sub_dir implements spl_sequence { protected $adir = array(); protected $cnt = 0; protected $path = ; protected $curr = ; protected $nodots = true; function __construct($path, $nodots = true) { $this-cnt = 0; $this-path = $path; } function rewind() { while($this-cnt) { unset($this-adir[$this-cnt--]); } $dir = new spl_dir($this-path); $dir-path = ; $this-adir[1] = $dir; $this-cnt = 1; if ($this-nodots) { while ($this-has_more()) { $ent = $this-current(); if ($ent != '.' $ent != '..') { break; } $this-next(); } } } function next() { if ($this-cnt) { $dir = $this-adir[$this-cnt]; $ent = $dir-current(); $path = $dir-get_path().'/'.$ent; if ($ent != '.' $ent != '..' is_dir($path)) { $new = new spl_dir($path); $new-path = $dir-path.$ent.'/'; $new-cnt = $this-cnt++; $this-adir[$this-cnt] = $new; if ($this-nodots) { while ($new-has_more()) { $ent = $new-current(); if ($ent != '.' $ent != '..') { break; } $new-next(); } } } $dir-next(); } } function has_more() { while ($this-cnt) { $dir = $this-adir[$this-cnt]; if ($dir-has_more()) { return true; } unset($this-adir[$this-cnt--]); } return false; } function current() { if ($this-cnt) { $dir = $this-adir[$this-cnt]; return $dir-path . $dir-current(); } throw new exception(No more elements available); } } foreach(new sub_dir($argv[1]) as $f) { echo $f\n; } ? -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: spl /examples tree.php
helly Wed Jul 16 16:17:34 2003 EDT Modified files: /spl/examples tree.php Log: Update examples Index: spl/examples/tree.php diff -u spl/examples/tree.php:1.1 spl/examples/tree.php:1.2 --- spl/examples/tree.php:1.1 Wed Jul 16 14:47:26 2003 +++ spl/examples/tree.php Wed Jul 16 16:17:34 2003 @@ -9,81 +9,7 @@ * (c) Marcus Boerger */ -class sub_dir implements spl_sequence -{ - protected $adir = array(); - protected $cnt = 0; - protected $path = ; - protected $curr = ; - protected $nodots = true; - - function __construct($path, $nodots = true) { - $this-cnt = 0; - $this-path = $path; - } - - function rewind() { - while($this-cnt) { - unset($this-adir[$this-cnt--]); - } - $dir = new spl_dir($this-path); - $dir-path = ; - $this-adir[1] = $dir; - $this-cnt = 1; - if ($this-nodots) { - while ($this-has_more()) { - $ent = $this-current(); - if ($ent != '.' $ent != '..') { - break; - } - $this-next(); - } - } - } - - function next() { - if ($this-cnt) { - $dir = $this-adir[$this-cnt]; - $ent = $dir-current(); - $path = $dir-get_path().'/'.$ent; - if ($ent != '.' $ent != '..' is_dir($path)) { - $new = new spl_dir($path); - $new-path = $dir-path.$ent.'/'; - $new-cnt = $this-cnt++; - $this-adir[$this-cnt] = $new; - if ($this-nodots) { - while ($new-has_more()) { - $ent = $new-current(); - if ($ent != '.' $ent != '..') { - break; - } - $new-next(); - } - } - } - $dir-next(); - } - } - - function has_more() { - while ($this-cnt) { - $dir = $this-adir[$this-cnt]; - if ($dir-has_more()) { - return true; - } - unset($this-adir[$this-cnt--]); - } - return false; - } - - function current() { - if ($this-cnt) { - $dir = $this-adir[$this-cnt]; - return $dir-path . $dir-current(); - } - throw new exception(No more elements available); - } -} +require_once(sub_dir.inc); foreach(new sub_dir($argv[1]) as $f) { echo $f\n; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php