blob: 0e1d5b3a4b04735f6da92f8d64a9a5fda2a2c9b5 (
plain) (
blame)
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
53
54
|
#!/usr/bin/perl
# $Id$
use strict;
use lib '/home/bbs/bin/';
use BBSFileHeader;
my($nDels, $prefix) = ();
$nDels = 0;
foreach( @ARGV ){
print "cleaning: $_\n";
cleandir($_);
print "\n";
}
print "$nDels files deleted\n";
sub toclean
{
unlink("$prefix/$_[0]");
++$nDels;
}
sub cleandir($)
{
my($dir) = @_;
my(%files, %dotDIR, $now, $counter) = ();
$now = time();
$prefix = $dir;
opendir DIR, $dir;
foreach( readdir(DIR) ){
if( /^\./ ){
next;
} elsif( -d $_ ){
print "dir? $_";
`/bin/rm -rf $prefix/$_`;
} elsif( /^M\.\d+\.A/ ){
$files{$_} = 1;
} elsif( (/^SR\./) && (stat($_))[2] < ($now - 86400) ){
toclean($_);
}
}
close DIR;
tie %dotDIR, 'BBSFileHeader', $dir;
foreach( 0..($dotDIR{num} - 1) ){
my $fn = $dotDIR{"$_.filename"};
delete $files{$fn};
}
untie %dotDIR;
toclean($_)
foreach( keys %files );
}
|