Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Move FILETEST-Z to Rakudo::Internals
  • Loading branch information
lizmat committed Jan 11, 2016
1 parent a9c8fe4 commit 0c4db8d
Show file tree
Hide file tree
Showing 4 changed files with 10 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-Z(Str $abspath) {
nqp::p6bool(nqp::stat(nqp::unbox_s($abspath),nqp::const::STAT_FILESIZE)==0);
}
#?if moar
sub FILETEST-MODIFIED(Str $abspath) {
Instant.from-posix( nqp::p6box_n(
Expand Down
2 changes: 1 addition & 1 deletion src/core/IO/Local.pm
Expand Up @@ -58,7 +58,7 @@ my role IO::Local {
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:) { ?Rakudo::Internals.FILETEST-RWX($!abspath) }
method z(IO::Local:D:) { FILETEST-Z( $!abspath) }
method z(IO::Local:D:) { ?Rakudo::Internals.FILETEST-Z( $!abspath) }
method modified(IO::Local:D:) { FILETEST-MODIFIED($!abspath) }
method accessed(IO::Local:D:) { FILETEST-ACCESSED($!abspath) }
method changed(IO::Local:D:) { FILETEST-CHANGED( $!abspath) }
Expand Down
8 changes: 5 additions & 3 deletions src/core/IO/Path.pm
Expand Up @@ -592,9 +592,11 @@ my class IO::Path is Cool {
}

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

method modified() {
Expand Down
4 changes: 4 additions & 0 deletions src/core/Rakudo/Internals.pm
Expand Up @@ -1036,6 +1036,10 @@ my class Rakudo::Internals {
&& nqp::filewritable($abspath)
&& nqp::fileexecutable($abspath)
}
method FILETEST-Z(Str:D \abspath) {
nqp::iseq_i(
nqp::stat(nqp::unbox_s(abspath),nqp::const::STAT_FILESIZE),0)
}
}

# vim: ft=perl6 expandtab sw=4

0 comments on commit 0c4db8d

Please sign in to comment.