File Coverage

blib/lib/Finnigan/OLE2Header.pm
Criterion Covered Total %
statement 34 34 100.0
branch n/a
condition n/a
subroutine 16 16 100.0
pod 11 11 100.0
total 61 61 100.0


line stmt bran cond sub pod time code
1             package Finnigan::OLE2Header;
2              
3 2     2   11 use strict;
  2         4  
  2         79  
4 2     2   10 use warnings FATAL => qw( all );
  2         4  
  2         96  
5             our $VERSION = 0.0206;
6              
7 2     2   11 use Finnigan;
  2         3  
  2         41  
8 2     2   11 use base 'Finnigan::Decoder';
  2         3  
  2         206  
9              
10 2     2   11 use overload ('""' => 'stringify');
  2         3  
  2         20  
11              
12             sub decode {
13 1     1 1 4 my ($class, $stream, $version) = @_;
14              
15 1         17 my @fields = (
16             "guid" => ['a16', 'RawBytes'], # used by some apps
17             "minor version" => ['v', 'UInt16'],
18             "major version" => ['v', 'UInt16'],
19             "endian" => ['a2', 'RawBytes'], # 0xFFFE for Intel
20             "bb log" => ['v', 'UInt16'], # log2-size of big blocks
21             "sb log" => ['v', 'UInt16'], # log2-size of small blocks (minisectors)
22             "reserved" => ['a6', 'RawBytes'],
23             "csectdir" => ['V', 'UInt32'], # Number of sector pointers in directory chain (sector size 4 kb)
24             "bb count" => ['V', 'UInt32'], # number of blocks in Big Block Depot (number of SECTs in the FAT chain)
25             "bb start" => ['V', 'UInt32'], # the first block in Big Block Depot (first SECT in the Directory chain)
26             "transaction" => ['a4', 'RawBytes'], # transaction signature
27             "ministream max" => ['V', 'UInt32'], # max. size of a ministream (4096)
28             "sb start" => ['V', 'UInt32'], # the first block in Small Block Depot (first SECT in the mini-FAT chain)
29             "sb count" => ['V', 'UInt32'], # number of blocks in Small Block Depot (number of SECTs in the mini-FAT chain)
30             "dif start" => ['V', 'UInt32'], # the first SECT in the DIF chain (should be 0xfffffffe if the file is smaller than 7Mb)
31             "dif count" => ['V', 'UInt32'], # number of SECTs in the DIF chain (should be 0 if the file is smaller than 7Mb)
32             );
33              
34 1         5 my $self = Finnigan::Decoder->read($stream, \@fields, $version);
35 1         9 return bless $self, $class;
36             }
37              
38             sub stringify {
39 1     1 1 2 my $self = shift;
40              
41 1         8 my $version = $self->{data}->{"major version"}->{value} . "." . $self->{data}->{"minor version"}->{value};
42 1         6 my $fat_blocks = $self->bb_count;
43 1         5 my $minifat_blocks = $self->sb_count;
44 1         4 my $dif_blocks = $self->dif_count;
45 1         8 return "Version $version; block(s) in FAT chain: $fat_blocks; in mini-FAT chain: $minifat_blocks; in DIF chain: $dif_blocks";
46             }
47              
48             sub ministream_max {
49 3     3 1 23 shift->{data}->{"ministream max"}->{value};
50             }
51              
52             sub bb_log {
53 6     6 1 31 shift->{data}->{"bb log"}->{value};
54             }
55              
56             sub sb_log {
57 1     1 1 6 shift->{data}->{"sb log"}->{value};
58             }
59              
60             sub bb_start {
61 1     1 1 6 shift->{data}->{"bb start"}->{value};
62             }
63              
64             sub bb_count {
65 2     2 1 8 shift->{data}->{"bb count"}->{value};
66             }
67              
68             sub sb_start {
69 1     1 1 8 shift->{data}->{"sb start"}->{value};
70             }
71              
72             sub sb_count {
73 1     1 1 4 shift->{data}->{"sb count"}->{value};
74             }
75              
76             sub dif_start {
77 1     1 1 6 shift->{data}->{"dif start"}->{value};
78             }
79              
80             sub dif_count {
81 2     2 1 14 shift->{data}->{"dif count"}->{value};
82             }
83              
84             1;
85             __END__