$f->{'size'} = $st[7];
}
elsif ($f->{'type'} == 1) {
- # Maildir folder size is that of all files in it
- $f->{'size'} = &recursive_disk_usage($f->{'file'});
+ # Maildir folder size is that of all files in it, except
+ # sub-folders.
+ $f->{'size'} = &recursive_disk_usage($f->{'file'}, '^\\.');
}
elsif ($f->{'type'} == 3) {
# MH folder size is that of all mail files
return $out =~ /^([0-9]+)/ ? $1 : "???";
}
-=head2 recursive_disk_usage(directory)
+=head2 recursive_disk_usage(directory, [skip-regexp], [only-regexp])
Returns the number of bytes taken up by all files in some directory and all
sub-directories, by summing up their lengths. The disk_usage_kb is more
sub recursive_disk_usage
{
my $dir = &translate_filename($_[0]);
+my $skip = $_[1];
+my $only = $_[2];
if (-l $dir) {
return 0;
}
closedir(DIR);
foreach my $f (@files) {
next if ($f eq "." || $f eq "..");
- $rv += &recursive_disk_usage("$dir/$f");
+ next if ($skip && $f =~ /$skip/);
+ next if ($only && $f !~ /$only/);
+ $rv += &recursive_disk_usage("$dir/$f", $skip, $only);
}
return $rv;
}