Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Move FILETEST-S to Rakudo::Internals
Also, no longer box the returned native int
  • Loading branch information
lizmat committed Jan 11, 2016
1 parent f90282b commit 6803444
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 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-S(Str $abspath) {
nqp::p6box_i(nqp::stat(nqp::unbox_s($abspath),nqp::const::STAT_FILESIZE) );
}
sub FILETEST-L(Str $abspath) {
nqp::p6bool(nqp::fileislink(nqp::unbox_s($abspath)));
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/IO/Local.pm
Expand Up @@ -51,7 +51,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:) { FILETEST-S( $!abspath) }
method s(IO::Local:D:) { Rakudo::Internals.FILETEST-S( $!abspath) }
method l(IO::Local:D:) { FILETEST-L( $!abspath) }
method r(IO::Local:D:) { FILETEST-R( $!abspath) }
method w(IO::Local:D:) { FILETEST-W( $!abspath) }
Expand Down
8 changes: 5 additions & 3 deletions src/core/IO/Path.pm
Expand Up @@ -548,9 +548,11 @@ my class IO::Path is Cool {
}

method s() {
fail X::IO::DoesNotExist.new(:path(self.Str),:trying<s>) if !$.e;
fail X::IO::NotAFile.new(:path(self.Str),:trying<s>) if !$.f;
FILETEST-S($!abspath);
$.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() {
Expand Down
3 changes: 3 additions & 0 deletions src/core/Rakudo/Internals.pm
Expand Up @@ -1011,6 +1011,9 @@ my class Rakudo::Internals {
method FILETEST-F(Str:D \abspath) {
nqp::stat(nqp::unbox_s(abspath),nqp::const::STAT_ISREG)
}
method FILETEST-S(Str:D \abspath) {
nqp::stat(nqp::unbox_s(abspath),nqp::const::STAT_FILESIZE)
}
}

# vim: ft=perl6 expandtab sw=4

0 comments on commit 6803444

Please sign in to comment.