Permalink
Browse files

guard against failed opendir(); use lexical directory handle

  • Loading branch information...
1 parent 49f0db6 commit 8148c00f75329f17a968f1aec6532de6fba3df6e @moritz committed Jun 24, 2011
Showing with 6 additions and 4 deletions.
  1. +2 −0 Changelog
  2. +4 −4 lib/App/Mowyw.pm
View
@@ -1,3 +1,5 @@
+mowyw (0.7.2)
+ * lib/App/Mowyw.pm: guard against failed opendir()
mowyw (0.7.1)
* script/mowyw: remove some fallout from the Mowyw -> App::Mowyw
transition (Kurt Tomlinson)
View
@@ -3,7 +3,7 @@ use strict;
use warnings;
#use warnings FATAL => 'all';
-our $VERSION = '0.7.1';
+our $VERSION = '0.7.2';
use App::Mowyw::Lexer qw(lex);
use App::Mowyw::Datasource;
@@ -80,8 +80,8 @@ sub parse_all_in_dir {
my @todo = @_;
while (my $fn = pop @todo){
$fn .= '/' unless ($fn =~ m#/$#);
- opendir DIR, $fn;
- IW: while (my $f = readdir DIR){
+ opendir my $DIR, $fn or die "Cannot opend directory '$fn' for reading: $!";
+ IW: while (my $f = readdir $DIR){
# ignore symbolic links and non-Readable files:
next IW if (-l $f);
# if we consider . and .., we loop infinetly.
@@ -102,7 +102,7 @@ sub parse_all_in_dir {
process_file($f);
}
}
- closedir DIR;
+ closedir $DIR;
}
}

0 comments on commit 8148c00

Please sign in to comment.