Skip to content

Commit

Permalink
move copy from IO::Handle to IO::Path, deprecate IO::Handle version
Browse files Browse the repository at this point in the history
  • Loading branch information
labster committed Jun 6, 2013
1 parent 57e740a commit f737ff7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/core/IO.pm
Expand Up @@ -254,6 +254,7 @@ my class IO::Handle does IO::FileTestable {

# not spec'd
method copy($dest) {
warn "IO::Handle.copy is deprecated. Please use IO::Path.copy instead.";
try {
nqp::copy(nqp::unbox_s(~$!path), nqp::unbox_s(~$dest));
}
Expand Down Expand Up @@ -399,6 +400,17 @@ my class IO::Path is Cool does IO::FileTestable {
$childname);
}

method copy($dest, :$createonly = False) {
if $createonly and $dest.path.e {
fail(X::IO::Copy.new(from => $.Str, to => $dest,
os-error => "Destination file $dest exists and :createonly passed to copy."));
}
try {
nqp::copy(nqp::unbox_s($.Str), nqp::unbox_s(~$dest));
}
$! ?? fail(X::IO::Copy.new(from => $.Str, to => $dest, os-error => ~$!)) !! True
}

}

my class IO::Path::Unix is IO::Path { method SPEC { IO::Spec::Unix }; }
Expand Down

0 comments on commit f737ff7

Please sign in to comment.