From 43ddfa56142b05eb634e67f9eb458184251a389e Mon Sep 17 00:00:00 2001 From: Tony Cook Date: Thu, 1 Mar 2012 21:16:50 +1100 Subject: [PATCH] rt #111126 - don't empty a file with copy("foo/bar", "foo/"); --- lib/File/Copy.pm | 10 +++++----- lib/File/Copy.t | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/File/Copy.pm b/lib/File/Copy.pm index cb246d6..b5ca436 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 7975cfe..e46de35 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 -- 2.7.4