summaryrefslogtreecommitdiff
path: root/lib/ExtUtils
diff options
context:
space:
mode:
authorYves Orton <demerphq@gmail.com>2006-01-31 10:55:25 +0100
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2006-01-31 10:07:00 +0000
commit3b4a80d1d9e181ce3db176cafa62162ddbd00ced (patch)
tree53c04f4d8dbb107159c81aed4e4b7f695aaace1d /lib/ExtUtils
parent682e4b71848152d6896e0c5f2ed3943038c0c77e (diff)
downloadperl-3b4a80d1d9e181ce3db176cafa62162ddbd00ced.tar.gz
Re: [PATCH] Re: replacing "inuse" Win files (was Re: Help with a Cwd.pm build error)
Message-ID: <9b18b3110601310055h7aeb9aa1gdc2d63cc56d97768@mail.gmail.com> p4raw-id: //depot/perl@27016
Diffstat (limited to 'lib/ExtUtils')
-rw-r--r--lib/ExtUtils/Install.pm29
1 files changed, 26 insertions, 3 deletions
diff --git a/lib/ExtUtils/Install.pm b/lib/ExtUtils/Install.pm
index 30740e0731..17cb7f156c 100644
--- a/lib/ExtUtils/Install.pm
+++ b/lib/ExtUtils/Install.pm
@@ -2,7 +2,7 @@ package ExtUtils::Install;
use 5.00503;
use vars qw(@ISA @EXPORT $VERSION);
-$VERSION = '1.33';
+$VERSION = '1.33_01';
use Exporter;
use Carp ();
@@ -91,6 +91,9 @@ sub install {
use File::Path qw(mkpath);
use File::Compare qw(compare);
+ my $win32_special=!$nonono &&
+ $^O eq 'MSWin32' &&
+ eval { require Win32API::File; 1 };
my(%from_to) = %$from_to;
my(%pack, $dir, $warn_permissions);
my($packlist) = ExtUtils::Packlist->new();
@@ -169,8 +172,28 @@ sub install {
$diff++;
}
- if ($diff){
- if (-f $targetfile){
+ if ($diff) {
+ if ($win32_special && -f $targetfile && !unlink $targetfile) {
+ print "Can't remove existing '$targetfile': $!\n";
+ my $tmp = "AAA";
+ ++$tmp while -e "$targetfile.$tmp";
+ $tmp= "$targetfile.$tmp";
+ if ( rename $targetfile, $tmp ) {
+ print "However it has been renamed as '$tmp' which ".
+ "will be removed at next reboot.\n";
+ Win32API::File::MoveFileEx( $tmp, [],
+ Win32API::File::MOVEFILE_DELAY_UNTIL_REBOOT() )
+ or die "MoveFileEx/Delete '$tmp' failed: $^E\n";
+ } else {
+ print "Installation cannot be completed until you reboot.\n",
+ "Until then using '$tmp' as the install filename.\n";
+ Win32API::File::MoveFileEx( $tmp, $targetfile,
+ Win32API::File::MOVEFILE_REPLACE_EXISTING() |
+ Win32API::File::MOVEFILE_DELAY_UNTIL_REBOOT() )
+ or die "MoveFileEx/Replace '$tmp' failed: $^E\n";
+ $targetfile = $tmp;
+ }
+ } elsif (-f $targetfile) {
forceunlink($targetfile) unless $nonono;
} else {
mkpath($targetdir,0,0755) unless $nonono;