Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Streamline spurt functionality
  • Loading branch information
lizmat committed Nov 30, 2014
1 parent b0605fc commit 8b565a6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/core/IO.pm
Expand Up @@ -213,7 +213,7 @@ sub SLURP-PATH(Str $path,:$encoding,:$bin,:$enc,|c) {
slurped;
}

sub SPURT-PATH(Str $path,$what,:$encoding,:$append,:$createonly,:$bin,:$enc,|c) {
sub SPURT-PATH(Str $path,\what,:$encoding,:$append,:$createonly,:$bin,:$enc,|c) {
if $createonly and FILETEST-E($path) {
fail("File '$path' already exists, and :createonly was specified");
}
Expand All @@ -223,8 +223,8 @@ sub SPURT-PATH(Str $path,$what,:$encoding,:$append,:$createonly,:$bin,:$enc,|c)
$handle // $handle.throw;

my $spurt := $bin
?? $handle.write($what)
!! $handle.print($what);
?? $handle.write(what)
!! $handle.print(what);
$handle.close; # can't use LEAVE in settings :-(
$spurt;
}
Expand Down
8 changes: 4 additions & 4 deletions src/core/io_operators.pm
Expand Up @@ -176,15 +176,15 @@ multi sub slurp(Cool:D $path, :$enc, |c) {
}

proto sub spurt(|) { * }
multi sub spurt(IO::Handle:D $fh, $what,|c ) {
multi sub spurt(IO::Handle:D $fh,\what,|c ) {
DEPRECATED('spurt($path,...)',|<2014.10 2015.10>,:what<spurt($handle,...)>);
my $result := $fh.spurt($what,:nodepr,|c);
my $result := $fh.spurt(what,:nodepr,|c);
$result // $result.throw;
}
multi sub spurt(Cool:D $path,$what,:$enc,|c) {
multi sub spurt(Cool:D $path,\what,:$enc,|c) {
DEPRECATED(":encoding($enc)",|<2014.12 2015.12>,:what(":enc($enc)"))
if $enc;
my $result := SPURT-PATH(MAKE-ABSOLUTE-PATH($path,$*CWD),$what,:$enc,|c);
my $result := SPURT-PATH(MAKE-ABSOLUTE-PATH($path,$*CWD),what,:$enc,|c);
$result // $result.throw;
}

Expand Down

0 comments on commit 8b565a6

Please sign in to comment.