nocvsdir.php 1.0 KB

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