Permalink
Browse files

implement IO::Path::contents on jvm w/ nqp::opendir, ...

  • Loading branch information...
1 parent 2118544 commit 1ca2ea24ace3d951f445249abb323696be43b0ad @timo timo committed Jun 29, 2013
Showing with 18 additions and 2 deletions.
  1. +18 −2 src/core/IO.pm
View
@@ -458,8 +458,24 @@ my class IO::Path is Cool does IO::FileTestable {
}
}
#?endif
-#?if !parrot
- die "dir is NYI on JVM backend";
+#?if jvm
+ my Mu $dirh := nqp::opendir($!path);
+ my $next = 1;
+ gather {
+ take $_.path if $_ ~~ $test for ".", "..";
+ while $next {
+ my Str $elem := nqp::nextfiledir($dirh);
+ if nqp::isnull_s($elem) {
+ nqp::closedir($dirh);
+ $next = 0;
+ } else {
+ if $elem.substr(0, 2) eq "./" {
+ $elem := $elem.substr(2);
+ }
+ take $elem.path if $elem ~~ $test;
+ }
+ }
+ }
#?endif
}

0 comments on commit 1ca2ea2

Please sign in to comment.