Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Move FILETEST-R to Rakudo::Internals
Also, no longer booleanify for internal usage.
  • Loading branch information
lizmat committed Jan 11, 2016
1 parent 18e981c commit 42191ca
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
5 changes: 1 addition & 4 deletions src/core/IO.pm
Expand Up @@ -122,9 +122,6 @@ sub REMOVE-DIR(Str $path --> True) {
} }
}

sub FILETEST-R(Str $abspath) {
nqp::p6bool(nqp::filereadable(nqp::unbox_s($abspath)));
}
sub FILETEST-W(Str $abspath) {
nqp::p6bool(nqp::filewritable(nqp::unbox_s($abspath)));
}
Expand Down Expand Up @@ -206,7 +203,7 @@ sub FILETEST-ALL(Str $path, *@tests) {

# most common cases
if @tests.join -> $tests {
return FILETEST-R($path) if $tests eq "r";
return Rakudo::Internals.FILETEST-R($path) if $tests eq "r";
return FILETEST-RW($path) if $tests eq "rw";
return FILETEST-RWX($path) if $tests eq "rwx";
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/IO/Local.pm
Expand Up @@ -53,7 +53,7 @@ my role IO::Local {
method f(IO::Local:D:) { ?Rakudo::Internals.FILETEST-F( $!abspath) }
method s(IO::Local:D:) { Rakudo::Internals.FILETEST-S( $!abspath) }
method l(IO::Local:D:) { ?Rakudo::Internals.FILETEST-L( $!abspath) }
method r(IO::Local:D:) { FILETEST-R( $!abspath) }
method r(IO::Local:D:) { ?Rakudo::Internals.FILETEST-R( $!abspath) }
method w(IO::Local:D:) { FILETEST-W( $!abspath) }
method rw(IO::Local:D:) { FILETEST-RW( $!abspath) }
method x(IO::Local:D:) { FILETEST-X( $!abspath) }
Expand Down
7 changes: 4 additions & 3 deletions src/core/IO/Path.pm
Expand Up @@ -561,9 +561,10 @@ my class IO::Path is Cool {
!! fail X::IO::DoesNotExist.new(:path(~self),:trying<l>)
}

method r() {
fail X::IO::DoesNotExist.new(:path(self.Str),:trying<r>) if !$.e;
FILETEST-R($!abspath);
method r(--> Bool) {
$.e
?? ?Rakudo::Internals.FILETEST-R($!abspath)
!! fail X::IO::DoesNotExist.new(:path(~self),:trying<r>)
}

method w() {
Expand Down
3 changes: 3 additions & 0 deletions src/core/Rakudo/Internals.pm
Expand Up @@ -1017,6 +1017,9 @@ my class Rakudo::Internals {
method FILETEST-L(Str:D \abspath) {
nqp::fileislink(nqp::unbox_s(abspath))
}
method FILETEST-R(Str:D \abspath) {
nqp::filereadable(nqp::unbox_s(abspath))
}
}

# vim: ft=perl6 expandtab sw=4

0 comments on commit 42191ca

Please sign in to comment.