hi, i wrote this little program. it reads a file and puts the output
into a treelike structure. the content of the file is the output of the
du command. something like that:

124k /var/backups/dpkg.status.3.gz
12k /var/log/auth.log.1.gz
12k /var/log/daemon.log.1.gz
12k /var/log/debug.1.gz
12k /var/log/syslog.2.gz
12k /var/log/syslog.3.gz
132k /var/backups/dpkg.status.1.gz
132k /var/backups/dpkg.status.2.gz
4.0k /var/log/auth.log.2.gz
4.0k /var/log/debug.2.gz
4.0k /var/log/kern.log.1.gz

the program works fine for a small directory, but as soon as the
directory is bigger, it takes a long time to start. do you have any
idea how to make this faster?


---

#!/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 SD,'</tmp/LIST' or die "Couldn't open all: $!\n";
#my %hash = reverse map split, <SD>;

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) {
    print "file: '$file'\n";
    my @path = split '/', $file;
    shift @path; # leeren Eintrag vorn entfernen
    print "path: '@path'\n";
    my $path = "";
    for my $pt (@path) {
        print "inpatharray: $pt\n";
        $path .= "/$pt";
        print "path: $path\n";


        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";
        }
    }
}
---

to create the LIST file, simply do:

du -h -a /usr> /tmp/all 2>/dev/null -->or /var or any big directory
sort +1 /tmp/all > /tmp/LIST


zhis should generate a file called LIST in the /tmp directory. i hope
someone has an idea because this is really important. 


THANKS YOU VERY MUCH :-)

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to