Back to index

php5  5.3.10
findfile.inc
Go to the documentation of this file.
00001 <?php
00002 
00012 if (!class_exists("FindFile", false)) require_once("findfile.inc");
00013 if (!class_exists("AppendIterator", false)) require_once("appenditerator.inc");
00014 
00021 class FindFile extends FilterIterator
00022 {
00024        private $file;
00025 
00033        function __construct($path, $file)
00034        {
00035               $this->file = $file;
00036               $list = split(PATH_SEPARATOR, $path);
00037               if (count($list) <= 1) {
00038                      parent::__construct(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)));
00039               } else {
00040                      $it = new AppendIterator();
00041                      foreach($list as $path) {
00042                             $it->append(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)));
00043                      }
00044                      parent::__construct($it);
00045               }
00046        }
00047 
00050        function accept()
00051        {
00052               return !strcmp($this->current(), $this->file);
00053        }
00054 
00059        function getSearch()
00060        {
00061               return $this->file;
00062        }
00063 }
00064 
00065 ?>