summaryrefslogtreecommitdiff
path: root/ext/spl/examples/findfile.inc
blob: c4bce73a30d00ca52a0fc7152958959a99ebd835 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php

/**
 * @brief   Base class to find files
 * @author  Marcus Boerger
 * @version 1.0
 *
 */
class FindFile extends FilterIterator
{
	protected $file;

	function __construct($path, $file)
	{
		$this->file = $file;
		$list = split(';', $path);
		if (count($list) <= 1) {
			parent::__construct(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)));
		} else {
			$it = new AppendIterator();
			foreach($list as $path) {
				$it->append(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)));
			}
			parent::__construct($it);
		}
	}

	function accept()
	{
		return !strcmp($this->current(), $this->file);
	}
}

?>