Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Move FILETEST-RW to Rakudo::Internals
  • Loading branch information
lizmat committed Jan 11, 2016
1 parent fe726c0 commit 43b5642
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
6 changes: 1 addition & 5 deletions src/core/IO.pm
Expand Up @@ -122,10 +122,6 @@ sub REMOVE-DIR(Str $path --> True) {
} }
}

sub FILETEST-RW(Str $abspath) {
my str $p = nqp::unbox_s($abspath);
nqp::p6bool(nqp::filereadable($p) && nqp::filewritable($p));
}
sub FILETEST-X(Str $abspath) {
nqp::p6bool(nqp::fileexecutable(nqp::unbox_s($abspath)));
}
Expand Down Expand Up @@ -201,7 +197,7 @@ sub FILETEST-ALL(Str $path, *@tests) {
# most common cases
if @tests.join -> $tests {
return Rakudo::Internals.FILETEST-R($path) if $tests eq "r";
return FILETEST-RW($path) if $tests eq "rw";
return Rakudo::Internals.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 @@ -55,7 +55,7 @@ my role IO::Local {
method l(IO::Local:D:) { ?Rakudo::Internals.FILETEST-L( $!abspath) }
method r(IO::Local:D:) { ?Rakudo::Internals.FILETEST-R( $!abspath) }
method w(IO::Local:D:) { ?Rakudo::Internals.FILETEST-W( $!abspath) }
method rw(IO::Local:D:) { FILETEST-RW( $!abspath) }
method rw(IO::Local:D:) { ?Rakudo::Internals.FILETEST-RW( $!abspath) }
method x(IO::Local:D:) { FILETEST-X( $!abspath) }
method rwx(IO::Local:D:) { FILETEST-RWX($!abspath) }
method z(IO::Local:D:) { FILETEST-Z( $!abspath) }
Expand Down
7 changes: 4 additions & 3 deletions src/core/IO/Path.pm
Expand Up @@ -573,9 +573,10 @@ my class IO::Path is Cool {
!! fail X::IO::DoesNotExist.new(:path(~self),:trying<w>)
}

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

method x() {
Expand Down
4 changes: 4 additions & 0 deletions src/core/Rakudo/Internals.pm
Expand Up @@ -1023,6 +1023,10 @@ my class Rakudo::Internals {
method FILETEST-W(Str:D \abspath) {
nqp::filewritable(nqp::unbox_s(abspath))
}
method FILETEST-RW(Str:D \abspath) {
my str $abspath = nqp::unbox_s(abspath);
nqp::filereadable($abspath) && nqp::filewritable($abspath)
}
}

# vim: ft=perl6 expandtab sw=4

0 comments on commit 43b5642

Please sign in to comment.