line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Gzip::Libdeflate; |
2
|
2
|
|
|
2
|
|
139069
|
use warnings; |
|
2
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
64
|
|
3
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
125
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
5
|
|
|
|
|
|
|
require XSLoader; |
6
|
|
|
|
|
|
|
XSLoader::load ('Gzip::Libdeflate', $VERSION); |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
938
|
use File::Slurper qw!read_binary write_binary!; |
|
2
|
|
|
|
|
27482
|
|
|
2
|
|
|
|
|
114
|
|
9
|
2
|
|
|
2
|
|
14
|
use Carp; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
703
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub get_from |
12
|
|
|
|
|
|
|
{ |
13
|
4
|
|
|
4
|
0
|
11
|
my (%options) = @_; |
14
|
4
|
|
|
|
|
5
|
my $from; |
15
|
4
|
50
|
|
|
|
14
|
if ($options{in}) { |
|
|
0
|
|
|
|
|
|
16
|
4
|
|
|
|
|
12
|
$from = read_binary ($options{in}); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
elsif ($options{from}) { |
19
|
0
|
|
|
|
|
0
|
$from = $options{from}; |
20
|
|
|
|
|
|
|
} |
21
|
4
|
50
|
|
|
|
411
|
if (! $from) { |
22
|
0
|
|
|
|
|
0
|
carp "Specify one of from => scalar or in => file"; |
23
|
|
|
|
|
|
|
} |
24
|
4
|
|
|
|
|
12
|
return $from; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub make_out |
28
|
|
|
|
|
|
|
{ |
29
|
4
|
|
|
4
|
0
|
27
|
my ($out, %options) = @_; |
30
|
4
|
|
|
|
|
12
|
my $outfile = $options{out}; |
31
|
4
|
100
|
|
|
|
13
|
if ($outfile) { |
32
|
2
|
|
|
|
|
12
|
write_binary ($outfile, $out); |
33
|
|
|
|
|
|
|
} |
34
|
4
|
|
|
|
|
364
|
return $out; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub compress_file |
38
|
|
|
|
|
|
|
{ |
39
|
1
|
|
|
1
|
1
|
379
|
my ($o, %options) = @_; |
40
|
1
|
|
|
|
|
4
|
my $from = get_from (%options); |
41
|
1
|
50
|
|
|
|
5
|
if (! $from) { |
42
|
0
|
|
|
|
|
0
|
return undef; |
43
|
|
|
|
|
|
|
} |
44
|
1
|
|
|
|
|
2070
|
my $out = $o->compress ($from); |
45
|
1
|
|
|
|
|
7
|
return make_out ($out, %options); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub decompress_file |
49
|
|
|
|
|
|
|
{ |
50
|
3
|
|
|
3
|
1
|
1852
|
my ($o, %options) = @_; |
51
|
3
|
|
|
|
|
11
|
my $from = get_from (%options); |
52
|
3
|
50
|
|
|
|
9
|
if (! $from) { |
53
|
0
|
|
|
|
|
0
|
return undef; |
54
|
|
|
|
|
|
|
} |
55
|
3
|
|
|
|
|
30
|
my $type = $o->get_type (); |
56
|
3
|
50
|
|
|
|
11
|
if ($type ne 'gzip') { |
57
|
0
|
0
|
|
|
|
0
|
if (! $options{size}) { |
58
|
0
|
|
|
|
|
0
|
warn "A non-zero numerical size is required to decompress deflate/zlib inputs"; |
59
|
0
|
|
|
|
|
0
|
return undef; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
3
|
|
|
|
|
7
|
my $size = $options{size}; |
63
|
3
|
50
|
|
|
|
7
|
if (! $size) { |
64
|
3
|
|
|
|
|
4
|
$size = 0; |
65
|
|
|
|
|
|
|
} |
66
|
3
|
|
|
|
|
884
|
my $out = $o->decompress ($from, $size); |
67
|
3
|
|
|
|
|
17
|
return make_out ($out, %options); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |