SPL-StandardPHPLibrary
findfile.inc
Go to the documentation of this file.
1 <?php
2 
12 if (!class_exists("FindFile", false)) require_once("findfile.inc");
13 if (!class_exists("AppendIterator", false)) require_once("appenditerator.inc");
14 
21 class FindFile extends FilterIterator
22 {
24  private $file;
25 
33  function __construct($path, $file)
34  {
35  $this->file = $file;
36  $list = split(PATH_SEPARATOR, $path);
37  if (count($list) <= 1) {
38  parent::__construct(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)));
39  } else {
40  $it = new AppendIterator();
41  foreach($list as $path) {
43  }
44  parent::__construct($it);
45  }
46  }
47 
50  function accept()
51  {
52  return !strcmp($this->current(), $this->file);
53  }
54 
59  function getSearch()
60  {
61  return $this->file;
62  }
63 }
64 
65 ?>
Iterates through recursive iterators.
getSearch()
Definition: findfile.inc:59
__construct($path, $file)
Construct from path and filename.
Definition: findfile.inc:33
Abstract filter for iterators.
Base class to find files.
Definition: findfile.inc:21
accept()
Definition: findfile.inc:50
Iterator that iterates over several iterators one after the other.
recursive directory iterator
Definition: spl.php:1034