summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2008-05-08 16:56:05 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2008-05-08 16:56:05 +0000
commit91ca337ee7134fa4c9667df8b8a7c5bd46526bf7 (patch)
treeaa2358d450bfb176e095d8cc5a56f432404cf963 /lib
parent9c76cba290de0f80b575f0b17c7ddd148628709d (diff)
downloadperl-91ca337ee7134fa4c9667df8b8a7c5bd46526bf7.tar.gz
The last change to File::Copy broke the perl build.
p4raw-id: //depot/perl@33796
Diffstat (limited to 'lib')
-rw-r--r--lib/File/Copy.pm17
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/File/Copy.pm b/lib/File/Copy.pm
index 01daad55fe..b6a05bae0e 100644
--- a/lib/File/Copy.pm
+++ b/lib/File/Copy.pm
@@ -12,7 +12,8 @@ use strict;
use warnings;
use File::Spec;
use Config;
-use Fcntl qw [O_CREAT O_WRONLY O_TRUNC];
+# During perl build, we need File::Copy but Fcntl might not be built yet
+my $Fcntl_loaded = eval q{ use Fcntl qw [O_CREAT O_WRONLY O_TRUNC]; 1 };
our(@ISA, @EXPORT, @EXPORT_OK, $VERSION, $Too_Big, $Syscopy_is_copy);
sub copy;
sub syscopy;
@@ -175,10 +176,16 @@ sub copy {
$to_h = $to;
} else {
$to = _protect($to) if $to =~ /^\s/s;
- my $perm = (stat $from_h) [2] & 0xFFF;
- sysopen $to_h, $to, O_CREAT | O_TRUNC | O_WRONLY, $perm
- or goto fail_open2;
- binmode $to_h or die "($!,$^E)";
+ if ($Fcntl_loaded) {
+ my $perm = (stat $from_h) [2] & 0xFFF;
+ sysopen $to_h, $to, O_CREAT() | O_TRUNC() | O_WRONLY(), $perm
+ or goto fail_open2;
+ }
+ else {
+ $to_h = \do { local *FH };
+ open $to_h, ">", $to or goto fail_open2;
+ }
+ binmode $to_h or die "($!,$^E)";
$closeto = 1;
}