line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package IO::Compress::Adapter::Zstd ; |
2
|
|
|
|
|
|
|
|
3
|
11
|
|
|
11
|
|
82
|
use strict; |
|
11
|
|
|
|
|
23
|
|
|
11
|
|
|
|
|
336
|
|
4
|
11
|
|
|
11
|
|
54
|
use warnings; |
|
11
|
|
|
|
|
20
|
|
|
11
|
|
|
|
|
246
|
|
5
|
11
|
|
|
11
|
|
57
|
use bytes; |
|
11
|
|
|
|
|
22
|
|
|
11
|
|
|
|
|
52
|
|
6
|
|
|
|
|
|
|
|
7
|
11
|
|
|
11
|
|
350
|
use IO::Compress::Base::Common 2.206 qw(:Status); |
|
11
|
|
|
|
|
181
|
|
|
11
|
|
|
|
|
1421
|
|
8
|
11
|
|
|
11
|
|
3863
|
use Compress::Stream::Zstd qw(ZSTD_MAX_CLEVEL); |
|
11
|
|
|
|
|
6484
|
|
|
11
|
|
|
|
|
673
|
|
9
|
11
|
|
|
11
|
|
5055
|
use Compress::Stream::Zstd::Compressor qw(ZSTD_CSTREAM_IN_SIZE); |
|
11
|
|
|
|
|
2292
|
|
|
11
|
|
|
|
|
5735
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our ($VERSION); |
12
|
|
|
|
|
|
|
$VERSION = '2.206'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub mkCompObject |
15
|
|
|
|
|
|
|
{ |
16
|
225
|
|
|
225
|
0
|
22623
|
my $level = shift ; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# TODO - parameterise level |
19
|
225
|
|
|
|
|
4406
|
my $compressor = Compress::Stream::Zstd::Compressor->new($level); |
20
|
|
|
|
|
|
|
|
21
|
225
|
|
|
|
|
1589
|
return bless { |
22
|
|
|
|
|
|
|
'Def' => $compressor, |
23
|
|
|
|
|
|
|
'Buffer' => '', |
24
|
|
|
|
|
|
|
'Error' => '', |
25
|
|
|
|
|
|
|
'ErrorNo' => 0, |
26
|
|
|
|
|
|
|
'CompBytes' => 0, |
27
|
|
|
|
|
|
|
'UnCompBytes'=> 0, |
28
|
|
|
|
|
|
|
} ; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub compr |
32
|
|
|
|
|
|
|
{ |
33
|
231
|
|
|
231
|
0
|
57338
|
my $self = shift ; |
34
|
231
|
|
|
|
|
357
|
my $buffer = shift ; |
35
|
|
|
|
|
|
|
|
36
|
231
|
|
|
|
|
462
|
my $def = $self->{Def}; |
37
|
|
|
|
|
|
|
|
38
|
231
|
|
|
|
|
418
|
eval { $_[0] .= $def->compress($$buffer) ; }; |
|
231
|
|
|
|
|
28770
|
|
39
|
|
|
|
|
|
|
|
40
|
231
|
50
|
33
|
|
|
1816
|
if ($@ || $def->isError()) |
41
|
|
|
|
|
|
|
{ |
42
|
0
|
|
|
|
|
0
|
$self->{Error} = $def->getErrorName(); |
43
|
0
|
|
|
|
|
0
|
$self->{ErrorNo} = $def->status() ; |
44
|
0
|
|
|
|
|
0
|
return STATUS_ERROR ; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
231
|
|
|
|
|
565
|
$self->{Error} = ''; |
48
|
231
|
|
|
|
|
373
|
$self->{ErrorNo} = 0; |
49
|
|
|
|
|
|
|
|
50
|
231
|
|
|
|
|
588
|
return STATUS_OK; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub flush |
54
|
|
|
|
|
|
|
{ |
55
|
4
|
|
|
4
|
0
|
943
|
my $self = shift ; |
56
|
|
|
|
|
|
|
|
57
|
4
|
|
|
|
|
10
|
my $def = $self->{Def}; |
58
|
|
|
|
|
|
|
|
59
|
4
|
|
|
|
|
8
|
eval { $_[0] .= $def->flush() } ; |
|
4
|
|
|
|
|
58
|
|
60
|
|
|
|
|
|
|
|
61
|
4
|
50
|
|
|
|
17
|
if ($@) |
62
|
|
|
|
|
|
|
{ |
63
|
0
|
|
|
|
|
0
|
$self->{ErrorNo} = $def->status() ; |
64
|
0
|
|
|
|
|
0
|
return STATUS_ERROR ; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
4
|
|
|
|
|
9
|
$self->{ErrorNo} = 0; |
68
|
|
|
|
|
|
|
|
69
|
4
|
|
|
|
|
10
|
return STATUS_OK; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub close |
73
|
|
|
|
|
|
|
{ |
74
|
224
|
|
|
224
|
0
|
32452
|
my $self = shift ; |
75
|
|
|
|
|
|
|
|
76
|
224
|
|
|
|
|
430
|
my $def = $self->{Def}; |
77
|
|
|
|
|
|
|
|
78
|
224
|
|
|
|
|
390
|
eval { $_[0] .= $def->end() } ; |
|
224
|
|
|
|
|
4946
|
|
79
|
|
|
|
|
|
|
|
80
|
224
|
50
|
|
|
|
840
|
if ($@) |
81
|
|
|
|
|
|
|
{ |
82
|
0
|
|
|
|
|
0
|
$self->{ErrorNo} = $def->status() ; |
83
|
0
|
|
|
|
|
0
|
return STATUS_ERROR ; |
84
|
|
|
|
|
|
|
} |
85
|
224
|
|
|
|
|
426
|
$self->{ErrorNo} = 0; |
86
|
|
|
|
|
|
|
|
87
|
224
|
|
|
|
|
512
|
return STATUS_OK; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub reset |
93
|
|
|
|
|
|
|
{ |
94
|
0
|
|
|
0
|
0
|
|
my $self = shift ; |
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
my $def = $self->{Def}; |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
eval { $_[0] = $def->init() } ; |
|
0
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
0
|
0
|
|
|
|
|
if ($@) |
101
|
|
|
|
|
|
|
{ |
102
|
0
|
|
|
|
|
|
$self->{ErrorNo} = $def->status() ; |
103
|
0
|
|
|
|
|
|
return STATUS_ERROR ; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
$self->{ErrorNo} = 0; |
107
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
return STATUS_OK; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub compressedBytes |
112
|
|
|
|
|
|
|
{ |
113
|
0
|
|
|
0
|
0
|
|
my $self = shift ; |
114
|
0
|
|
|
|
|
|
$self->{CompBytes}; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub uncompressedBytes |
118
|
|
|
|
|
|
|
{ |
119
|
0
|
|
|
0
|
0
|
|
my $self = shift ; |
120
|
0
|
|
|
|
|
|
$self->{UnCompBytes}; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
1; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
__END__ |