From: Mark Wooding Date: Thu, 15 Jun 2023 16:28:05 +0000 (+0100) Subject: mason/dhandler (.contact): Nudge index-scanning loop to focus on top level. X-Git-Url: https://git.distorted.org.uk/~mdw/tgal/commitdiff_plain/b0e94d8a6a8cfc0cb5f19f7bdfa110af15c8ca6e?hp=2306963b392cb67d27e354af3327be8bc9111ff1 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. --- 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; } }