lib/Win32/Exe/Resource/Version.pm

filter: Statementstmt 68.2% 155 / 227 Branchbran 32.5% 39 / 120 Conditioncond 30.9% 13 / 42 MC/DCmcdc 7.6% 2 / 26 Subroutinesub 91.3% 21 / 23 Podpod 0.0% 0 / 16 totaltotal 50.6% 230 / 454 CC 80 SCAR 44.7
CC
80
Cov
53%
set
226.2
find_info
132.0
get
119.4
CRAP 87.0
« lib/Win32/Exe/Manifest.pm ↑ Summary lib/Win32/Exe.pm »
1 # Copyright 2004 by Audrey Tang <cpan@audreyt.org>
2  
3 package Win32::Exe::Resource::Version;
4  
5 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use base 'Win32::Exe::Resource';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use constant FORMAT => (
Subroutine BEGIN: called CC=1 SCAR=0.0
8 Data => 'a*',
9 5 );
10 5 ▶use constant FIXED_INFO => [qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
11 Signature StrucVersion FileVersionMS FileVersionLS
12 ProductVersionMS ProductVersionLS FileFlagsMask FileFlags
13 FileOS FileType FileSubtype FileDateMS FileDateLS
14 5 )];
15 5 ▶use constant STRING_INFO => [qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
16 Comments CompanyName FileDescription FileVersion InternalName
17 LegalCopyright LegalTrademarks OriginalFilename PrivateBuild
18 ProductName ProductVersion SpecialBuild FileNumber ProductNumber
19 5 )];
20 5 ▶use constant FI_TO_ID => {
Subroutine BEGIN: called CC=1 SCAR=0.0
21 5 map { (FIXED_INFO->[$_] => $_) } (0 .. $#{+FIXED_INFO})
22 5 };
23 5 ▶use constant LC_TO_SI => {
Subroutine BEGIN: called CC=2 SCAR=6.9
24 135 (map { (lc($_) => $_) } @{+STRING_INFO}, keys %{+FI_TO_ID}),
25 5 ▶ (map { (lc($_) => $_) } map { /^(.+)MS$/ ? $1 : () } keys %{+FI_TO_ID}),
Branch: 1 branch
BranchTrueFalseTotal
/^(.+)MS$/ ? : 15 50 65
26 5 };
27  
28 24 ▶sub fi_to_id {
Subroutine fi_to_id: called CC=1 SCAR=0.0
Pod undocumented
29 24 my ($self, $name) = @_;
30 24 return(+FI_TO_ID->{$name});
31 }
32  
33 8 ▶sub lc_to_si {
Subroutine lc_to_si: called CC=2 SCAR=8.1
Pod undocumented
34 8 my ($self, $name) = @_;
35 8 ▶ return(+LC_TO_SI->{lc($name)} || $name);
Condition33%1/3
{comments => 'Comments', companyname => 'CompanyName', filedate => 'FileDate', filedatels => 'FileDateLS', filedatems => 'FileDateMS', filedescription => 'FileDescription', fileflags => 'FileFlags', fileflagsmask => 'FileFlagsMask', filenumber => 'FileNumber', fileos => 'FileOS', filesubtype => 'FileSubtype', filetype => 'FileType', fileversion => 'FileVersion', fileversionls => 'FileVersionLS', fileversionms => 'FileVersionMS', internalname => 'InternalName', legalcopyright => 'LegalCopyright', legaltrademarks => 'LegalTrademarks', originalfilename => 'OriginalFilename', privatebuild => 'PrivateBuild', productname => 'ProductName', productnumber => 'ProductNumber', productversion => 'ProductVersion', productversionls => 'ProductVersionLS', productversionms => 'ProductVersionMS', signature => 'Signature', specialbuild => 'SpecialBuild', strucversion => 'StrucVersion'}->{lc $name} || $name
l!l&&r!l&&!r
800
MC/DC0%0/2
{comments => 'Comments', companyname => 'CompanyName', filedate => 'FileDate', filedatels => 'FileDateLS', filedatems => 'FileDateMS', filedescription => 'FileDescription', fileflags => 'FileFlags', fileflagsmask => 'FileFlagsMask', filenumber => 'FileNumber', fileos => 'FileOS', filesubtype => 'FileSubtype', filetype => 'FileType', fileversion => 'FileVersion', fileversionls => 'FileVersionLS', fileversionms => 'FileVersionMS', internalname => 'InternalName', legalcopyright => 'LegalCopyright', legaltrademarks => 'LegalTrademarks', originalfilename => 'OriginalFilename', privatebuild => 'PrivateBuild', productname => 'ProductName', productnumber => 'ProductNumber', productversion => 'ProductVersion', productversionls => 'ProductVersionLS', productversionms => 'ProductVersionMS', signature => 'Signature', specialbuild => 'SpecialBuild', strucversion => 'StrucVersion'}->{lc $name} || $name
{comments => 'Comments', companyname => 'CompanyName', filedate => 'FileDate', filedatels => 'FileDateLS', filedatems => 'FileDateMS', filedescription => 'FileDescription', fileflags => 'FileFlags', fileflagsmask => 'FileFlagsMask', filenumber => 'FileNumber', fileos => 'FileOS', filesubtype => 'FileSubtype', filetype => 'FileType', fileversion => 'FileVersion', fileversionls => 'FileVersionLS', fileversionms => 'FileVersionMS', internalname => 'InternalName', legalcopyright => 'LegalCopyright', legaltrademarks => 'LegalTrademarks', originalfilename => 'OriginalFilename', privatebuild => 'PrivateBuild', productname => 'ProductName', productnumber => 'ProductNumber', productversion => 'ProductVersion', productversionls => 'ProductVersionLS', productversionms => 'ProductVersionMS', signature => 'Signature', specialbuild => 'SpecialBuild', strucversion => 'StrucVersion'}->{lc $name} $name
Truth table33%1/3
A || B
A= {comments => 'Comments', companyname => 'CompanyName', filedate => 'FileDate', filedatels => 'FileDateLS', filedatems => 'FileDateMS', filedescription => 'FileDescription', fileflags => 'FileFlags', fileflagsmask => 'FileFlagsMask', filenumber => 'FileNumber', fileos => 'FileOS', filesubtype => 'FileSubtype', filetype => 'FileType', fileversion => 'FileVersion', fileversionls => 'FileVersionLS', fileversionms => 'FileVersionMS', internalname => 'InternalName', legalcopyright => 'LegalCopyright', legaltrademarks => 'LegalTrademarks', originalfilename => 'OriginalFilename', privatebuild => 'PrivateBuild', productname => 'ProductName', productnumber => 'ProductNumber', productversion => 'ProductVersion', productversionls => 'ProductVersionLS', productversionms => 'ProductVersionMS', signature => 'Signature', specialbuild => 'SpecialBuild', strucversion => 'StrucVersion'}->{lc $name}B= $name
ABresult
1X1
011
000
36 }
37  
38 22 ▶sub info {
Subroutine info: called CC=1 SCAR=0.0
Pod undocumented
39 22 my ($self) = @_;
40 22 return $self->{info};
41 }
42  
43 10 ▶sub set_info {
Subroutine set_info: called CC=1 SCAR=0.0
Pod undocumented
44 10 my ($self, $info) = @_;
45 10 $self->{info} = $info;
46 }
47  
48 10 ▶sub initialize {
Subroutine initialize: called CC=2 SCAR=7.1
Pod undocumented
49 10 my ($self) = @_;
50 10 $self->set_info($self->decode_info($self->Data));
51 10 ▶ die 'Invalid structure' unless $self->check;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->check 0 10 10
52 }
53  
54 2 ▶sub refresh {
Subroutine refresh: called CC=1 SCAR=0.0
Pod undocumented
55 2 my ($self) = @_;
56 2 $self->SetData($self->encode_info($self->info));
57 2 my $rsrc = $self->first_parent('Resources');
58 2 $rsrc->remove("/#RT_VERSION");
59 2 $rsrc->insert("/#RT_VERSION/#1/#0" => $self);
60 2 $rsrc->refresh;
61 2 $self->initialize;
62 }
63  
64 28 ▶sub encode_info {
Subroutine encode_info: called CC=5 SCAR=16.1
Pod undocumented
65 28 my ($self, $info) = @_;
66  
67 28 my $key = shift(@$info);
68 28 $key = $self->encode_ucs2("$key\0");
69  
70 28 my $val = shift(@$info);
71 28 my ($type, $vallen);
72  
73 28 ▶ if (ref $val) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $val) { } 4 24 28
elsif (length $val) { } 18 6 24
74 4 $type = 0; # binary
75 4 $val = pack('V*', @$val);
76 4 $vallen = length($val);
77 }
78 elsif (length $val) {
79 18 $type = 1; # text;
80 18 $val = $self->encode_ucs2("$val\0");
81 18 $vallen = length($val) / 2;
82 }
83 else {
84 6 $type = 1;
85 6 $vallen = 0;
86 }
87  
88 28 my @sub_objects;
89 28 foreach my $sub_info (@$info) {
90 26 my $obj = $self->encode_info($sub_info);
91 26 push(@sub_objects, $obj);
92 }
93  
94 28 my $buf = pack('v3', 0, $vallen, $type) . $key;
95 28 $buf .= $self->pad($buf, 4);
96 28 $buf .= $val;
97  
98 28 foreach my $sub_object (@sub_objects) {
99 26 $buf .= $self->pad($buf, 4);
100 26 $buf .= $sub_object;
101 }
102  
103 28 substr($buf, 0, 2, pack('v', length($buf)));
104 28 return $buf;
105 }
106  
107 140 ▶sub decode_info {
Subroutine decode_info: called CC=12 SCAR=25.0
Pod undocumented
108 140 my $self = shift;
109 140 ▶ my $level = $_[1] || 1;
Condition100%2/2
$_[1] || 1
l!l
13010
MC/DC100%1/1
$_[1] || 1
$_[1]
Truth table100%2/2
A
A= $_[1]
Aresult
11
00
110  
111 140 my ($len, $vallen, $type) = unpack('v3', $_[0]);
112 140 ▶ die 'No record length' unless $len;
Branch: 1 branch
BranchTrueFalseTotal
unless $len 0 140 140
113 140 ▶ die 'Long length' if $len > length($_[0]);
Branch: 1 branch
BranchTrueFalseTotal
if $len > length $_[0] 0 140 140
114  
115 140 my $buf = substr($_[0], 0, $len);
116 140 substr($_[0], 0, $self->align($len, 4)) = '';
117  
118 140 my $endkey = index($buf, "\0\0", 6);
119 140 ▶ while ($endkey > 0 and ($endkey % 2)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($endkey > 0 and $endkey % 2) 140 140 280
Condition66%2/3
$endkey > 0 and $endkey % 2
!ll&&!rl&&r
0140140
MC/DC50%1/2
$endkey > 0 and $endkey % 2
$endkey > 0 $endkey % 2
Truth table66%2/3
A and B
A= $endkey > 0B= $endkey % 2
ABresult
0X0
100
111
120 140 $endkey = index($buf, "\0\0", $endkey + 1);
121 }
122  
123 140 ▶ die 'Invalid endkey' if $endkey < 6 or $endkey > $len - $vallen;;
Branch: 1 branch
BranchTrueFalseTotal
if $endkey < 6 or $endkey > $len - $vallen 0 140 140
Condition33%1/3
$endkey < 6 or $endkey > $len - $vallen
l!l&&r!l&&!r
00140
MC/DC0%0/2
$endkey < 6 or $endkey > $len - $vallen
$endkey < 6 $endkey > $len - $vallen
Truth table33%1/3
A or B
A= $endkey < 6B= $endkey > $len - $vallen
ABresult
1X1
011
000
124  
125 140 my $key = substr($buf, 6, $endkey - 6);
126 140 my $u8_key = $self->decode_ucs2($key);
127  
128 140 my @res = ($u8_key);
129 140 $endkey = $self->align($endkey + 2, 4);
130 140 substr($buf, 0, $endkey, '');
131  
132 140 ▶ if ($vallen) {
Branch: 1 branch
BranchTrueFalseTotal
if ($vallen) { } 110 30 140
133 110 ▶ $vallen *= 2 if $level == 4; # only for strings
Branch: 1 branch
BranchTrueFalseTotal
if $level == 4 90 20 110
134 110 my $val = substr($buf, 0, $vallen);
135 110 ▶ if ($type) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type) { } 90 20 110
136 90 $val = $self->decode_ucs2($val);
137 90 $val =~ s/\0\z//;
138 }
139 else {
140 20 $val = [ unpack('V*', $val) ];
141 }
142 110 push(@res, $val);
143 110 $vallen = $self->align($vallen, 4);
144  
145 110 substr($buf, 0, $vallen) = '';
146 }
147 else {
148 30 push(@res, '');
149 }
150  
151 140 ▶ while (length $buf) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $buf) 130 140 270
152 130 push(@res, $self->decode_info($buf, $level + 1));
153 }
154  
155 140 return \@res;
156 }
157  
158 0 ▶sub empty_info {
Subroutine empty_info: not called CC=1 SCAR=6.9
Pod undocumented
159 0 [ 'VS_VERSION_INFO', [ 0xFEEF04BD, 1 << 16, (0) x 11 ] ];
160 }
161  
162 10 ▶sub check_info {
Subroutine check_info: called CC=5 SCAR=17.2
Pod undocumented
163 10 my ($self, $info) = @_;
164 10 ▶ return 0 unless $info->[0] eq 'VS_VERSION_INFO';
Branch: 1 branch
BranchTrueFalseTotal
unless $info->[0] eq "VS_VERSION_INFO" 0 10 10
165 10 ▶ return 0 unless ref($info->[1]);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $info->[1] 0 10 10
166 10 ▶ return 0 unless $info->[1][0] == 0xFEEF04BD;
Branch: 1 branch
BranchTrueFalseTotal
unless $info->[1][0] == 4277077181 0 10 10
167 10 ▶ return 0 unless $self->check_sub_info($info);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->check_sub_info($info) 0 10 10
168 10 return 1;
169 }
170  
171 140 ▶sub check_sub_info {
Subroutine check_sub_info: called CC=11 SCAR=28.3
Pod undocumented
172 140 my ($self, $info) = @_;
173 140 ▶ return unless UNIVERSAL::isa($info, 'ARRAY');
Branch: 1 branch
BranchTrueFalseTotal
unless UNIVERSAL::isa($info, "ARRAY") 0 140 140
174 140 ▶ return if @$info < 2;
Branch: 1 branch
BranchTrueFalseTotal
if @$info < 2 0 140 140
175 140 ▶ return unless defined($info->[0]) and defined($info->[1]);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $info->[0] and defined $info->[1] 0 140 140
Condition33%1/3
defined $info->[0] and defined $info->[1]
!ll&&!rl&&r
00140
MC/DC0%0/2
defined $info->[0] and defined $info->[1]
defined $info->[0] defined $info->[1]
Truth table33%1/3
A and B
A= defined $info->[0]B= defined $info->[1]
ABresult
0X0
100
111
176 140 ▶ return unless !ref($info->[0]) and length($info->[0]);
Branch: 1 branch
BranchTrueFalseTotal
unless not ref $info->[0] and length $info->[0] 0 140 140
Condition33%1/3
not ref $info->[0] and length $info->[0]
!ll&&!rl&&r
00140
MC/DC0%0/2
not ref $info->[0] and length $info->[0]
not ref $info->[0] length $info->[0]
Truth table33%1/3
not(A) and B
A= not ref $info->[0]B= length $info->[0]
ABresult
0X0
100
111
177 140 ▶ return unless !ref($info->[1]) or UNIVERSAL::isa($info->[1], 'ARRAY');
Branch: 1 branch
BranchTrueFalseTotal
unless not ref $info->[1] or UNIVERSAL::isa($info->[1], "ARRAY") 0 140 140
Condition66%2/3
not ref $info->[1] or UNIVERSAL::isa($info->[1], "ARRAY")
l!l&&r!l&&!r
120200
MC/DC0%0/2
not ref $info->[1] or UNIVERSAL::isa($info->[1], "ARRAY")
not ref $info->[1] UNIVERSAL::isa($info->[1], "ARRAY")
Truth table66%2/3
not(A) or B
A= not ref $info->[1]B= UNIVERSAL::isa($info->[1], "ARRAY")
ABresult
1X1
011
000
178 140 foreach my $idx (2 .. @$info - 1) {
179 130 ▶ return 0 unless $self->check_sub_info($info->[$idx]);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->check_sub_info($info->[$idx]) 0 130 130
180 }
181 140 return 1;
182 }
183  
184 6 ▶sub get {
Subroutine get: called CC=17 SCAR=47.8
Pod undocumented
185 6 my ($self, $name) = @_;
186 6 $name =~ s!\\!/!g;
187 6 $name = $self->lc_to_si($name);
188 6 my $info = $self->info;
189  
190 6 ▶ if ($name eq '/') {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "/") 0 6 6
191 0 ▶ return undef unless ref $info->[1];
Branch: 1 branch
BranchTrueFalseTotal
unless ref $info->[1] 0 0 0
192 0 return $info->[1];
193 }
194  
195 6 my $fixed = $self->fi_to_id($name);
196 6 ▶ if (defined $fixed) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fixed) 0 6 6
197 0 my $struct = $info->[1];
198 0 ▶ return undef unless $struct && ref($struct);
Branch: 1 branch
BranchTrueFalseTotal
unless $struct and ref $struct 0 0 0
Condition0%0/3
$struct and ref $struct
!ll&&!rl&&r
000
MC/DC0%0/2
$struct and ref $struct
$struct ref $struct
Truth table0%0/3
A and B
A= $structB= ref $struct
ABresult
0X0
100
111
199 0 return $struct->[$fixed];
200 }
201  
202 6 $fixed = $self->fi_to_id($name.'MS');
203 6 ▶ if (defined $fixed) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fixed) 6 0 6
204 6 my $struct = $info->[1];
205 6 ▶ return undef unless $struct && ref($struct);
Branch: 1 branch
BranchTrueFalseTotal
unless $struct and ref $struct 0 6 6
Condition33%1/3
$struct and ref $struct
!ll&&!rl&&r
006
MC/DC0%0/2
$struct and ref $struct
$struct ref $struct
Truth table33%1/3
A and B
A= $structB= ref $struct
ABresult
0X0
100
111
206 6 my $ms = $struct->[$fixed];
207 6 my $ls = $struct->[ $self->fi_to_id($name.'LS') ];
208 6 return join(',', $self->split_dword($ms), $self->split_dword($ls));
209 }
210  
211 0 my $s;
212 0 ▶ if ($name =~ s!^/!!) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ s[^/][]) { } 0 0 0
213 0 $s = $info;
214 0 ▶ while ($name =~ s!^([^/]+)/!!) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ s[^([^/]+)/][]) 0 0 0
215 0 ▶ $s = $self->find_info($s, $1) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
$s = $self->find_info($s, $1) or return undef 0 0 0
216 }
217 }
218 else {
219 0 ▶ $s = $self->find_info($info, 'StringFileInfo') or return undef;
Branch: 1 branch
BranchTrueFalseTotal
$s = $self->find_info($info, "StringFileInfo") or return undef 0 0 0
220 0 ▶ if (my $cur_trans = $self->{cur_trans}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $cur_trans = $self->{'cur_trans'}) { } 0 0 0
221 0 ▶ $s = $self->find_info($s, $cur_trans, 1) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
$s = $self->find_info($s, $cur_trans, 1) or return undef 0 0 0
222 }
223 else {
224 0 ▶ $s = $s->[2] or return undef;
Branch: 1 branch
BranchTrueFalseTotal
$s = $s->[2] or return undef 0 0 0
225 0 $self->{cur_trans} = $s->[0];
226 }
227 }
228  
229 0 ▶ $s = $self->find_info($s, $name) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
$s = $self->find_info($s, $name) or return undef 0 0 0
230 0 return $s->[1];
231 }
232  
233 2 ▶sub set {
Subroutine set: called CC=22 SCAR=54.2
Pod undocumented
234 2 my ($self, $name, $value) = @_;
235 2 $name =~ s!\\!/!g;
236 2 $name = $self->lc_to_si($name);
237 2 my $info = $self->info;
238  
239 2 ▶ if ($name eq '/') {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "/") 0 2 2
240 0 ▶ if (!defined $value) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $value) { } 0 0 0
elsif (UNIVERSAL::isa($value, 'ARRAY') and @$value == 13) { } 0 0 0
241 0 $info->[1] = '';
242 }
243 ▶ elsif (UNIVERSAL::isa($value, 'ARRAY') and @$value == 13) {
Condition0%0/3
UNIVERSAL::isa($value, "ARRAY") and @$value == 13
!ll&&!rl&&r
000
MC/DC0%0/2
UNIVERSAL::isa($value, "ARRAY") and @$value == 13
UNIVERSAL::isa($value, "ARRAY") @$value == 13
Truth table0%0/3
A and B
A= UNIVERSAL::isa($value, "ARRAY")B= @$value == 13
ABresult
0X0
100
111
244 0 $info->[1] = $value;
245 }
246 else {
247 0 die 'Invalid array assigned';
248 }
249 }
250  
251 2 my $fixed = $self->fi_to_id($name);
252 2 ▶ if (defined $fixed) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fixed) 0 2 2
253 0 ▶ $value = oct($value) if $value =~ /^0/;
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /^0/ 0 0 0
254 0 $info->[1][$fixed] = $value;
255 0 return;
256 }
257  
258 2 $fixed = $self->fi_to_id($name.'MS');
259 2 ▶ if (defined $fixed) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fixed) 2 0 2
260 2 my @value = split(/[,.]/, $value, -1);
261 2 ▶ if (@value == 4) {
Branch: 1 branch
BranchTrueFalseTotal
if (@value == 4) 2 0 2
262 2 $value[0] = ($value[0] << 16) | $value[1];
263 2 $value[1] = ($value[2] << 16) | $value[3];
264 2 splice(@value, 2);
265 }
266  
267 2 ▶ die 'Invalid MS/LS value' if @value != 2;
Branch: 1 branch
BranchTrueFalseTotal
if @value != 2 0 2 2
268 2 ▶ $info->[1][$fixed] = $value[0] || 0;
Condition50%1/2
$value[0] || 0
l!l
20
MC/DC0%0/1
$value[0] || 0
$value[0]
Truth table50%1/2
A
A= $value[0]
Aresult
11
00
269 2 ▶ $info->[1][$self->fi_to_id($name.'LS')] = $value[1] || 0;
Condition50%1/2
$value[1] || 0
l!l
02
MC/DC0%0/1
$value[1] || 0
$value[1]
Truth table50%1/2
A
A= $value[1]
Aresult
11
00
270 2 return;
271 }
272  
273 0 my $container = $info;
274  
275 0 ▶ if ($name =~ s!^/!!) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ s[^/][]) { } 0 0 0
276 0 ▶ while ($name =~ s!^([^/]+)/!!) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ s[^([^/]+)/][]) 0 0 0
277 0 my $n = $1;
278 0 my $s = $self->find_info($container, $n);
279 0 ▶ unless ($s) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($s) 0 0 0
280 0 $s = [ $n => '' ];
281 0 push(@$container, $s);
282 }
283 0 $container = $s;
284 }
285 }
286 else {
287 0 my $s = $self->find_info($container, 'StringFileInfo');
288 0 ▶ unless ($s) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($s) 0 0 0
289 0 $s = [ StringFileInfo => '' ];
290 0 push(@$container, $s);
291 }
292 0 $container = $s;
293  
294 0 my $cur_trans = $self->{cur_trans};
295 0 ▶ unless ($cur_trans) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($cur_trans) 0 0 0
296 0 ▶ if (@$container > 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$container > 2) { } 0 0 0
297 0 $cur_trans = $container->[2][0];
298 }
299 else {
300 0 $cur_trans = '000004B0'; # Language Neutral && CP 1200 = Unicode
301 }
302 0 $self->{cur_trans} = $cur_trans;
303 }
304  
305 0 $s = $self->find_info($container, $cur_trans, 1);
306 0 ▶ unless ($s) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($s) 0 0 0
307 0 $s = [ $cur_trans => '' ];
308 0 push(@$container, $s);
309 }
310 0 $container = $s;
311 }
312  
313 0 my ($kv, $kv_index) = $self->find_info($container, $name);
314 0 ▶ unless ($kv) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($kv) 0 0 0
315 0 ▶ push(@$container, [ $name => $value ]) if defined $value;
Branch: 1 branch
BranchTrueFalseTotal
if defined $value 0 0 0
316 0 return;
317 }
318  
319 0 ▶ if (defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) { } 0 0 0
320 0 $kv->[1] = $value;
321 }
322 else {
323 0 splice(@$container, $kv_index, 1);
324 }
325 }
326  
327 10 ▶sub check {
Subroutine check: called CC=1 SCAR=0.0
Pod undocumented
328 10 my $self = shift;
329 10 return $self->check_info($self->info);
330 }
331  
332 0 ▶sub find_info {
Subroutine find_info: not called CC=11 SCAR=48.8
Pod undocumented
333 0 my ($self, $info, $name, $ignore) = @_;
334 0 my $index;
335  
336 0 ▶ if ($name =~ /^#(\d+)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ /^#(\d+)$/) { } 0 0 0
337 0 $index = $1 - 1 + 2;
338 0 ▶ $index = undef if $index < 2 || $index >= @$info;
Branch: 1 branch
BranchTrueFalseTotal
if $index < 2 or $index >= @$info 0 0 0
Condition0%0/3
$index < 2 or $index >= @$info
l!l&&r!l&&!r
000
MC/DC0%0/2
$index < 2 or $index >= @$info
$index < 2 $index >= @$info
Truth table0%0/3
A or B
A= $index < 2B= $index >= @$info
ABresult
1X1
011
000
339 }
340 else {
341 0 for (2 .. @$info - 1) {
342 0 my $e = $info->[$_];
343 0 ▶ if ($e->[0] eq $name or $ignore && lc($e->[0]) eq lc($name)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($e->[0] eq $name or $ignore and lc $e->[0] eq lc $name) 0 0 0
Condition0%0/6
$e->[0] eq $name or $ignore and lc $e->[0] eq lc $name
l!l&&r!l&&!r
000
$ignore and lc $e->[0] eq lc $name
!ll&&!rl&&r
000
MC/DC0%0/3
$e->[0] eq $name or $ignore and lc $e->[0] eq lc $name
$e->[0] eq $name $ignore lc $e->[0] eq lc $name
Truth table0%0/4
A or B and C
A= $e->[0] eq $nameB= $ignoreC= lc $e->[0] eq lc $name
ABCresult
1XX1
0111
00X0
0100
344 0 $index = $_;
345 0 last;
346 }
347 }
348 }
349 0 ▶ if ($index) {
Branch: 1 branch
BranchTrueFalseTotal
if ($index) 0 0 0
350 0 ▶ return $info->[$index] unless wantarray;
Branch: 1 branch
BranchTrueFalseTotal
unless wantarray 0 0 0
351 0 return ($info->[$index], $index);
352 }
353  
354 0 ▶ return undef unless wantarray;
Branch: 1 branch
BranchTrueFalseTotal
unless wantarray 0 0 0
355 0 return (undef, undef);
356 }
357  
358 12 ▶sub split_dword {
Subroutine split_dword: called CC=1 SCAR=0.0
Pod undocumented
359 12 my ($self, $dword) = @_;
360 12 return ($dword >> 16), ($dword & 0xFFFF);
361 }
362  
363 5 1;
« lib/Win32/Exe/Manifest.pm ↑ Summary lib/Win32/Exe.pm »