[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 158
  • Last Modified:

Menu tree from Hard disk

I look for a sollution to let people view a part of a harddisk (let's say c:\data and it's submenu's) in a menu style like this:
c:\data
   + word documents
       + Sales
       + Vendor
   + Excell Sheets
       + Sales

Do someone have here a sollution.

This must be just show a Hard disk tree with the current files in it.

I start with 100 points and go up if I found realy something.

Mario
0
Lermitte
Asked:
Lermitte
  • 8
  • 8
1 Solution
 
MindoCommented:
Damn, while at the Perl exam at my university i had to write a recursive file directory representation just like for you. I wrote it, got my grade and deleted it! What a shame :-(
0
 
LermitteAuthor Commented:
That's indeed a shame, I know java and HTML but I have not the expertise to write something like I need now. And I need it Fast...

Mario
0
 
LermitteAuthor Commented:
Adjusted points to 125
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
MindoCommented:
Ok, wait an hour, i'm writing it once again :-)
0
 
LermitteAuthor Commented:
This will be great...

Mario
0
 
LermitteAuthor Commented:
You can send it to lermitte@pandora.be
If it's to big to place it here.

Mario
0
 
ozoCommented:
use File::Find;
find(\&wanted,'c:/data');
sub wanted{print "  "x($File::Find::dir=~tr:/:/:),"  + $_\n"}
0
 
MindoCommented:
I'm unlucky, an expert provided an answer just before i wrote it. Mario? Should i proceed doing this? My answer isn't so nice as ozo's :-(
0
 
MindoCommented:
My answer differentiates directories from files.
0
 
MindoCommented:
#!/usr/local/bin/perl -w

use File::Find;

push(@DIR, $ARGV[0]);

$c = count_slashes($ARGV[0]);

find (\&process_file, @DIR);

#--------------------------------------------------------

sub process_file
{
  $file_name = $File::Find::name;
 
  $count = &count_slashes($file_name) - $c;
 
  $start = "";
 
  for($i = 0; $i < $count; $i++)
  {
    $start .= "  ";
  }
 
  if(-d $file_name)
  {
    $start .= "+ ";
  }  
  else
  {
    $start .= "- ";
  }
 
  $start .= $_;
 
  print "$start\n";
}

#--------------------------------------------------------

sub count_slashes
{
  my($file_name) = shift;
 
  $seen{"/"} = 0;
 
  foreach (split //, $file_name)
  {
    $seen{$_}++;
  }
 
  return $seen{"/"};
}

#--------------------------------------------------------
0
 
MindoCommented:
I'm dead, ozo's answer is a real piece of code!

Nevertheless, my answer accepts directories from the command line. Also, it lets you add different symbols depending on the type of your file: directory/plain file.
0
 
LermitteAuthor Commented:
Second question. How can I integrate this in a HTML file...

Don't panic I can give point to your both...

Mario
0
 
LermitteAuthor Commented:
Second question. How can I integrate this in a HTML file...

Don't panic I can give point to your both...

Mario
0
 
MindoCommented:
Ok, do the following:

Name your Perl source file perl.cgi. Give it permissions so that people could see it on the web. Give it a parameter directory name through CGI. Then print the HTML tags and inside print the results of this program.
0
 
MindoCommented:
I think you should post it as a new question to receive full source code.
0
 
LermitteAuthor Commented:
It's not exact what we want put we have working on it and now we have a sollution to view a tre menu in a webpage.

Thanks,

Mario
0
 
LermitteAuthor Commented:
Ozo look for a question special for you.

Mario
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 8
  • 8
Tackle projects and never again get stuck behind a technical roadblock.
Join Now