summaryrefslogtreecommitdiff
path: root/ext/spl/examples/directoryfilterdots.inc
blob: 37f14b7106eda50498df3ec4e09faf19da98412e (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
35
36
37
38
39
40
41
42
43
44
45
<?php

/** @file directoryfilterdots.inc
 * @ingroup Examples
 * @brief class DirectoryFilterDots
 * @author  Marcus Boerger
 * @date    2003 - 2006
 *
 * SPL - Standard PHP Library
 */

/** @ingroup Examples
 * @brief   A filtered DirectoryIterator
 * @author  Marcus Boerger
 * @version 1.2
 *
 * This Iterator takes a pathname from which it creates a RecursiveDirectoryIterator
 * and makes it recursive. Further more it filters the entries '.' and '..'.
 */
class DirectoryFilterDots extends RecursiveFilterIterator
{
	/** Construct from a path.
	 * @param $path directory to iterate
	 */
	function __construct($path)
	{
		parent::__construct(new RecursiveDirectoryIterator($path));
	}

	/** @return whether the current entry is neither '.' nor '..'
	 */	
	function accept()
	{
		return !$this->getInnerIterator()->isDot();
	}

	/** @return the current entries path name
	 */
	function key()
	{
		return $this->getInnerIterator()->getPathname();
	}
}

?>