From f737ff7bb095f81ef1c28664fe77b72979436766 Mon Sep 17 00:00:00 2001 From: labster Date: Thu, 6 Jun 2013 15:16:35 -0700 Subject: [PATCH] move copy from IO::Handle to IO::Path, deprecate IO::Handle version --- src/core/IO.pm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/core/IO.pm b/src/core/IO.pm index 60b392a65ed..ce42f9452a9 100644 --- a/src/core/IO.pm +++ b/src/core/IO.pm @@ -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)); } @@ -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 }; }