Created
June 29, 2012 21:04
-
-
Save moritz/3020637 to your computer and use it in GitHub Desktop.
File::Find patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/File/Find.pm b/lib/File/Find.pm | |
index c649980..9986078 100644 | |
--- a/lib/File/Find.pm | |
+++ b/lib/File/Find.pm | |
@@ -44,13 +44,9 @@ sub checkrules ($elem, %opts) { | |
return True | |
} | |
-sub file-from-path($path) { | |
- $path.split('/')[*-1]; | |
-} | |
- | |
sub find (:$dir!, :$name, :$type) is export { | |
my @targets = dir($dir).map: { | |
- File::Find::Result.new(dir => $dir, name => file-from-path(.path)); | |
+ File::Find::Result.new(dir => $dir, name => .basename); | |
}; | |
my $list = gather while @targets { | |
my $elem = @targets.shift; | |
@@ -58,7 +54,7 @@ sub find (:$dir!, :$name, :$type) is export { | |
if $elem.IO ~~ :d { | |
for dir($elem) -> $file { | |
@targets.push( | |
- File::Find::Result.new(dir => $elem, name => file-from-path($file.path)) | |
+ File::Find::Result.new(dir => $elem, name => $file.basename) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment