Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #480 from jonathanstowe/slurp-rest-multi
Make IO::Handle.spurt-rest a multi
  • Loading branch information
FROGGS committed Jul 27, 2015
2 parents 9ed640c + 8a46049 commit e3314c8
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/core/IO/Handle.pm
Expand Up @@ -512,21 +512,20 @@ my class IO::Handle does IO {
self.slurp-rest(|c);
}

method slurp-rest(IO::Handle:D: :$bin, :$enc) {
if $bin {
my $Buf := buf8.new();
loop {
my $buf := buf8.new();
nqp::readfh($!PIO,$buf,65536);
last if $buf.bytes == 0;
$Buf := $Buf ~ $buf;
}
$Buf;
}
else {
self.encoding($enc) if $enc.defined;
nqp::p6box_s(nqp::readallfh($!PIO));
proto method slurp-rest(|) { * }
multi method slurp-rest(IO::Handle:D: :$bin!) returns Buf {
my $Buf := buf8.new();
loop {
my $buf := buf8.new();
nqp::readfh($!PIO,$buf,65536);
last if $buf.bytes == 0;
$Buf := $Buf ~ $buf;
}
$Buf;
}
multi method slurp-rest(IO::Handle:D: :$enc) returns Str {
self.encoding($enc) if $enc.defined;
nqp::p6box_s(nqp::readallfh($!PIO));
}

proto method spurt(|) { * }
Expand Down

0 comments on commit e3314c8

Please sign in to comment.