| 1 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # File: RSRC.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # Description: Read Mac OS Resource information | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # Revisions: 2010/03/17 - P. Harvey Created | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # References: 1) http://developer.apple.com/legacy/mac/library/documentation/mac/MoreToolbox/MoreToolbox-99.html | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | package Image::ExifTool::RSRC; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use Image::ExifTool qw(:DataAccess :Utils); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | $VERSION = '1.10'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | sub ProcessRSRC($$); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | # Information decoded from Mac OS resources | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | %Image::ExifTool::RSRC::Main = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | GROUPS => { 2 => 'Document' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | PROCESS_PROC => \&ProcessRSRC, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | NOTES => q{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | Tags extracted from Mac OS resource files, DFONT files and "._" sidecar | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | files. These tags may also be extracted from the resource fork of any file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | in OS X, either by adding "/..namedfork/rsrc" to the filename to process the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | resource fork alone, or by using the L<ExtractEmbedded|../ExifTool.html#ExtractEmbedded> (-ee) option to process | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | the resource fork as a sub-document of the main file. When writing, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | ExifTool preserves the Mac OS resource fork by default, but it may deleted | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | with C<-rsrc:all=> on the command line. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | '8BIM' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | Name => 'PhotoshopInfo', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | SubDirectory => { TagTable => 'Image::ExifTool::Photoshop::Main' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 'sfnt' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | Name => 'Font', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | SubDirectory => { TagTable => 'Image::ExifTool::Font::Name' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | # my samples of postscript-type DFONT files have a POST resource | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | # with ID 0x1f5 and the same format as a PostScript file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 'POST_0x01f5' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | Name => 'PostscriptFont', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | SubDirectory => { TagTable => 'Image::ExifTool::PostScript::Main' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 'usro_0x0000' => 'OpenWithApplication', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 'vers_0x0001' => 'ApplicationVersion', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 'STR _0xbff3' => 'ApplicationMissingMsg', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 'STR _0xbff4' => 'CreatorApplication', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | # the following written by Photoshop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | # (ref http://www.adobe.ca/devnet/photoshop/psir/ps_image_resources.pdf) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 'STR#_0x0080' => 'Keywords', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 'TEXT_0x0080' => 'Description', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | # don't extract PICT's because the clip region isn't set properly | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | # in the PICT resource for some reason. Also, a dummy 512-byte | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | # header would have to be added to create a valid PICT file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | # 'PICT' => { Name => 'PreviewPICT', Binary => 1 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | # Read information from a Mac resource file (ref 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | # Inputs: 0) ExifTool ref, 1) dirInfo ref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | # Returns: 1 on success, 0 if this wasn't a valid resource file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | sub ProcessRSRC($$) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ProcessRSRC: called CC=59 SCAR=63.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 2 | my ($et, $dirInfo) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 2 | my $raf = $$dirInfo{RAF}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 2 | my ($hdr, $map, $buff, $i, $j); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | # allow access with data reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 2 | ▶ | $raf or $raf = File::RandomAccess->new($$dirInfo{DataPt}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | # attempt to validate the format as thoroughly as practical | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 2 | ▶ | return 0 unless $raf->Read($hdr, 30) == 30; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 2 | my ($datOff, $mapOff, $datLen, $mapLen) = unpack('N*', $hdr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 2 | ▶ | return 0 unless $raf->Seek(0, 2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 2 | my $fLen = $raf->Tell(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 2 | ▶ | return 0 if $datOff < 0x10 or $datOff + $datLen > $fLen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$datOff < 16 or $datOff + $datLen > $fLen
MC/DC0%0/2
$datOff < 16 or $datOff + $datLen > $fLen
$datOff < 16
$datOff + $datLen > $fLen
Truth table33%1/3
A or B
A= $datOff < 16B= $datOff + $datLen > $fLen
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 2 | ▶ | return 0 if $mapOff < 0x10 or $mapOff + $mapLen > $fLen or $mapLen < 30; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$mapOff < 16 or $mapOff + $mapLen > $fLen or $mapLen < 30
$mapOff < 16 or $mapOff + $mapLen > $fLen
MC/DC0%0/3
$mapOff < 16 or $mapOff + $mapLen > $fLen or $mapLen < 30
$mapOff < 16
$mapOff + $mapLen > $fLen
$mapLen < 30
Truth table25%1/4
A or B or C
A= $mapOff < 16B= $mapOff + $mapLen > $fLenC= $mapLen < 30
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 2 | ▶ | return 0 if $datOff < $mapOff and $datOff + $datLen > $mapOff; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$datOff < $mapOff and $datOff + $datLen > $mapOff
MC/DC0%0/2
$datOff < $mapOff and $datOff + $datLen > $mapOff
$datOff < $mapOff
$datOff + $datLen > $mapOff
Truth table66%2/3
A and B
A= $datOff < $mapOffB= $datOff + $datLen > $mapOff
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 2 | ▶ | return 0 if $mapOff < $datOff and $mapOff + $mapLen > $datOff; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$mapOff < $datOff and $mapOff + $mapLen > $datOff
MC/DC0%0/2
$mapOff < $datOff and $mapOff + $mapLen > $datOff
$mapOff < $datOff
$mapOff + $mapLen > $datOff
Truth table33%1/3
A and B
A= $mapOff < $datOffB= $mapOff + $mapLen > $datOff
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | # read the resource map | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 2 | ▶ | $raf->Seek($mapOff, 0) and $raf->Read($map, $mapLen) == $mapLen or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$raf->Seek($mapOff, 0) and $raf->Read($map, $mapLen) == $mapLen
MC/DC0%0/2
$raf->Seek($mapOff, 0) and $raf->Read($map, $mapLen) == $mapLen
$raf->Seek($mapOff, 0)
$raf->Read($map, $mapLen) == $mapLen
Truth table33%1/3
A and B
A= $raf->Seek($mapOff, 0)B= $raf->Read($map, $mapLen) == $mapLen
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 2 | SetByteOrder('MM'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 2 | my $typeOff = Get16u(\$map, 24); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 2 | my $nameOff = Get16u(\$map, 26); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 2 | my $numTypes = (Get16u(\$map, 28) + 1) & 0xffff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | # validate offsets in the resource map | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 2 | ▶ | return 0 if $typeOff < 28 or $nameOff < 30; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$typeOff < 28 or $nameOff < 30
MC/DC0%0/2
$typeOff < 28 or $nameOff < 30
$typeOff < 28
$nameOff < 30
Truth table33%1/3
A or B
A= $typeOff < 28B= $nameOff < 30
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 2 | ▶ | $et->SetFileType('RSRC') unless $$et{IN_RESOURCE}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 2 | my $verbose = $et->Options('Verbose'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 2 | my $tagTablePtr = GetTagTable('Image::ExifTool::RSRC::Main'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 2 | $et->VerboseDir('RSRC', $numTypes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | # parse resource type list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 2 | ▶ | for ($i=0; $i<$numTypes; ++$i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 2 | my $off = $typeOff + 2 + 8 * $i; # offset of entry in type list | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 2 | ▶ | last if $off + 8 > $mapLen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 2 | my $resType = substr($map,$off,4); # resource type | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 2 | my $resNum = Get16u(\$map,$off+4); # number of resources - 1 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 2 | my $refOff = Get16u(\$map,$off+6) + $typeOff; # offset to first resource reference | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | # loop through all resources | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 2 | ▶ | for ($j=0; $j<=$resNum; ++$j) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 2 | my $roff = $refOff + 12 * $j; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 2 | ▶ | last if $roff + 12 > $mapLen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | # read only the 24-bit resource data offset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 2 | my $id = Get16u(\$map,$roff); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 2 | my $resOff = (Get32u(\$map,$roff+4) & 0x00ffffff) + $datOff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 2 | my $resNameOff = Get16u(\$map,$roff+2) + $nameOff + $mapOff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 2 | my ($tag, $val, $valLen); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 2 | my $tagInfo = $$tagTablePtr{$resType}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 2 | ▶ | if ($tagInfo) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 1 | $tag = $resType; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 1 | $tag = sprintf('%s_0x%.4x', $resType, $id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 1 | $tagInfo = $$tagTablePtr{$tag}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | # read the resource data if necessary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 2 | ▶ | if ($tagInfo or $verbose) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$tagInfo or $verbose
MC/DC0%0/2
$tagInfo or $verbose
$tagInfo
$verbose
Truth table33%1/3
A or B
A= $tagInfoB= $verbose
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 2 | ▶ | unless ($raf->Seek($resOff, 0) and $raf->Read($buff, 4) == 4 and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
$raf->Seek($resOff, 0) and $raf->Read($buff, 4) == 4 and ($valLen = unpack("N", $buff)) < 100000000 and $raf->Read($val, $valLen) == $valLen
$raf->Seek($resOff, 0) and $raf->Read($buff, 4) == 4 and ($valLen = unpack("N", $buff)) < 100000000
$raf->Seek($resOff, 0) and $raf->Read($buff, 4) == 4
MC/DC0%0/4
$raf->Seek($resOff, 0) and $raf->Read($buff, 4) == 4 and ($valLen = unpack("N", $buff)) < 100000000 and $raf->Read($val, $valLen) == $valLen
$raf->Seek($resOff, 0)
$raf->Read($buff, 4) == 4
($valLen = unpack("N", $buff)) < 100000000
$raf->Read($val, $valLen) == $valLen
Truth table20%1/5
A and B and C and D
A= $raf->Seek($resOff, 0)B= $raf->Read($buff, 4) == 4C= ($valLen = unpack("N", $buff)) < 100000000D= $raf->Read($val, $valLen) == $valLen
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | ($valLen = unpack('N', $buff)) < 100000000 and # arbitrary size limit (100MB) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | $raf->Read($val, $valLen) == $valLen) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | $et->Warn("Error reading $resType resource"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 2 | ▶ | if ($verbose) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | my ($resName, $nameLen); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | $resName = '' unless $raf->Seek($resNameOff, 0) and $raf->Read($buff, 1) and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$raf->Seek($resNameOff, 0) and $raf->Read($buff, 1) and ($nameLen = ord $buff) != 0 and $raf->Read($resName, $nameLen) == $nameLen
$raf->Seek($resNameOff, 0) and $raf->Read($buff, 1) and ($nameLen = ord $buff) != 0
$raf->Seek($resNameOff, 0) and $raf->Read($buff, 1)
MC/DC0%0/4
$raf->Seek($resNameOff, 0) and $raf->Read($buff, 1) and ($nameLen = ord $buff) != 0 and $raf->Read($resName, $nameLen) == $nameLen
$raf->Seek($resNameOff, 0)
$raf->Read($buff, 1)
($nameLen = ord $buff) != 0
$raf->Read($resName, $nameLen) == $nameLen
Truth table0%0/5
A and B and C and D
A= $raf->Seek($resNameOff, 0)B= $raf->Read($buff, 1)C= ($nameLen = ord $buff) != 0D= $raf->Read($resName, $nameLen) == $nameLen
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | ($nameLen = ord $buff) != 0 and $raf->Read($resName, $nameLen) == $nameLen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | $et->VPrint(0,sprintf("%s resource ID 0x%.4x (offset 0x%.4x, $valLen bytes, name='%s'):\n", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | $resType, $id, $resOff, $resName)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | $et->VerboseDump(\$val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 2 | ▶ | next unless $tagInfo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 2 | ▶ | if ($resType eq 'vers') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 8 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | # parse the 'vers' resource to get the long version string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 1 | ▶ | next unless $valLen > 8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | # long version string is after short version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 1 | my $p = 7 + Get8u(\$val, 6); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 1 | ▶ | next if $p >= $valLen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 1 | my $vlen = Get8u(\$val, $p++); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 1 | ▶ | next if $p + $vlen > $valLen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 1 | my $tagTablePtr = GetTagTable('Image::ExifTool::RSRC::Main'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 1 | $val = $et->Decode(substr($val, $p, $vlen), 'MacRoman'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } elsif ($resType eq 'sfnt') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | # parse the OTF font block | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 1 | ▶ | $raf->Seek($resOff + 4, 0) or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 1 | $$dirInfo{Base} = $resOff + 4; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 1 | require Image::ExifTool::Font; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 1 | ▶ | unless (Image::ExifTool::Font::ProcessOTF($et, $dirInfo)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | $et->Warn('Unrecognized sfnt resource format'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | # assume this is a DFONT file unless processing the rsrc fork | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 1 | ▶ | $et->OverrideFileType('DFONT') unless $$et{DOC_NUM}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } elsif ($resType eq '8BIM') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | my $ttPtr = GetTagTable('Image::ExifTool::Photoshop::Main'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | $et->HandleTag($ttPtr, $id, $val, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | DataPt => \$val, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | DataPos => $resOff + 4, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | Size => $valLen, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | Start => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | Parent => 'RSRC', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | ▶ | } elsif ($resType eq 'STR ' and $valLen > 1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$resType eq "STR " and $valLen > 1
MC/DC0%0/2
$resType eq "STR " and $valLen > 1
$resType eq "STR "
$valLen > 1
Truth table0%0/3
A and B
A= $resType eq "STR "B= $valLen > 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | # extract Pascal string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | my $len = ord $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | next unless $valLen >= $len + 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | $val = substr($val, 1, $len); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | ▶ | } elsif ($resType eq 'usro' and $valLen > 4) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$resType eq "usro" and $valLen > 4
MC/DC0%0/2
$resType eq "usro" and $valLen > 4
$resType eq "usro"
$valLen > 4
Truth table0%0/3
A and B
A= $resType eq "usro"B= $valLen > 4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | my $len = unpack('N', $val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | next unless $valLen >= $len + 4; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ($val = substr($val, 4, $len)) =~ s/\0.*//g; # truncate at null | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | ▶ | } elsif ($resType eq 'STR#' and $valLen > 2) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$resType eq "STR#" and $valLen > 2
MC/DC0%0/2
$resType eq "STR#" and $valLen > 2
$resType eq "STR#"
$valLen > 2
Truth table0%0/3
A and B
A= $resType eq "STR#"B= $valLen > 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | # extract list of strings (ref http://simtech.sourceforge.net/tech/strings.html) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | my $num = unpack('n', $val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | next if $num & 0xf000; # (ignore special-format STR# resources) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | my ($i, @vals); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | my $pos = 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | for ($i=0; $i<$num; ++$i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | last if $pos >= $valLen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | my $len = ord substr($val, $pos++, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | last if $pos + $len > $valLen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | push @vals, substr($val, $pos, $len); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | $pos += $len; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | $val = \@vals; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } elsif ($resType eq 'POST') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | # assume this is a DFONT file unless processing the rsrc fork | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | $et->OverrideFileType('DFONT') unless $$et{DOC_NUM}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $val = substr $val, 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } elsif ($resType ne 'TEXT') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 1 | $et->HandleTag($tagTablePtr, $tag, $val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 2 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 2 | 1; # end | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||