hi, i wrote this little program. it shows a directory structure using
tree and hlist. it reads the directoycontent from a file. when i
display small directories, the program starts fast, but as soon as the
directory is big, it takes a long time to start. for example when i use
the /var directory.
to test, simply generate a file and read that file. maybe you have to
change the file name within the program.
du- ha >/tmp/yourfilename1
sort +1 /tmp/yourfilename1 > /tmp/LIST
heres the code:
----
#!/usr/bin/perl
use diagnostics;
use strict;
use Tk;
use Tk::HList;
use Tk::Tree;
use File::Basename;
my $mw = tkinit;
my $hl = $mw->ScrlTree(-separator => '/',
-drawbranch => 1,
-scrollbars => 'osoe',
-selectmode => 'extended',
-selectforeground => 'red',
)->pack(-fill => 'both',
-expand => 1);
open DATA,'</tmp/LIST' or die "Couldn't open all: $!\n";
#my %hash = reverse map split, <DATA>;
my %hash = reverse map split, <DATA>; #<SD>;
print "Datei '$_' belegt '$hash{$_}'.\n" for sort keys %hash;
$hl->add('/');
$hl->item('create', '/', 0, -text => '/');
for my $file (sort keys %hash) {
my @path = split '/', $file;
shift @path; # leeren Eintrag vorn entfernen
my $path = "";
for my $pt (@path) {
$path .= "/$pt";
if (! $hl->info('exists', $path)) {
my $realFile= fileparse($file);
if (-d $path) {
$hl->add($path);
$hl->item('create',
$path,
0,
-text => "$path",
-image => $hl->Getimage('folder'),
);
$hl->autosetmode;
}
else {
$hl->add($path);
$hl->item('create',
$path,
0,
-text => "$path",
-image => $hl->Getimage('file'),
);
$hl->autosetmode;
}
}
else {
#print "weder noch\n";
}
}
}
MainLoop;
__DATA__
----
THANK YOU VERY MUCH
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]