Browse files

move copy from IO::Handle to IO::Path, deprecate IO::Handle version

  • Loading branch information...
1 parent 57e740a commit f737ff7bb095f81ef1c28664fe77b72979436766 @labster labster committed Jun 6, 2013
Showing with 12 additions and 0 deletions.
  1. +12 −0 src/core/IO.pm
View
12 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 }; }

0 comments on commit f737ff7

Please sign in to comment.