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   346 use 5.016;
  17         109  
3             our $VERSION = '2.01';
4 17     17   111 use strict;
  17         38  
  17         629  
5 17     17   139 use warnings;
  17         37  
  17         1074  
6              
7 17     17   125 use parent 'EBook::Ishmael::EBook::Mobi';
  17         66  
  17         155  
8              
9             my $TYPE = 'BOOK';
10             my $CREATOR = 'MOBI';
11              
12             sub heuristic {
13              
14 81     81 0 207 my $class = shift;
15 81         183 my $file = shift;
16 81         173 my $fh = shift;
17              
18 81 50       1589 return 0 unless -s $file >= 68;
19              
20 81         495 seek $fh, 32, 0;
21 81         821 read $fh, my ($null), 1;
22              
23 81 100       364 unless ($null eq "\0") {
24 35         206 return 0;
25             }
26              
27 46         360 seek $fh, 60, 0;
28 46         265 read $fh, my ($type), 4;
29 46         115 read $fh, my ($creator), 4;
30              
31 46 100 66     433 return 0 unless $type eq $TYPE && $creator eq $CREATOR;
32              
33 22         170 seek $fh, 78, 0;
34 22         150 read $fh, my ($off), 4;
35 22         123 $off = unpack "N", $off;
36 22         182 seek $fh, $off + 36, 0;
37 22         152 read $fh, my ($ver), 4;
38 22         67 $ver = unpack "N", $ver;
39              
40 22         239 return $ver == 8;
41              
42             }
43              
44             1;