TREE command

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dave

    TREE command

    Hi folks,
    I notice both unix and windows have the tree command for viewing a systems
    files from the current dir downwards. Is there anyway in PHP which I could
    use this command and make a tree with all the directories clickable? So
    users could go to them directories?

    Or what are others ways for navigation, basically one function I have for
    instance is copy, a user selects a file to copy and on the next screen is
    presented with a textbox to type wheer to copy in. It would be nice if I
    could have something graphically for them to click on and then update the
    box. Anyknow know anything on this or resources, anything in PEAR?

    Thanks in advance.
    Dave


  • Andy Hassall

    #2
    Re: TREE command

    On Tue, 21 Dec 2004 22:07:47 -0000, "Dave" <contact@akamar keting.com> wrote:
    [color=blue]
    >I notice both unix and windows have the tree command for viewing a systems
    >files from the current dir downwards. Is there anyway in PHP which I could
    >use this command and make a tree with all the directories clickable? So
    >users could go to them directories?[/color]

    May you could, but often it's better and safer to stick with native functions
    rather than spawning external processes. See:

    opendir()
    readdir()

    And use an array as a stack to read any subdirectories. e.g.

    <?php
    $baseDir = '.';
    $dirStack = array($baseDir) ;

    while (($currentDir = array_pop($dirS tack)) !== null)
    {
    if ($dir = opendir($curren tDir))
    {
    while (($file = readdir($dir)) !== false)
    {
    if ($file != '.' && $file != '..')
    {
    if (is_dir("$curre ntDir/$file"))
    array_push($dir Stack, "$currentDi r/$file");

    echo htmlspecialchar s("$currentDi r/$file") . "<br>";
    }
    }
    }
    }
    ?>

    --
    Andy Hassall / <andy@andyh.co. uk> / <http://www.andyh.co.uk >
    <http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool

    Comment

    • Steve

      #3
      Re: TREE command

      Ner dont reinvent the wheel



      Comment

      Working...