~ubuntu-branches/ubuntu/quantal/php5/quantal

« back to all changes in this revision

Viewing changes to ext/spl/examples/tree.php

  • Committer: Bazaar Package Importer
  • Author(s): Sean Finney
  • Date: 2009-07-01 09:12:10 UTC
  • mto: (0.9.1) (1.1.17 upstream)
  • mto: This revision was merged to the branch mainline in revision 58.
  • Revision ID: james.westby@ubuntu.com-20090701091210-go0h6506p62on17r
Tags: upstream-5.3.0
ImportĀ upstreamĀ versionĀ 5.3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
/** @file   tree.php
 
4
 * @brief   Program Tree view example
 
5
 * @ingroup Examples
 
6
 * @author  Marcus Boerger
 
7
 * @date    2003 - 2005
 
8
 *
 
9
 * Usage: php tree.php \<path\>
 
10
 *
 
11
 * Simply specify the path to tree with parameter \<path\>.
 
12
 */
 
13
 
 
14
// The following line only operates on classes which are converted to c already.
 
15
// But does not generate a graphical output.
 
16
//foreach(new RecursiveIteratorIterator(new ParentIterator(new RecursiveDirectoryIterator($argv[1])), 1) as $file) {
 
17
 
 
18
if ($argc < 2) {
 
19
        echo <<<EOF
 
20
Usage: php ${_SERVER['PHP_SELF']} <path>
 
21
 
 
22
Displays a graphical tree for the given <path>.
 
23
 
 
24
<path> The directory for which to generate the tree graph.
 
25
 
 
26
 
 
27
EOF;
 
28
        exit(1);
 
29
}
 
30
 
 
31
if (!class_exists("DirectoryTreeIterator", false)) require_once("directorytreeiterator.inc");
 
32
if (!class_exists("DirectoryGraphIterator", false)) require_once("directorygraphiterator.inc");
 
33
 
 
34
echo $argv[1]."\n";
 
35
foreach(new DirectoryGraphIterator($argv[1]) as $file)
 
36
{
 
37
        echo $file . "\n";
 
38
}
 
39
 
 
40
?>