Skip to content

Commit

Permalink
Add naive $*SPEC.extension for basenames
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Oct 5, 2014
1 parent 2662e01 commit 205b588
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/core/IO/Spec/Unix.pm
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ my class IO::Spec::Unix is IO::Spec {
!! path.substr( nqp::box_i($index + 1,Int) );
}

method extension(\path) {
my str $str = nqp::unbox_s(path);
my int $index = nqp::rindex($str,'.');
nqp::p6bool($index == -1)
?? ''
!! path.substr( nqp::box_i($index + 1,Int) );
}

method tmpdir {
self.canonpath: first( { .defined && .IO.d && .IO.w },
%*ENV<TMPDIR>,
Expand Down

0 comments on commit 205b588

Please sign in to comment.