From b0e94d8a6a8cfc0cb5f19f7bdfa110af15c8ca6e Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Thu, 15 Jun 2023 17:28:05 +0100 Subject: [PATCH] mason/dhandler (.contact): Nudge index-scanning loop to focus on top level. If, say, we want to do something else with the direct contents of the directory, then it would be nice if this were easy. Pull the variable declarations out, pull an initial priming call to `listdir' out, and move the inner `listdir' to the end of the loop. --- mason/dhandler | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mason/dhandler b/mason/dhandler index de50cd8..94c39cc 100755 --- a/mason/dhandler +++ b/mason/dhandler @@ -89,8 +89,9 @@ Failed to find ‘<% $path |h %>’. { $tn{$f} = TrivGal::Image->new($path . $f->name)->scale($size); } for my $d (@$dd) { my $p = join_paths $path, $d->name; + my ($ddd, $fff, $iii); + ($ddd, $fff, $iii) = listdir join_paths $IMGROOT, $p; DIR: for (;;) { - my ($ddd, $fff, $iii) = listdir join_paths $IMGROOT, $p; if (defined $iii) { my $index = join_paths $p, $iii->name; $tn{$d} = TrivGal::Image->new($index)->scale($size); @@ -98,6 +99,7 @@ Failed to find ‘<% $path |h %>’. } if (!@$ddd) { $tn{$d} = undef; last DIR; } $p = join_paths $p, $ddd->[0]->name; + ($ddd, $fff, $iii) = listdir join_paths $IMGROOT, $p; } } -- 2.11.0