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

Reply via email to