summaryrefslogtreecommitdiff
path: root/fml/lib/File/CacheDir.pm
diff options
context:
space:
mode:
authorfukachan <fukachan>2001-04-14 14:47:56 +0000
committerfukachan <fukachan>2001-04-14 14:47:56 +0000
commitc071d963a70363af88ba465f184b7ceca5d944c4 (patch)
tree5c7e697bd4c083f93f19f6e8de5fe2b10e7e4bd6 /fml/lib/File/CacheDir.pm
parent4852e070722a5e4300b5002ce9e041c636f98d1a (diff)
downloadfml8-c071d963a70363af88ba465f184b7ceca5d944c4.tar.gz
fml8-c071d963a70363af88ba465f184b7ceca5d944c4.tar.bz2
fml8-c071d963a70363af88ba465f184b7ceca5d944c4.zip
check the directory existence.
fix find() to search only \d+ files in the directory.
Diffstat (limited to 'fml/lib/File/CacheDir.pm')
-rw-r--r--fml/lib/File/CacheDir.pm12
1 files changed, 10 insertions, 2 deletions
diff --git a/fml/lib/File/CacheDir.pm b/fml/lib/File/CacheDir.pm
index c1a34d0d..247f0172 100644
--- a/fml/lib/File/CacheDir.pm
+++ b/fml/lib/File/CacheDir.pm
@@ -5,7 +5,7 @@
# redistribute it and/or modify it under the same terms as Perl itself.
#
# $Id$
-# $FML: CacheDir.pm,v 1.3 2001/04/04 14:47:55 fukachan Exp $
+# $FML: CacheDir.pm,v 1.4 2001/04/14 11:20:56 fukachan Exp $
#
package File::CacheDir;
@@ -136,6 +136,12 @@ sub _take_file_name
my $file;
use File::Spec;
+ unless (-d $directory) {
+ my $mode = $args->{ directory_mode } || 0755;
+ use File::Utils qw(mkdirhier);
+ mkdirhier($directory, $mode);
+ }
+
if ($cache_type eq 'temporal') {
my ($sec,$min,$hour,$mday,$mon,$year,$wday) = localtime(time);
my $file_name = sprintf("%04d%02d%02d", 1900+$year, $mon+1, $wday);
@@ -227,8 +233,10 @@ sub get_latest_value
my $dir = $self->{ _directory };
my $dh = new IO::Handle;
+ my @dh = ();
opendir($dh, $dir);
- my @dh = sort { $b <=> $a } readdir($dh);
+ for (readdir($dh)) { push(@dh, $_) if /^\d+/;}
+ @dh = sort { $b <=> $a } @dh;
for (@dh) {
next if $_ =~ /^\./;