Skip to content

Commit

Permalink
Set that on successful open/mkdir/spurt
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Nov 30, 2014
1 parent 8b565a6 commit db00491
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/core/IOU.pm
Expand Up @@ -20,9 +20,21 @@ my class IOU {

method IO(IOU:D:) { $!that // self }

method open(IOU:D: |c) { open($!abspath,|c) }
method mkdir(IOU:D: |c) { mkdir($!abspath,|c) }
method spurt(IOU:D: \what, |c) { spurt($!abspath,what,|c) }
method open(IOU:D: |c) {
my $handle = open($!abspath,|c);
$!that = IO::File.new(:$!abspath) if $handle;
$handle;
}
method mkdir(IOU:D: |c) {
my $result = mkdir($!abspath,|c);
$!that = IO::Dir.new(:$!abspath) if $result;
$result;
}
method spurt(IOU:D: \what, |c) {
my $result = spurt($!abspath,what,|c);
$!that = IO::File.new(:$!abspath) if $result;
$result;
}

multi method Str(IOU:D:) { $!this }
multi method gist(IOU:D:) { qq|"$!this".IO| }
Expand Down

0 comments on commit db00491

Please sign in to comment.