Skip to content

Commit ae065ac

Browse files
committed
Use nqp:: I/O ops for things in the setting.
1 parent 613cdac commit ae065ac

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/core/IO.pm

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ Open file.
1010

1111
sub open($filename, :$r, :$w, :$a, :$bin) {
1212
my $mode := $w ?? 'w' !! ($a ?? 'wa' !! 'r');
13-
my $handle := pir::new__Ps('FileHandle');
14-
$handle.open($filename, $mode);
15-
$handle.encoding($bin ?? 'binary' !! 'utf8');
13+
my $handle := nqp::open($filename, $mode);
14+
nqp::setencoding($handle, $bin ?? 'binary' !! 'utf8');
1615
$handle;
1716
}
1817

@@ -21,7 +20,7 @@ Close handle
2120
=end item
2221

2322
sub close($handle) {
24-
$handle.close();
23+
nqp::closefh($handle);
2524
}
2625

2726
=begin item slurp
@@ -30,8 +29,8 @@ Returns the contents of C<$filename> as a single string.
3029

3130
sub slurp ($filename) {
3231
my $handle := open($filename, :r);
33-
my $contents := $handle.readall;
34-
$handle.close();
32+
my $contents := nqp::readallfh($handle);
33+
nqp::closefh($handle);
3534
$contents;
3635
}
3736

@@ -42,8 +41,8 @@ Write the string value of C<$contents> to C<$filename>.
4241

4342
sub spew($filename, $contents) {
4443
my $handle := open($filename, :w);
45-
$handle.print($contents);
46-
$handle.close();
44+
nqp::printfh($handle, $contents);
45+
nqp::closefh($handle);
4746
}
4847

4948
sub print(*@args) {

0 commit comments

Comments
 (0)