Skip to content
Browse files

Reboostrap setting only.

  • Loading branch information...
1 parent 412953d commit b812ff74dd0b1672ed554e7b21cc36735133097a @bacek bacek committed Jan 6, 2011
Showing with 21 additions and 2 deletions.
  1. +21 −2 src/stage0/nqp-setting.nqp
View
23 src/stage0/nqp-setting.nqp
@@ -254,13 +254,32 @@ IO Methods and Functions
=end
+=begin item open
+Open file.
+=end item
+
+sub open($filename, :$r, :$w, :$a, :$bin) {
+ my $mode := $w ?? 'w' !! ($a ?? 'wa' !! 'r');
+ my $handle := pir::new__Ps('FileHandle');
+ $handle.open($filename, $mode);
+ $handle.encoding($bin ?? 'binary' !! 'utf8');
+ $handle;
+}
+
+=begin item close
+Close handle
+=end item
+
+sub close($handle) {
+ $handle.close();
+}
+
=begin item slurp
Returns the contents of C<$filename> as a single string.
=end item
our sub slurp ($filename) {
- my $handle := pir::new__Ps('FileHandle');
- $handle.open($filename, 'r');
+ my $handle := open($filename, :r);
my $contents := $handle.readall;
$handle.close();
$contents;

0 comments on commit b812ff7

Please sign in to comment.
Something went wrong with that request. Please try again.