Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove FILETEST-E to Rakudo::Internals
Also, no longer booleanify for internal usage.
  • Loading branch information
lizmat committed Jan 11, 2016
1 parent 308c469 commit 14b73ac
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
15 changes: 6 additions & 9 deletions src/core/IO.pm
Expand Up @@ -42,16 +42,16 @@ sub CHANGE-DIRECTORY($path,$base,&test) {

my $abspath = Rakudo::Internals.MAKE-CLEAN-PARTS(
Rakudo::Internals.MAKE-ABSOLUTE-PATH($path,$base)).join('/');
FILETEST-E($abspath) && FILETEST-D($abspath) && test($abspath)
Rakudo::Internals.FILETEST-E($abspath)
&& FILETEST-D($abspath)
&& test($abspath)
?? IO::Path.new-from-absolute-path($abspath.chop)
!! fail X::IO::Chdir.new(
:$path,
:os-error( "does not exist, is not a dir or no access" ),
);
:$path, :os-error( "does not exist, is not a dir or no access" ))
}

sub COPY-FILE(Str $from, Str $to, :$createonly --> True) {
if $createonly and FILETEST-E($to) {
if $createonly && Rakudo::Internals.FILETEST-E($to) {
fail X::IO::Copy.new(
:$from,
:$to,
Expand All @@ -66,7 +66,7 @@ sub COPY-FILE(Str $from, Str $to, :$createonly --> True) {
}

sub RENAME-PATH(Str $from, Str $to, :$createonly --> True) {
if $createonly and FILETEST-E($to) {
if $createonly && Rakudo::Internals.FILETEST-E($to) {
fail X::IO::Rename.new(
:$from,
:$to,
Expand Down Expand Up @@ -122,9 +122,6 @@ sub REMOVE-DIR(Str $path --> True) {
} }
}

sub FILETEST-E(Str $abspath) {
nqp::p6bool( nqp::stat(nqp::unbox_s($abspath),nqp::const::STAT_EXISTS) );
}
sub FILETEST-D(Str $abspath) {
nqp::p6bool( nqp::stat(nqp::unbox_s($abspath),nqp::const::STAT_ISDIR) );
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/IO/Path.pm
Expand Up @@ -565,7 +565,7 @@ my class IO::Path is Cool {
$result;
}

method e() { $!e //= FILETEST-E($.abspath) }
method e() { $!e //= ?Rakudo::Internals.FILETEST-E($.abspath) }

method d() {
fail X::IO::DoesNotExist.new(:path(self.Str),:trying<d>) if !$.e;
Expand Down
4 changes: 4 additions & 0 deletions src/core/Rakudo/Internals.pm
Expand Up @@ -1001,6 +1001,10 @@ my class Rakudo::Internals {
?? nqp::p6box_s(nqp::substr($path,nqp::chars($root)))
!! path;
}

method FILETEST-E(Str:D \abspath) {
nqp::stat(nqp::unbox_s(abspath),nqp::const::STAT_EXISTS)
}
}

# vim: ft=perl6 expandtab sw=4

0 comments on commit 14b73ac

Please sign in to comment.