Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[IO] implement sub form of spurt
  • Loading branch information
moritz committed Jul 6, 2012
1 parent 737fb0f commit b1aa031
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/core/IO.pm
Expand Up @@ -364,6 +364,25 @@ multi sub slurp(IO $io = $*ARGFILES) {
$io.slurp;
}

proto sub spurt(|$) { * }
multi sub spurt(Cool $filename,
Cool $contents,
:encoding(:$enc) = 'utf8',
:$append) {
my $mode = $append ?? :a !! :w;
my $fh = open($filename.Str, :$enc, |$mode);
$fh.print($contents);
$fh.close;
}
multi sub spurt(Cool $filename,
Buf $contents,
:$append) {
my $mode = $append ?? :a !! :w;
my $fh = open($filename.Str, :bin, |$mode);
$fh.write($contents);
$fh.close;
}

my class X::IO::Cwd { ... }
proto sub cwd(|$) { * }
multi sub cwd() {
Expand Down

0 comments on commit b1aa031

Please sign in to comment.