remove $Id$ strings from everywhere that I can find
[spider.git] / cmd / show / files.pl
1 #
2 # the show/files command, list bulls, files and areas 
3 #
4 # The equivalent of LS in other words
5 #
6 # Copyright (c) 1999 Dirk Koopman G1TLH
7 #
8 #
9 #
10
11 my ($self, $line) = @_;
12 my @f = split /\s+/, $line;
13 my $root = "$main::root/packclus";
14 my @out;
15 my @file;
16 my @d;
17 my @slot;
18 my $patt = '^.*$';
19
20 if (@f) {
21         my $fn = lc $f[0];
22         $fn =~ s/\\/\//og;
23         $fn =~ s/\.//og;
24         $fn =~ s/^\///og;
25         $root = "$root/$fn";
26
27     $patt = shellregex(lc $f[1]) if defined $f[1];
28 }
29
30 opendir(DIR, $root) or  return (1, $self->msg('e3', 'show/files', $f[0]));
31 @file = sort readdir(DIR);
32 closedir(DIR);
33
34 my $flag = 0;
35 for (@file) {
36         next if /^\./;
37     next unless m{$patt};
38         my $fn = "$root/$_";
39         my $size;
40         
41         @d = stat($fn);
42         if (-d $fn) {
43                 $size = "DIR";
44         } else {
45                 $size = $d[7]
46         }
47         $slot[$flag] = sprintf("%-10.10s %7.7s %s", $_, $size, cldatetime($d[9]));
48         $flag ^= 1;
49         if ($flag == 0 && @slot >= 2) {
50                 push @out, "$slot[0] $slot[1]";
51         }
52 }
53 push @out, $slot[0] if $flag;
54 return (1, @out);
55
56