mason/.perl-lib/TrivGal.pm: Fix behaviour for `unreadable' directories.
authorMark Wooding <mdw@distorted.org.uk>
Fri, 29 Apr 2022 16:49:44 +0000 (17:49 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Fri, 29 Apr 2022 16:49:44 +0000 (17:49 +0100)
They can be listed in the parent, but their contents is secret.

mason/.perl-lib/TrivGal.pm

index 5b5cbfa..39c6913 100644 (file)
@@ -295,6 +295,9 @@ sub listdir ($) {
     if ($item && $comment) { $item->comment($comment); }
     close $f;
   } else {
+    my $st = stat "$path/$e";
+    unless ($st->mode&0004) { return ([], [], undef); }
+
     opendir $d, $path;
     my @e = readdir $d;
     closedir $d;
@@ -304,7 +307,7 @@ sub listdir ($) {
       my $dotp = $e =~ /^\./;
       my $st = stat "$path/$e";
       my $list = undef;
-      if ($dotp || !($st->mode&0004)) { }
+      if ($dotp) { }
       elsif (-d $st) { $list = \@d; }
       elsif ($TYPE{lc $ext} && -f $st) { $list = \@f; }
       $list and push @$list, TrivGal::Item->new($e);