Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
more consistent exception for IO.copy
also remove unnecessary special case that could lead to race conditions
  • Loading branch information
moritz committed May 27, 2012
1 parent 5f81da3 commit 3003279
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/core/IO.pm
@@ -1,3 +1,5 @@
my class X::IO::Copy { ... }

sub print(|$) {
my $args := pir::perl6_current_args_rpa__P();
$*OUT.print(nqp::shift($args)) while $args;
Expand Down Expand Up @@ -203,13 +205,10 @@ class IO {

# not spec'd
method copy($dest) {
if self.d() {
die "Cannot copy '$.path': Is a directory"
}
try {
pir::new__PS('File').copy(nqp::unbox_s(~$.path), nqp::unbox_s(~$dest));
}
$! ?? fail($!) !! True
$! ?? fail(X::IO::Copy.new(from => $.path, to => $dest, os-error => ~$!)) !! True
}

my class X::IO::Chmod { ... }
Expand Down Expand Up @@ -383,7 +382,6 @@ sub rename(Cool $from as Str, Cool $to as Str) {
}
}
}
my class X::IO::Copy { ... }
sub copy(Cool $from as Str, Cool $to as Str) {
pir::new__PS('File').copy(nqp::unbox_s($from), nqp::unbox_s($to));
return True;
Expand Down

0 comments on commit 3003279

Please sign in to comment.