summaryrefslogtreecommitdiff
path: root/fml/lib
diff options
context:
space:
mode:
authorfukachan <fukachan>2004-12-15 13:53:08 +0000
committerfukachan <fukachan>2004-12-15 13:53:08 +0000
commit47bea17ae6e2ed9d78e8931ac45ad5234434f73b (patch)
tree8f98c834678903de64d319b7dd69450b99b0f26c /fml/lib
parent7eb62827c9b73077caa7f22d003ae191bfbc28d3 (diff)
downloadfml8-47bea17ae6e2ed9d78e8931ac45ad5234434f73b.tar.gz
fml8-47bea17ae6e2ed9d78e8931ac45ad5234434f73b.tar.bz2
fml8-47bea17ae6e2ed9d78e8931ac45ad5234434f73b.zip
implement remove_too_old_files_in_dir() method.
Diffstat (limited to 'fml/lib')
-rw-r--r--fml/lib/FML/Process/Utils.pm34
1 files changed, 33 insertions, 1 deletions
diff --git a/fml/lib/FML/Process/Utils.pm b/fml/lib/FML/Process/Utils.pm
index ca3686f7..25426021 100644
--- a/fml/lib/FML/Process/Utils.pm
+++ b/fml/lib/FML/Process/Utils.pm
@@ -4,7 +4,7 @@
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
-# $FML: Utils.pm,v 1.126 2004/11/25 12:20:06 fukachan Exp $
+# $FML: Utils.pm,v 1.127 2004/12/05 16:19:11 fukachan Exp $
#
package FML::Process::Utils;
@@ -2103,6 +2103,38 @@ sub log_rorate
}
+# Descriptions: remove too old incoming queue files.
+# Arguments: OBJ($curproc) STR($dir) NUM($_limit)
+# Side Effects: remove too old incoming queue files.
+# Return Value: none
+sub remove_too_old_files_in_dir
+{
+ my ($curproc, $dir, $_limit) = @_;
+ my $limit = $_limit || 14*24*3600; # 2 weeks by default.
+
+ use DirHandle;
+ use File::stat;
+ my $dh = new DirHandle $dir;
+ if (defined $dh) {
+ my ($file, $entry, $stat);
+ my $day_limit = time - $limit;
+
+ ENTRY:
+ while ($entry = $dh->read()) {
+ next ENTRY if $entry =~ /^\./o;
+
+ $file = File::Spec->catfile($dir, $entry);
+ $stat = stat($file);
+ if ($stat->mtime < $day_limit) {
+ $curproc->log("remove too old file: $entry");
+ unlink $file;
+ }
+ }
+ $dh->close();
+ }
+}
+
+
=head1 CODING STYLE
See C<http://www.fml.org/software/FNF/> on fml coding style guide.