summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2012-03-01 21:16:50 +1100
committerTony Cook <tony@develop-help.com>2012-08-24 20:32:12 +1000
commit43ddfa56142b05eb634e67f9eb458184251a389e (patch)
tree86d3f2b27abae5c3324fb72b16c75fffca3af95c /lib
parentb306ad7b4bea67081ddb83601fc8bddf296e7905 (diff)
downloadperl-43ddfa56142b05eb634e67f9eb458184251a389e.tar.gz
rt #111126 - don't empty a file with copy("foo/bar", "foo/");
Diffstat (limited to 'lib')
-rw-r--r--lib/File/Copy.pm10
-rw-r--r--lib/File/Copy.t1
2 files changed, 5 insertions, 6 deletions
diff --git a/lib/File/Copy.pm b/lib/File/Copy.pm
index cb246d645f..b5ca436618 100644
--- a/lib/File/Copy.pm
+++ b/lib/File/Copy.pm
@@ -22,7 +22,7 @@ sub syscopy;
sub cp;
sub mv;
-$VERSION = '2.23';
+$VERSION = '2.24';
require Exporter;
@ISA = qw(Exporter);
@@ -133,6 +133,10 @@ sub copy {
return 1;
}
+ if (!$from_a_handle && !$to_a_handle && -d $to && ! -d $from) {
+ $to = _catname($from, $to);
+ }
+
if ((($Config{d_symlink} && $Config{d_readlink}) || $Config{d_link}) &&
!($^O eq 'MSWin32' || $^O eq 'os2')) {
my @fs = stat($from);
@@ -145,10 +149,6 @@ sub copy {
}
}
- if (!$from_a_handle && !$to_a_handle && -d $to && ! -d $from) {
- $to = _catname($from, $to);
- }
-
if (defined &syscopy && !$Syscopy_is_copy
&& !$to_a_handle
&& !($from_a_handle && $^O eq 'os2' ) # OS/2 cannot handle handles
diff --git a/lib/File/Copy.t b/lib/File/Copy.t
index 7975cfecbd..e46de358f6 100644
--- a/lib/File/Copy.t
+++ b/lib/File/Copy.t
@@ -476,7 +476,6 @@ use File::Temp qw(tempdir);
use File::Spec;
SKIP: {
- local $TODO = "copy foo/file to foo/ overwrites, RT #111126";
# RT #111126: File::Copy copy() zeros file when copying a file
# into the same directory it is stored in