| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Filename::Ebook; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
|
4
|
|
|
|
|
|
|
our $DATE = '2020-05-30'; # DATE |
|
5
|
|
|
|
|
|
|
our $DIST = 'Filename-Ebook'; # DIST |
|
6
|
|
|
|
|
|
|
our $VERSION = '0.001'; # VERSION |
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
56977
|
use 5.010001; |
|
|
1
|
|
|
|
|
13
|
|
|
9
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
29
|
|
|
10
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
307
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
require Exporter; |
|
13
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
|
14
|
|
|
|
|
|
|
our @EXPORT_OK = qw(check_ebook_filename); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our %SPEC; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our %SUFFIXES = ( |
|
19
|
|
|
|
|
|
|
'.azw' => {format=>'kindle'}, |
|
20
|
|
|
|
|
|
|
'.azw3' => {format=>'kindle'}, |
|
21
|
|
|
|
|
|
|
'.kf8' => {format=>'kindle'}, |
|
22
|
|
|
|
|
|
|
'.kfx' => {format=>'kindle'}, |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
'.cbr' => {format=>'cbr'}, |
|
25
|
|
|
|
|
|
|
'.cbz' => {format=>'cbr'}, |
|
26
|
|
|
|
|
|
|
'.cb7' => {format=>'cbr'}, |
|
27
|
|
|
|
|
|
|
'.cbt' => {format=>'cbr'}, |
|
28
|
|
|
|
|
|
|
'.cba' => {format=>'cbr'}, |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
'.chm' => {format=>'chm'}, |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
'.djvu' => {format=>'djvu'}, |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
'.doc' => {format=>'doc'}, |
|
35
|
|
|
|
|
|
|
'.docx' => {format=>'docx'}, |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
'.epub' => {format=>'epub'}, |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
'.htm' => {format=>'html'}, |
|
40
|
|
|
|
|
|
|
'.html' => {format=>'html'}, |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
'.mobi' => {format=>'mobi'}, |
|
43
|
|
|
|
|
|
|
'.prc' => {format=>'mobi'}, |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
'.pdf' => {format=>'pdf'}, |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
'.ps' => {format=>'postscript'}, |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
'.rtf' => {format=>'rtf'}, |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
'.text' => {format=>'txt'}, |
|
52
|
|
|
|
|
|
|
'.txt' => {format=>'txt'}, |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# old/unpopular |
|
55
|
|
|
|
|
|
|
# .pdb (palm) |
|
56
|
|
|
|
|
|
|
# .fb2 (fictionbook) |
|
57
|
|
|
|
|
|
|
# .xeb, .ceb (apabi) |
|
58
|
|
|
|
|
|
|
# .ibooks (apple ibook) |
|
59
|
|
|
|
|
|
|
# .inf (ibm) |
|
60
|
|
|
|
|
|
|
# .lit (microsoft lit) |
|
61
|
|
|
|
|
|
|
# .pkg (newton) |
|
62
|
|
|
|
|
|
|
# .opf (open ebook, superseded by epub) |
|
63
|
|
|
|
|
|
|
# .pdg (ssreader) |
|
64
|
|
|
|
|
|
|
# .tr2, .tr3 (tomeraider) |
|
65
|
|
|
|
|
|
|
# .oxps, .xps (open xml paper) |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# ambiguous |
|
68
|
|
|
|
|
|
|
# .xml |
|
69
|
|
|
|
|
|
|
); |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
our %FORMATS = ( |
|
72
|
|
|
|
|
|
|
); |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
our $STR_RE = join "|", map {quotemeta} sort keys %SUFFIXES; |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
our $RE = qr((?:$STR_RE)\z)i; |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
$SPEC{check_ebook_filename} = { |
|
79
|
|
|
|
|
|
|
v => 1.1, |
|
80
|
|
|
|
|
|
|
summary => 'Check whether filename indicates being an e-book', |
|
81
|
|
|
|
|
|
|
description => <<'_', |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
_ |
|
85
|
|
|
|
|
|
|
args => { |
|
86
|
|
|
|
|
|
|
filename => { |
|
87
|
|
|
|
|
|
|
schema => 'str*', |
|
88
|
|
|
|
|
|
|
req => 1, |
|
89
|
|
|
|
|
|
|
pos => 0, |
|
90
|
|
|
|
|
|
|
}, |
|
91
|
|
|
|
|
|
|
ci => { |
|
92
|
|
|
|
|
|
|
summary => 'Whether to match case-insensitively', |
|
93
|
|
|
|
|
|
|
schema => 'bool', |
|
94
|
|
|
|
|
|
|
default => 1, |
|
95
|
|
|
|
|
|
|
}, |
|
96
|
|
|
|
|
|
|
}, |
|
97
|
|
|
|
|
|
|
result_naked => 1, |
|
98
|
|
|
|
|
|
|
}; |
|
99
|
|
|
|
|
|
|
sub check_ebook_filename { |
|
100
|
5
|
|
|
5
|
1
|
82
|
my %args = @_; |
|
101
|
|
|
|
|
|
|
|
|
102
|
5
|
100
|
|
|
|
54
|
$args{filename} =~ $RE ? {} : 0; |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1; |
|
106
|
|
|
|
|
|
|
# ABSTRACT: Check whether filename indicates being an e-book |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
__END__ |