Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
implement &dir
  • Loading branch information
moritz committed Aug 21, 2011
1 parent c05ba3a commit eee43c6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/core/IO.pm
Expand Up @@ -184,6 +184,19 @@ multi sub cwd() {
$! ?? fail($!) !! $pwd;
}

sub dir($path = '.', Mu :$test = none('.', '..')) {
my Mu $RSA := pir::new__PS('OS').readdir(nqp::unbox_s($path.Stringy));
my Int $elems := nqp::p6box_i(pir::set__IP($RSA));
my @res;
loop (my Int $i = 0; $i < $elems; $i++) {
my Str $item := nqp::p6box_s(nqp::atpos($RSA, nqp::unbox_i($i)));
@res.push: $item if $test.ACCEPTS($item);
}
say $elems;
@res;

}

$PROCESS::IN = open('-');
$PROCESS::OUT = open('-', :w);
$PROCESS::ERR = IO.new;
Expand Down
2 changes: 1 addition & 1 deletion t/spectest.data
Expand Up @@ -495,7 +495,7 @@ S32-hash/keys_values.t
S32-hash/pairs.t
# S32-hash/push.t # err: Cannot assign a non-Perl 6 value to a Perl 6 container
S32-hash/slice.t
# S32-io/dir.t # err: Could not find sub &dir
S32-io/dir.t
# S32-io/chdir.t # err: Method 'd' not found for invocant of class 'Str'
S32-io/file-tests.t
S32-io/note.t
Expand Down

0 comments on commit eee43c6

Please sign in to comment.