From: Michael G. Schwern Date: Mon, 11 Jul 2005 17:35:14 +0000 (-0700) Subject: Re: [perl #36502] File::Copy::mv fails to replicate behavior of Unix mv X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=762548ba14cb03ab1e8e076574a2a58cba3772a1;p=p5sagit%2Fp5-mst-13.2.git Re: [perl #36502] File::Copy::mv fails to replicate behavior of Unix mv Message-ID: <20050712003514.GA20132@windhund.schwern.org> p4raw-id: //depot/perl@25120 --- diff --git a/lib/File/Copy.pm b/lib/File/Copy.pm index 828473e..6316b97 100644 --- a/lib/File/Copy.pm +++ b/lib/File/Copy.pm @@ -205,7 +205,17 @@ sub move { $tosz2 == $fromsz; # it's all there ($tosz1,$tomt1) = (stat($to))[7,9]; # just in case rename did something - return 1 if copy($from,$to) && unlink($from); + + { + local $@; + eval { + copy($from,$to) or die; + my($atime, $mtime) = (stat($from))[8,9]; + utime($atime, $mtime, $to); + unlink($from) or die; + }; + return 1 unless $@; + } ($sts,$ossts) = ($! + 0, $^E + 0); ($tosz2,$tomt2) = ((stat($to))[7,9],0,0) if defined $tomt1;