Skip to content

Commit

Permalink
Adapted merge
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Nov 27, 2014
1 parent 8bbcb2f commit 73b2124
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
6 changes: 2 additions & 4 deletions src/core/IO/ArgFiles.pm
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@ my class IO::ArgFiles is IO::Handle {
$!io.close;
}
while $!args {
my $fn = $!args.shift;
my $file = open($fn);
@chunks.push: $file.slurp;
@chunks.push: slurp $!args.shift;
}
return $*IN.slurp unless @chunks;
return $*IN.slurp-rest unless @chunks;
@chunks.join;
}
}
Expand Down
14 changes: 9 additions & 5 deletions src/core/io_operators.pm
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
my class IO::ArgFiles { ... }

sub print(|) {
my $args := nqp::p6argvmarray();
my $out := $*OUT;
Expand Down Expand Up @@ -196,15 +198,17 @@ multi sub close($fh) {
}

proto sub slurp(|) { * }
multi sub slurp(IO::Handle $io = $*ARGFILES, :$bin, :$enc = 'utf8', |c) {
multi sub slurp(IO::ArgFiles:D $io = $*ARGFILES, :$bin, :$enc = 'utf8', |c) {
my $result := $io.slurp(:$bin, :$enc, |c);
$result // $result.throw;
}
multi sub slurp(IO::Handle:D $io = $*ARGFILES, :$bin, :$enc = 'utf8', |c) {
DEPRECATED('slurp($path,...)',|<2014.10 2015.10>,:what<slurp($handle,...)>);
my $result := $io.slurp-rest(:$bin, :$enc, |c);
$result // $result.throw;
}
multi sub slurp($path, :$bin = False, :$enc = 'utf8', |c) {
my $handle := open($path,:$bin,:$enc,|c);
$handle // $handle.throw;
my $result := $handle.slurp-rest(:$bin, :$enc, |c);
multi sub slurp(Cool:D $path, :$bin = False, :$enc = 'utf8', |c) {
my $result := $path.IO.slurp(:$bin, :$enc, |c);
$result // $result.throw;
}

Expand Down

0 comments on commit 73b2124

Please sign in to comment.