1<?php 2 3/** @file nocvsdir.php 4 * @brief Program Dir without CVS subdirs 5 * @ingroup Examples 6 * @author Marcus Boerger 7 * @date 2003 - 2006 8 * @version 1.1 9 * 10 * Usage: php nocvsdir.php \<path\> 11 * 12 * Simply specify the path to tree with parameter \<path\>. 13 */ 14 15if ($argc < 2) { 16 echo <<<EOF 17Usage: php ${_SERVER['PHP_SELF']} <path> 18 19Show the directory and all it's contents without any CVS directory in <path>. 20 21<path> The directory for which to generate the directory. 22 23 24EOF; 25 exit(1); 26} 27 28if (!class_exists("RecursiveFilterIterator")) require_once("recursivefilteriterator.inc"); 29 30class NoCvsDirectory extends RecursiveFilterIterator 31{ 32 function __construct($path) 33 { 34 parent::__construct(new RecursiveDirectoryIterator($path)); 35 } 36 37 function accept() 38 { 39 return $this->getInnerIterator()->getFilename() != 'CVS'; 40 } 41 42 function getChildren() 43 { 44 return new NoCvsDirectory($this->key()); 45 } 46} 47 48$it = new RecursiveIteratorIterator(new NoCvsDirectory($argv[1])); 49 50foreach($it as $pathname => $file) 51{ 52 echo $pathname."\n"; 53} 54 55?>