Skip to content

Commit

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

sub FILETEST-RWX(Str $abspath) {
my str $p = nqp::unbox_s($abspath);
nqp::p6bool(
nqp::filereadable($p) && nqp::filewritable($p) && nqp::fileexecutable($p)
);
}
sub FILETEST-Z(Str $abspath) {
nqp::p6bool(nqp::stat(nqp::unbox_s($abspath),nqp::const::STAT_FILESIZE)==0);
}
Expand Down Expand Up @@ -195,7 +189,7 @@ sub FILETEST-ALL(Str $path, *@tests) {
if @tests.join -> $tests {
return Rakudo::Internals.FILETEST-R($path) if $tests eq "r";
return Rakudo::Internals.FILETEST-RW($path) if $tests eq "rw";
return FILETEST-RWX($path) if $tests eq "rwx";
return Rakudo::Internals.FILETEST-RWX($path) if $tests eq "rwx";
}

# nothing to check
Expand Down
2 changes: 1 addition & 1 deletion src/core/IO/Local.pm
Expand Up @@ -57,7 +57,7 @@ my role IO::Local {
method w(IO::Local:D:) { ?Rakudo::Internals.FILETEST-W( $!abspath) }
method rw(IO::Local:D:) { ?Rakudo::Internals.FILETEST-RW( $!abspath) }
method x(IO::Local:D:) { ?Rakudo::Internals.FILETEST-X( $!abspath) }
method rwx(IO::Local:D:) { FILETEST-RWX($!abspath) }
method rwx(IO::Local:D:) { ?Rakudo::Internals.FILETEST-RWX($!abspath) }
method z(IO::Local:D:) { FILETEST-Z( $!abspath) }
method modified(IO::Local:D:) { FILETEST-MODIFIED($!abspath) }
method accessed(IO::Local:D:) { FILETEST-ACCESSED($!abspath) }
Expand Down
7 changes: 4 additions & 3 deletions src/core/IO/Path.pm
Expand Up @@ -585,9 +585,10 @@ my class IO::Path is Cool {
!! fail X::IO::DoesNotExist.new(:path(~self),:trying<x>)
}

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

method z() {
Expand Down
6 changes: 6 additions & 0 deletions src/core/Rakudo/Internals.pm
Expand Up @@ -1030,6 +1030,12 @@ my class Rakudo::Internals {
method FILETEST-X(Str:D \abspath) {
nqp::fileexecutable(nqp::unbox_s(abspath))
}
method FILETEST-RWX(Str:D \abspath) {
my str $abspath = nqp::unbox_s(abspath);
nqp::filereadable($abspath)
&& nqp::filewritable($abspath)
&& nqp::fileexecutable($abspath)
}
}

# vim: ft=perl6 expandtab sw=4

0 comments on commit a9c8fe4

Please sign in to comment.