Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[io grant] Fix IO::Path.copy/move when source/target are same
  • Loading branch information
zoffixznet committed May 2, 2017
1 parent c61c7f8 commit 08a8075
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/core/IO/Path.pm
Expand Up @@ -473,7 +473,15 @@ my class IO::Path is Cool does IO {
:to($to.absolute),
:os-error(':createonly specified and destination exists');

nqp::copy($.absolute, nqp::unbox_s($to.absolute));
# XXX TODO: maybe move the sameness check to the nqp OP/VM
nqp::if(
nqp::iseq_s(
(my $from-abs := $.absolute),
(my $to-abs := $to.absolute)),
X::IO::Copy.new(:from($from-abs), :to($to-abs),
:os-error('source and target are the same')).fail,
nqp::copy($from-abs, $to-abs));

CATCH { default {
fail X::IO::Copy.new:
:from($!abspath), :to($to.absolute), :os-error(.Str)
Expand Down

0 comments on commit 08a8075

Please sign in to comment.