| 1 | package PAR::Heavy; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | $PAR::Heavy::VERSION = '0.12'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | PAR::Heavy - PAR guts | ||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | (internal use only) | ||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | No user-serviceable parts inside. | ||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # Dynamic inclusion of XS modules | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # NOTE: Don't "use" any module here, esp. one that is an XS module or | ||||||||||||||||||||||||||||||||||||||||||||||
| 25 | # whose "use" could cause the loading of an XS module thru its dependencies. | ||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # enable debug/trace messages from DynaLoader perl code | ||||||||||||||||||||||||||||||||||||||||||||||
| 28 | ▶ | my $dl_debug = $ENV{PERL_DL_DEBUG} || 0; | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$ENV{'PERL_DL_DEBUG'} || 0
MC/DC0%0/1
$ENV{'PERL_DL_DEBUG'} || 0
$ENV{'PERL_DL_DEBUG'}
Truth table0%0/2
A
A= $ENV{'PERL_DL_DEBUG'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||
| 30 | our %FullCache; | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | my ($bootstrap, $dl_findfile); # Caches for code references | ||||||||||||||||||||||||||||||||||||||||||||||
| 33 | my ($cache_key); # The current file to find | ||||||||||||||||||||||||||||||||||||||||||||||
| 34 | my $is_insensitive_fs = ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 35 | -s $0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 36 | and (-s lc($0) || -1) == (-s uc($0) || -1) | ||||||||||||||||||||||||||||||||||||||||||||||
| 37 | and (-s lc($0) || -1) == -s $0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 38 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | # Adds pre-hooks to Dynaloader's key methods | ||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 7 | ▶ | sub _init_dynaloader { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_init_dynaloader: called CC=4 SCAR=17.7
| |||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | return if $bootstrap; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_init_dynaloader: not called CC=4 SCAR=17.7
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | return unless eval { require DynaLoader; DynaLoader::dl_findfile(); 1 }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | print STDERR "PAR::Heavy: pre-hooks to Dynaloader's key methods\n" | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 46 | if $dl_debug; | ||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | $bootstrap = \&DynaLoader::bootstrap; | |||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | $dl_findfile = \&DynaLoader::dl_findfile; | |||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||
| 51 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | local $^W; | |||||||||||||||||||||||||||||||||||||||||||||
| 54 | 4 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | *{'DynaLoader::dl_expandspec'} = sub { return }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | *{'DynaLoader::bootstrap'} = \&_bootstrap; | |||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | *{'DynaLoader::dl_findfile'} = \&_dl_findfile; | |||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||
| 61 | # Return the cached location of .dll inside PAR first, if possible. | ||||||||||||||||||||||||||||||||||||||||||||||
| 62 | sub _dl_findfile { | ||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | print STDERR "PAR::Heavy::_dl_findfile($cache_key)\n" if $dl_debug; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dl_findfile: not called CC=8 SCAR=42.8
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | if (exists $FullCache{$cache_key}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | print STDERR " found in FullCache as $FullCache{$cache_key}\n" | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 67 | if $dl_debug; | ||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | return $FullCache{$cache_key}; | |||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | if ($is_insensitive_fs) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 71 | # We have a case-insensitive filesystem... | ||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | my ($key) = grep { lc($_) eq lc($cache_key) } keys %FullCache; | |||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | if (defined $key) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | print STDERR " found case-insensitively in FullCache as $FullCache{$key}\n" | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 75 | if $dl_debug; | ||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | return $FullCache{$key}; | |||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | print STDERR " fall back to DynaLoader::dl_findfile\n" if $dl_debug; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | return $dl_findfile->(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||
| 83 | # Find and extract .dll from PAR files for a given dynamic module. | ||||||||||||||||||||||||||||||||||||||||||||||
| 84 | sub _bootstrap { | ||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | my (@args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_bootstrap: not called CC=18 SCAR=57.6
| |||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | my ($module) = $args[0] or return; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | my @modparts = split(/::/, $module); | |||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | my $modfname = $modparts[-1]; | |||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | $modfname = &DynaLoader::mod2fname(\@modparts) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 92 | if defined &DynaLoader::mod2fname; | ||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | if (($^O eq 'NetWare') && (length($modfname) > 8)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition16%1/6
$^O eq "NetWare" and length $modfname > 8
$^O eq "NetWare" and length $modfname > 8
MC/DC0%0/2
$^O eq "NetWare" and length $modfname > 8
$^O eq "NetWare"
length $modfname > 8
MC/DC0%0/2
$^O eq "NetWare" and length $modfname > 8
$^O eq "NetWare"
length $modfname > 8
Truth table0%0/3
A and B
A= $^O eq "NetWare"B= length $modfname > 8
Truth table0%0/3
A and B
A= $^O eq "NetWare"B= length $modfname > 8
| |||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | $modfname = substr($modfname, 0, 8); | |||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | my $modpname = join((($^O eq 'MacOS') ? ':' : '/'), @modparts); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | my $file = $cache_key = "auto/$modpname/$modfname.$DynaLoader::dl_dlext"; | |||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | if ($FullCache{$file}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # TODO: understand | ||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | local $DynaLoader::do_expand = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | return $bootstrap->(@args); | |||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | my $member; | |||||||||||||||||||||||||||||||||||||||||||||
| 108 | # First, try to find things in the preferentially loaded PARs: | ||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | $member = PAR::_find_par_internals([@PAR::PAR_INC], undef, $file, 1) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 110 | if defined &PAR::_find_par_internals; | ||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||
| 112 | # If that failed to find the dll, let DynaLoader (try or) throw an error | ||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | unless ($member) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | my $filename = eval { $bootstrap->(@args) }; | |||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | return $filename if not $@ and defined $filename; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition16%1/6
not $@ and defined $filename
not $@ and defined $filename
MC/DC0%0/2
not $@ and defined $filename
not $@
defined $filename
MC/DC0%0/2
not $@ and defined $filename
not $@
defined $filename
Truth table0%0/3
not(A) and B
A= not $@B= defined $filename
Truth table33%1/3
not(A) and B
A= not $@B= defined $filename
| |||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||
| 117 | # Now try the fallback pars | ||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | $member = PAR::_find_par_internals([@PAR::PAR_INC_LAST], undef, $file, 1) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 119 | if defined &PAR::_find_par_internals; | ||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||
| 121 | # If that fails, let dynaloader have another go JUST to throw an error | ||||||||||||||||||||||||||||||||||||||||||||||
| 122 | # While this may seem wasteful, nothing really matters once we fail to | ||||||||||||||||||||||||||||||||||||||||||||||
| 123 | # load shared libraries! | ||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | unless ($member) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | return $bootstrap->(@args); | |||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | $FullCache{$file} = _dl_extract($member); | |||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||
| 131 | # Now extract all associated shared objs in the same auto/ dir | ||||||||||||||||||||||||||||||||||||||||||||||
| 132 | # XXX: shouldn't this also set $FullCache{...} for those files? | ||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my $first = $member->fileName; | |||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | my $path_pattern = $first; | |||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | $path_pattern =~ s{[^/]*$}{}; | |||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | if ($PAR::LastAccessedPAR) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | foreach my $member ( $PAR::LastAccessedPAR->members ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | next if $member->isDirectory; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | my $name = $member->fileName; | |||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | next if $name eq $first; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | next unless $name =~ m{^/?\Q$path_pattern\E\/[^/]*\.\Q$DynaLoader::dl_dlext\E[^/]*$}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | $name =~ s{.*/}{}; | |||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | _dl_extract($member, $name); | |||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | local $DynaLoader::do_expand = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | return $bootstrap->(@args); | |||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||
| 152 | sub _dl_extract { | ||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | my ($member, $name) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dl_extract: not called CC=8 SCAR=40.5
| |||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | $name ||= $member->crc32String . ".$DynaLoader::dl_dlext"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition16%1/6
$name ||= $member->crc32String . ".$DynaLoader::dl_dlext"
$name ||= $member->crc32String . ".$DynaLoader::dl_dlext"
MC/DC0%0/2
$name ||= $member->crc32String . ".$DynaLoader::dl_dlext"
$name
$member->crc32String . ".$DynaLoader::dl_dlext"
MC/DC0%0/2
$name ||= $member->crc32String . ".$DynaLoader::dl_dlext"
$name
$member->crc32String . ".$DynaLoader::dl_dlext"
Truth table0%0/3
A ||= B
A= $nameB= $member->crc32String . ".$DynaLoader::dl_dlext"
Truth table33%1/3
A ||= B
A= $nameB= $member->crc32String . ".$DynaLoader::dl_dlext"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | my $filename = File::Spec->catfile($ENV{PAR_TEMP} || File::Spec->tmpdir, $name); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition16%1/6
$ENV{'PAR_TEMP'} || 'File::Spec'->tmpdir
$ENV{'PAR_TEMP'} || 'File::Spec'->tmpdir
MC/DC0%0/2
$ENV{'PAR_TEMP'} || 'File::Spec'->tmpdir
$ENV{'PAR_TEMP'}
'File::Spec'->tmpdir
MC/DC0%0/2
$ENV{'PAR_TEMP'} || 'File::Spec'->tmpdir
$ENV{'PAR_TEMP'}
'File::Spec'->tmpdir
Truth table0%0/3
A || B
A= $ENV{'PAR_TEMP'}B= 'File::Spec'->tmpdir
Truth table33%1/3
A || B
A= $ENV{'PAR_TEMP'}B= 'File::Spec'->tmpdir
| |||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ($filename) = $filename =~ /^([\x20-\xff]+)$/; | |||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | return $filename if -e $filename && -s _ == $member->uncompressedSize; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition16%1/6
-e $filename and -s _ == $member->uncompressedSize
-e $filename and -s _ == $member->uncompressedSize
MC/DC0%0/2
-e $filename and -s _ == $member->uncompressedSize
-e $filename
-s _ == $member->uncompressedSize
MC/DC0%0/2
-e $filename and -s _ == $member->uncompressedSize
-e $filename
-s _ == $member->uncompressedSize
Truth table0%0/3
A and B
A= -e $filenameB= -s _ == $member->uncompressedSize
Truth table0%0/3
A and B
A= -e $filenameB= -s _ == $member->uncompressedSize
| |||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||
| 161 | # $filename doesn't exist or hasn't been completely extracted: | ||||||||||||||||||||||||||||||||||||||||||||||
| 162 | # extract it under a temporary name that isn't likely to be used | ||||||||||||||||||||||||||||||||||||||||||||||
| 163 | # by concurrent processes doing the same | ||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | my $tempname = "$filename.$$"; | |||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | $member->extractToFileNamed($tempname) == Archive::Zip::AZ_OK() | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 166 | or die "Can't extract archive member ".$member->fileName." to $tempname: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||
| 168 | # now that we have a "good" copy in $tempname, rename it to $filename; | ||||||||||||||||||||||||||||||||||||||||||||||
| 169 | # if this fails (e.g. some OSes won't let you delete DLLs that are | ||||||||||||||||||||||||||||||||||||||||||||||
| 170 | # in use), but $filename exists, we assume that $filename is also | ||||||||||||||||||||||||||||||||||||||||||||||
| 171 | # "good": remove $tempname and return $filename | ||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | unless (rename($tempname, $filename)) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 173 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | -e $filename or die "can't rename $tempname to $filename: $!"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | unlink($tempname); | |||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | return $filename; | |||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 1; | ||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||
| 182 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||
| 184 | L<PAR> | ||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||
| 186 | =head1 AUTHORS | ||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||
| 188 | Audrey Tang E<lt>cpan@audreyt.orgE<gt> | ||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||
| 190 | You can write | ||||||||||||||||||||||||||||||||||||||||||||||
| 191 | to the mailing list at E<lt>par@perl.orgE<gt>, or send an empty mail to | ||||||||||||||||||||||||||||||||||||||||||||||
| 192 | E<lt>par-subscribe@perl.orgE<gt> to participate in the discussion. | ||||||||||||||||||||||||||||||||||||||||||||||
| 193 | Archives of the mailing list are available at | ||||||||||||||||||||||||||||||||||||||||||||||
| 194 | E<lt>https://www.mail-archive.com/par@perl.org/E<gt> or E<lt>https://groups.google.com/g/perl.parE<gt>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||
| 196 | Please submit bug reports to E<lt>https://github.com/rschupp/PAR/issuesE<gt>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||
| 198 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||
| 200 | Copyright 2002-2010 by Audrey Tang | ||||||||||||||||||||||||||||||||||||||||||||||
| 201 | E<lt>cpan@audreyt.orgE<gt>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||
| 203 | Copyright 2006-2010 by Steffen Mueller | ||||||||||||||||||||||||||||||||||||||||||||||
| 204 | E<lt>smueller@cpan.orgE<gt>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||
| 206 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||||||||||||||
| 207 | under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||
| 209 | See F<LICENSE>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||
| 211 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||