Permalink
Browse files

Make it work after &dir changes

  • Loading branch information...
1 parent a644578 commit d3123eaa3e06cae3e3619d24d979e52af1f839f4 @tadzik tadzik committed Jun 29, 2012
Showing with 15 additions and 6 deletions.
  1. +15 −6 bin/ufo
View
21 bin/ufo
@@ -157,14 +157,23 @@ sub find-file-by-ext(@dirs, *@ext) {
}
}
+sub basename(Str $path) {
+ my $slash = $path.rindex('/');
+ if $slash {
+ return $path.substr($slash + 1)
+ }
+ return $path
+}
+
sub dirwalk(Str $dir = '.', Mu :$d = none(<. ..>), Mu :$f = *, :&dx = -> $ {}, :&fx = -> $ {}) {
- for dir($dir, :test(*)) {
- when .f {
- fx($path) if $path ~~ $f
+ for dir($dir, :test(*)) -> $p {
+ when $p.f {
+ fx($p.path) if $p.path ~~ $f
+ }
+ when $p.d {
+ dirwalk($p.path, :$d, :$f, :&dx, :&fx)
+ if basename($p.path) ~~ $d;
}
- when .d {
- dirwalk(.path, :$d, :$f, :&dx, :&fx) if $p ~~ $d;
- }
}
dx($dir) if $dir ~~ $d;
}

0 comments on commit d3123ea

Please sign in to comment.