File Coverage

blib/lib/EBook/Ishmael/EBook/KF8.pm
Criterion Covered Total %
statement 30 30 100.0
branch 5 6 83.3
condition 2 3 66.6
subroutine 5 5 100.0
pod 0 1 0.0
total 42 45 93.3


line stmt bran cond sub pod time code
1             package EBook::Ishmael::EBook::KF8;
2 17     17   261 use 5.016;
  17         49  
3             our $VERSION = '2.05';
4 17     17   101 use strict;
  17         20  
  17         326  
5 17     17   57 use warnings;
  17         20  
  17         746  
6              
7 17     17   73 use parent 'EBook::Ishmael::EBook::Mobi';
  17         44  
  17         95  
8              
9             my $TYPE = 'BOOK';
10             my $CREATOR = 'MOBI';
11              
12             sub heuristic {
13              
14 81     81 0 123 my $class = shift;
15 81         112 my $file = shift;
16 81         116 my $fh = shift;
17              
18 81 50       988 return 0 unless -s $file >= 68;
19              
20 81         312 seek $fh, 32, 0;
21 81         465 read $fh, my ($null), 1;
22              
23 81 100       215 unless ($null eq "\0") {
24 35         105 return 0;
25             }
26              
27 46         235 seek $fh, 60, 0;
28 46         218 read $fh, my ($type), 4;
29 46         79 read $fh, my ($creator), 4;
30              
31 46 100 66     220 return 0 unless $type eq $TYPE && $creator eq $CREATOR;
32              
33 22         105 seek $fh, 78, 0;
34 22         87 read $fh, my ($off), 4;
35 22         83 $off = unpack "N", $off;
36 22         118 seek $fh, $off + 36, 0;
37 22         97 read $fh, my ($ver), 4;
38 22         34 $ver = unpack "N", $ver;
39              
40 22         68 return $ver == 8;
41              
42             }
43              
44             1;