Skip to content

Commit

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

sub FILETEST-L(Str $abspath) {
nqp::p6bool(nqp::fileislink(nqp::unbox_s($abspath)));
}
sub FILETEST-R(Str $abspath) {
nqp::p6bool(nqp::filereadable(nqp::unbox_s($abspath)));
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/IO/Local.pm
Expand Up @@ -52,7 +52,7 @@ my role IO::Local {
method e(IO::Local:D:) { True }
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:) { FILETEST-L( $!abspath) }
method l(IO::Local:D:) { ?Rakudo::Internals.FILETEST-L( $!abspath) }
method r(IO::Local:D:) { FILETEST-R( $!abspath) }
method w(IO::Local:D:) { FILETEST-W( $!abspath) }
method rw(IO::Local:D:) { FILETEST-RW( $!abspath) }
Expand Down
11 changes: 6 additions & 5 deletions src/core/IO/Path.pm
Expand Up @@ -541,23 +541,24 @@ my class IO::Path is Cool {
!! fail X::IO::DoesNotExist.new(:path(~self),:trying<d>)
}

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

method s() {
method s(--> Int) {
$.e
?? $.f
?? Rakudo::Internals.FILETEST-S($!abspath)
!! fail X::IO::NotAFile.new(:path(~self),:trying<s>)
!! fail X::IO::DoesNotExist.new(:path(~self),:trying<s>)
}

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

method r() {
Expand Down
3 changes: 3 additions & 0 deletions src/core/Rakudo/Internals.pm
Expand Up @@ -1014,6 +1014,9 @@ my class Rakudo::Internals {
method FILETEST-S(Str:D \abspath) {
nqp::stat(nqp::unbox_s(abspath),nqp::const::STAT_FILESIZE)
}
method FILETEST-L(Str:D \abspath) {
nqp::fileislink(nqp::unbox_s(abspath))
}
}

# vim: ft=perl6 expandtab sw=4

0 comments on commit 18e981c

Please sign in to comment.