1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
package LXRng::Repo::Plain::Directory;
use strict;
use base qw(LXRng::Repo::Directory);
sub new {
my ($class, $name, $path, $stat) = @_;
$name =~ s,(.)/*$,$1/,;
$path =~ s,/*$,/,;
return bless({name => $name, path => $path, stat => $stat}, $class);
}
sub cache_key {
my ($self) = @_;
return $$self{'path'};
}
sub time {
my ($self) = @_;
return $$self{'stat'}[9];
}
sub size {
my ($self) = @_;
return '';
}
sub contents {
my ($self) = @_;
my (@dirs, @files);
my ($dir, $node);
opendir($dir, $$self{'path'}) or die("Can't open ".$$self{'path'}.": $!");
while (defined($node = readdir($dir))) {
next if $node =~ /^\.|~$|\.orig$/;
next if $node eq 'CVS';
my $file = LXRng::Repo::Plain::File->new($$self{'name'}.$node,
$$self{'path'}.$node);
push(@files, $file) if $file;
}
closedir($dir);
return sort { ref($a) cmp ref($b) || $$a{'name'} cmp $$b{'name'} } @files;
}
1;
|