diff options
author | Nicholas Clark <nick@ccl4.org> | 2002-10-29 23:00:05 +0000 |
---|---|---|
committer | hv <hv@crypt.org> | 2002-11-19 12:07:25 +0000 |
commit | 36bb303b6ac55df9c2780b48d374c505374dc378 (patch) | |
tree | 6aa3bf528c2bb5e5d77e72a8f5137a045663734e /regen.pl | |
parent | 0dae17bd7971d11b90a07b6fc03ec78ab38e4db4 (diff) | |
download | perl-36bb303b6ac55df9c2780b48d374c505374dc378.tar.gz |
regen_headers outside Makefile (was Re: [PATCH] embed.pl doc)
Message-ID: <20021029230003.GF287@Bagpuss.unfortu.net>
p4raw-id: //depot/perl@18160
Diffstat (limited to 'regen.pl')
-rw-r--r-- | regen.pl | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/regen.pl b/regen.pl new file mode 100644 index 0000000000..1c830a2cdc --- /dev/null +++ b/regen.pl @@ -0,0 +1,45 @@ +#!/usr/bin/perl -w +use strict; +use vars qw($Is_W32 $Is_OS2 $Is_Cygwin $Is_NetWare $Needs_Write); +use Config; # Remember, this is running using an existing perl + +# Common functions needed by the regen scripts + +$Is_W32 = $^O eq 'MSWin32'; +$Is_OS2 = $^O eq 'os2'; +$Is_Cygwin = $^O eq 'cygwin'; +$Is_NetWare = $Config{osname} eq 'NetWare'; +if ($Is_NetWare) { + $Is_W32 = 0; +} + +$Needs_Write = $Is_OS2 || $Is_W32 || $Is_Cygwin || $Is_NetWare; + +sub safer_unlink { + my @names = @_; + my $cnt = 0; + + my $name; + foreach $name (@names) { + next unless -e $name; + chmod 0777, $name if $Needs_Write; + ( CORE::unlink($name) and ++$cnt + or warn "Couldn't unlink $name: $!\n" ); + } + return $cnt; +} + +sub safer_rename_silent { + my ($from, $to) = @_; + + # Some dosish systems can't rename over an existing file: + safer_unlink $to; + chmod 0600, $from if $Needs_Write; + rename $from, $to; +} + +sub safer_rename { + my ($from, $to) = @_; + safer_rename_silent($from, $to) or die "renaming $from to $to: $!"; +} +1; |