rt #111126 - don't empty a file with copy("foo/bar", "foo/");
authorTony Cook <tony@develop-help.com>
Thu, 1 Mar 2012 10:16:50 +0000 (21:16 +1100)
committerTony Cook <tony@develop-help.com>
Fri, 24 Aug 2012 10:32:12 +0000 (20:32 +1000)
lib/File/Copy.pm
lib/File/Copy.t

index cb246d6..b5ca436 100644 (file)
@@ -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
index 7975cfe..e46de35 100644 (file)
@@ -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