directorytree.php 845 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /** @file directorytree.php
  3. * @brief Program Directory tree example
  4. * @ingroup Examples
  5. * @author Marcus Boerger
  6. * @date 2003 - 2005
  7. *
  8. * Usage: php directorytree.php \<path\> [\<start\> [\<count\>]]
  9. *
  10. * Simply specify the path to tree with parameter \<path\>.
  11. */
  12. if ($argc < 2) {
  13. echo <<<EOF
  14. Usage: php ${_SERVER['PHP_SELF']} <path>
  15. Displays a graphical directory tree for the given <path>.
  16. <path> The directory for which to generate the directory tree graph.
  17. EOF;
  18. exit(1);
  19. }
  20. if (!class_exists("DirectoryTreeIterator", false)) require_once("directorytreeiterator.inc");
  21. $length = $argc > 3 ? $argv[3] : -1;
  22. echo $argv[1]."\n";
  23. foreach(new LimitIterator(new DirectoryTreeIterator($argv[1]), @$argv[2], $length) as $key=>$file) {
  24. //foreach(new DirectoryTreeIterator($argv[1]) as $file) {
  25. echo $file . "\n";
  26. }
  27. ?>