Skip to content

Commit

Permalink
[IO] added :$bin parameter to &open and .open
Browse files Browse the repository at this point in the history
When called, the file is opened without expecting utf-8. The argument
'binary' to the .encoding method on the filehandle could actually have
been any non-'utf-8' string, since Parrot only has two modes right now.
  • Loading branch information
Carl Masak committed Jul 9, 2010
1 parent e58b166 commit 2d0a573
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/core/IO.pm
Expand Up @@ -35,7 +35,7 @@ class IO is Cool {
}
}

method open($filename, :$r, :$w, :$a) {
multi method open($filename, :$r, :$w, :$a, :$bin) {
if $!PIO { $!PIO.close; $!PIO = Nil; }
my $mode = $w ?? 'w' !! ($a ?? 'wa' !! 'r');
$!PIO = $filename eq '-'
Expand All @@ -44,7 +44,7 @@ class IO is Cool {
unless pir::istrue__IP($!PIO) {
fail("Unable to open file '$filename'");
}
$!PIO.encoding('utf8');
$!PIO.encoding($bin ?? 'binary' !! 'utf8');
self;
}

Expand Down Expand Up @@ -108,7 +108,7 @@ multi sub say(Mu *@items) { $*OUT.say(@items); }

sub getc($handle) { $handle.getc(); }

sub open($filename, :$r, :$w, :$a) {
sub open($filename, :$r, :$w, :$a, :$bin) {
my $mode = $w ?? 'w' !! ($a ?? 'wa' !! 'r');
my $PIO = pir::open__PSS($filename, $mode);
unless pir::istrue__IP($PIO) {
Expand Down

0 comments on commit 2d0a573

Please sign in to comment.