line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Gzip::Libdeflate; |
2
|
2
|
|
|
2
|
|
136927
|
use warnings; |
|
2
|
|
|
|
|
17
|
|
|
2
|
|
|
|
|
64
|
|
3
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
124
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.04_03'; |
5
|
|
|
|
|
|
|
require XSLoader; |
6
|
|
|
|
|
|
|
XSLoader::load ('Gzip::Libdeflate', $VERSION); |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
961
|
use File::Slurper qw!read_binary write_binary!; |
|
2
|
|
|
|
|
26937
|
|
|
2
|
|
|
|
|
111
|
|
9
|
2
|
|
|
2
|
|
14
|
use Carp; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
728
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub get_from |
12
|
|
|
|
|
|
|
{ |
13
|
4
|
|
|
4
|
0
|
14
|
my (%options) = @_; |
14
|
4
|
|
|
|
|
6
|
my $from; |
15
|
4
|
50
|
|
|
|
12
|
if ($options{in}) { |
|
|
0
|
|
|
|
|
|
16
|
4
|
|
|
|
|
25
|
$from = read_binary ($options{in}); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
elsif ($options{from}) { |
19
|
0
|
|
|
|
|
0
|
$from = $options{from}; |
20
|
|
|
|
|
|
|
} |
21
|
4
|
50
|
|
|
|
423
|
if (! $from) { |
22
|
0
|
|
|
|
|
0
|
carp "Specify one of from => scalar or in => file"; |
23
|
|
|
|
|
|
|
} |
24
|
4
|
|
|
|
|
17
|
return $from; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub make_out |
28
|
|
|
|
|
|
|
{ |
29
|
4
|
|
|
4
|
0
|
28
|
my ($out, %options) = @_; |
30
|
4
|
|
|
|
|
10
|
my $outfile = $options{out}; |
31
|
4
|
100
|
|
|
|
10
|
if ($outfile) { |
32
|
2
|
|
|
|
|
11
|
write_binary ($outfile, $out); |
33
|
|
|
|
|
|
|
} |
34
|
4
|
|
|
|
|
390
|
return $out; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub compress_file |
38
|
|
|
|
|
|
|
{ |
39
|
1
|
|
|
1
|
1
|
340
|
my ($o, %options) = @_; |
40
|
1
|
|
|
|
|
4
|
my $from = get_from (%options); |
41
|
1
|
50
|
|
|
|
6
|
if (! $from) { |
42
|
0
|
|
|
|
|
0
|
return undef; |
43
|
|
|
|
|
|
|
} |
44
|
1
|
|
|
|
|
2074
|
my $out = $o->compress ($from); |
45
|
1
|
|
|
|
|
7
|
return make_out ($out, %options); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub decompress_file |
49
|
|
|
|
|
|
|
{ |
50
|
3
|
|
|
3
|
1
|
1790
|
my ($o, %options) = @_; |
51
|
3
|
|
|
|
|
11
|
my $from = get_from (%options); |
52
|
3
|
50
|
|
|
|
10
|
if (! $from) { |
53
|
0
|
|
|
|
|
0
|
return undef; |
54
|
|
|
|
|
|
|
} |
55
|
3
|
|
|
|
|
16
|
my $type = $o->get_type (); |
56
|
3
|
50
|
|
|
|
10
|
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
|
|
|
|
|
902
|
my $out = $o->decompress ($from, $size); |
67
|
3
|
|
|
|
|
15
|
return make_out ($out, %options); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |