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   274 use 5.016;
  17         63  
3             our $VERSION = '2.03';
4 17     17   96 use strict;
  17         29  
  17         479  
5 17     17   74 use warnings;
  17         52  
  17         881  
6              
7 17     17   89 use parent 'EBook::Ishmael::EBook::Mobi';
  17         30  
  17         135  
8              
9             my $TYPE = 'BOOK';
10             my $CREATOR = 'MOBI';
11              
12             sub heuristic {
13              
14 81     81 0 202 my $class = shift;
15 81         221 my $file = shift;
16 81         192 my $fh = shift;
17              
18 81 50       1566 return 0 unless -s $file >= 68;
19              
20 81         463 seek $fh, 32, 0;
21 81         807 read $fh, my ($null), 1;
22              
23 81 100       362 unless ($null eq "\0") {
24 35         176 return 0;
25             }
26              
27 46         310 seek $fh, 60, 0;
28 46         298 read $fh, my ($type), 4;
29 46         137 read $fh, my ($creator), 4;
30              
31 46 100 66     379 return 0 unless $type eq $TYPE && $creator eq $CREATOR;
32              
33 22         212 seek $fh, 78, 0;
34 22         155 read $fh, my ($off), 4;
35 22         143 $off = unpack "N", $off;
36 22         253 seek $fh, $off + 36, 0;
37 22         166 read $fh, my ($ver), 4;
38 22         69 $ver = unpack "N", $ver;
39              
40 22         160 return $ver == 8;
41              
42             }
43              
44             1;