Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Deprecate $handle.slurp -> slurp-rest
  • Loading branch information
lizmat committed Nov 7, 2014
1 parent 2b57f3f commit a0304c3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
15 changes: 9 additions & 6 deletions src/core/IO/Handle.pm
Expand Up @@ -135,7 +135,7 @@ my class IO::Handle does IO {
$!ins = $!ins + 1;
$x;
}

method getc(IO::Handle:D:) {
my $c = nqp::p6box_s(nqp::getcfh($!PIO));
fail if $c eq '';
Expand Down Expand Up @@ -479,10 +479,13 @@ my class IO::Handle does IO {
self.print: nqp::shift($args).gist while $args;
self.print: "\n";
}

method slurp(IO::Handle:D: :$bin, :$enc, :$nodepr) {
DEPRECATED("IO::Path.slurp", |<2014.10 2015.10>) unless $nodepr;

method slurp(IO::Handle:D: |c) {
DEPRECATED('$handle.slurp-rest', |<2014.10 2015.10>);
self.slurp-rest(|c);
}

method slurp-rest(IO::Handle:D: :$bin, :$enc) {
if $bin {
my $Buf := buf8.new();
loop {
Expand All @@ -496,15 +499,15 @@ my class IO::Handle does IO {
else {
self.encoding($enc) if $enc.defined;
nqp::p6box_s(nqp::readallfh($!PIO));
}
}
}

proto method spurt(|) { * }
multi method spurt(IO::Handle:D: Cool $contents, :$nodepr) {
DEPRECATED("IO::Path.spurt", |<2014.10 2015.10>) unless $nodepr;
self.print($contents);
}

multi method spurt(IO::Handle:D: Blob $contents, :$nodepr) {
DEPRECATED("IO::Path.spurt", |<2014.10 2015.10>) unless $nodepr;
self.write($contents);
Expand Down
6 changes: 3 additions & 3 deletions src/core/io_operators.pm
Expand Up @@ -99,7 +99,7 @@ multi sub close($fh) {
proto sub slurp(|) { * }
multi sub slurp(IO::Handle $io = $*ARGFILES, :$bin, :$enc = 'utf8', |c) {
DEPRECATED('slurp($path,...)',|<2014.10 2015.10>,:what<slurp($handle,...)>);
my $result := $io.slurp(:$bin, :$enc, :nodepr, |c);
my $result := $io.slurp-rest(:$bin, :$enc, |c);
$result // $result.throw;
}
multi sub slurp($path, :$bin = False, :$enc = 'utf8', |c) {
Expand Down Expand Up @@ -150,7 +150,7 @@ sub chdir($path as Str) {
sub indir($path as Str, $what, :$test = <r w>) {
my $newCWD := CHANGE-DIRECTORY($path,$*CWD ~ '/',&FILETEST-RWX);
$newCWD // $newCWD.throw;

{
my $*CWD = $newCWD; # temp doesn't work in core settings :-(
$what();
Expand Down Expand Up @@ -244,6 +244,6 @@ sub link($target, $name, :$SPEC = $*SPEC, :$CWD = $*CWD) {
sub cwd() {
DEPRECATED('$*CWD', |<2014.10 2015.10>);
$*CWD;
}
}

# vim: ft=perl6 expandtab sw=4

0 comments on commit a0304c3

Please sign in to comment.