added type and show/files
[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 # $Id$
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
19 if (@f) {
20         my $fn = lc $f[0];
21         $fn =~ s/\\/\//og;
22         $fn =~ s/\.//og;
23         $fn =~ s/^\///og;
24         $root = "$root/$fn";
25 }
26
27 opendir(DIR, $root) or  return (1, $self->msg('e3', 'show/files', $f[0]));
28 @file = sort readdir(DIR);
29 closedir(DIR);
30
31 my $flag = 0;
32 for (@file) {
33         next if /^\./;
34         my $fn = "$root/$_";
35         my $size;
36         
37         @d = stat($fn);
38         if (-d $fn) {
39                 $size = "DIR";
40         } else {
41                 $size = $d[7]
42         }
43         $slot[$flag] = sprintf("%-10.10s %7.7s %s", $_, $size, cldatetime($d[9]));
44         $flag ^= 1;
45         if ($flag == 0 && @slot >= 2) {
46                 push @out, "$slot[0] $slot[1]";
47         }
48 }
49 push @out, $slot[0] if $flag;
50 return (1, @out);
51
52