develooper Front page | perl.perl5.porters | Postings from May 2008

Re: [PATCH] File::Copy & permission bits.

Thread Previous
From:
Rafael Garcia-Suarez
Date:
May 8, 2008 09:57
Subject:
Re: [PATCH] File::Copy & permission bits.
Message ID:
b77c1dce0805080957i54aa2241uea0a32ed598ff40d@mail.gmail.com
2008/5/8 Rafael Garcia-Suarez <rgarciasuarez@gmail.com>:
> 2008/5/7 Abigail <abigail@abigail.be>:
>>
>> The following patch to File::Copy makes if one copies a file, permission
>> bits are handled as POSIX 1003.1 describes the shell utility 'cp' ought
>> to behave.
>
> Thanks, applied.
>
> I also added the following :

And then this, because perl wasn't buildable anymore, sigh :

Change 33796 by rgs@stcosmo on 2008/05/08 16:56:05

        The last change to File::Copy broke the perl build.

Affected files ...

... //depot/perl/lib/File/Copy.pm#54 edit

Differences ...

==== //depot/perl/lib/File/Copy.pm#54 (text) ====

@@ -12,7 +12,8 @@
 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 @@
        $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;
     }

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About