summaryrefslogtreecommitdiff
path: root/Echolot/Tools.pm
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2003-06-06 10:36:23 +0000
committerPeter Palfrader <peter@palfrader.org>2003-06-06 10:36:23 +0000
commit4218368936ee0e3613d29903a333f334b65f63dd (patch)
treeea2ec0c26ab7a559d9fc6bfd6bbd21eda2c11438 /Echolot/Tools.pm
parent5c5d3ec3d283b8454788dad1c72510c1eb4eaf71 (diff)
Regularily clean up temp dir
Diffstat (limited to 'Echolot/Tools.pm')
-rw-r--r--Echolot/Tools.pm16
1 files changed, 15 insertions, 1 deletions
diff --git a/Echolot/Tools.pm b/Echolot/Tools.pm
index fd86a4c..c3ad305 100644
--- a/Echolot/Tools.pm
+++ b/Echolot/Tools.pm
@@ -1,7 +1,7 @@
package Echolot::Tools;
# (c) 2002 Peter Palfrader <peter@palfrader.org>
-# $Id: Tools.pm,v 1.22 2003/06/06 09:32:37 weasel Exp $
+# $Id: Tools.pm,v 1.23 2003/06/06 10:36:23 weasel Exp $
#
=pod
@@ -363,6 +363,20 @@ sub read_file($;$) {
return $result;
};
+sub cleanup_tmp() {
+ my $tmpdir = Echolot::Config::get()->{'tmpdir'};
+
+ opendir(DIR, $tmpdir) or
+ Echolot::Log::warn("Could not open '$tmpdir': $!."),
+ return undef;
+ my @files = grep { ! /^[.]/ } readdir(DIR);
+ closedir(DIR);
+
+ for my $file (@files) {
+ unlink($tmpdir.'/'.$file) or
+ Echolot::Log::warn("Could not unlink '$tmpdir/$file': $!.");
+ };
+};
1;