line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package IO::Compress::Adapter::Zstd ; |
2
|
|
|
|
|
|
|
|
3
|
11
|
|
|
11
|
|
81
|
use strict; |
|
11
|
|
|
|
|
25
|
|
|
11
|
|
|
|
|
344
|
|
4
|
11
|
|
|
11
|
|
54
|
use warnings; |
|
11
|
|
|
|
|
23
|
|
|
11
|
|
|
|
|
280
|
|
5
|
11
|
|
|
11
|
|
54
|
use bytes; |
|
11
|
|
|
|
|
21
|
|
|
11
|
|
|
|
|
94
|
|
6
|
|
|
|
|
|
|
|
7
|
11
|
|
|
11
|
|
444
|
use IO::Compress::Base::Common 2.205 qw(:Status); |
|
11
|
|
|
|
|
204
|
|
|
11
|
|
|
|
|
1469
|
|
8
|
11
|
|
|
11
|
|
3883
|
use Compress::Stream::Zstd qw(ZSTD_MAX_CLEVEL); |
|
11
|
|
|
|
|
7225
|
|
|
11
|
|
|
|
|
685
|
|
9
|
11
|
|
|
11
|
|
5338
|
use Compress::Stream::Zstd::Compressor qw(ZSTD_CSTREAM_IN_SIZE); |
|
11
|
|
|
|
|
2384
|
|
|
11
|
|
|
|
|
6060
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our ($VERSION); |
12
|
|
|
|
|
|
|
$VERSION = '2.205'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub mkCompObject |
15
|
|
|
|
|
|
|
{ |
16
|
225
|
|
|
225
|
0
|
23827
|
my $level = shift ; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# TODO - parameterise level |
19
|
225
|
|
|
|
|
4198
|
my $compressor = Compress::Stream::Zstd::Compressor->new($level); |
20
|
|
|
|
|
|
|
|
21
|
225
|
|
|
|
|
1612
|
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
|
57381
|
my $self = shift ; |
34
|
231
|
|
|
|
|
418
|
my $buffer = shift ; |
35
|
|
|
|
|
|
|
|
36
|
231
|
|
|
|
|
427
|
my $def = $self->{Def}; |
37
|
|
|
|
|
|
|
|
38
|
231
|
|
|
|
|
411
|
eval { $_[0] .= $def->compress($$buffer) ; }; |
|
231
|
|
|
|
|
28318
|
|
39
|
|
|
|
|
|
|
|
40
|
231
|
50
|
33
|
|
|
1834
|
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
|
|
|
|
|
559
|
$self->{Error} = ''; |
48
|
231
|
|
|
|
|
392
|
$self->{ErrorNo} = 0; |
49
|
|
|
|
|
|
|
|
50
|
231
|
|
|
|
|
612
|
return STATUS_OK; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub flush |
54
|
|
|
|
|
|
|
{ |
55
|
4
|
|
|
4
|
0
|
947
|
my $self = shift ; |
56
|
|
|
|
|
|
|
|
57
|
4
|
|
|
|
|
10
|
my $def = $self->{Def}; |
58
|
|
|
|
|
|
|
|
59
|
4
|
|
|
|
|
8
|
eval { $_[0] .= $def->flush() } ; |
|
4
|
|
|
|
|
78
|
|
60
|
|
|
|
|
|
|
|
61
|
4
|
50
|
|
|
|
18
|
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
|
|
|
|
|
11
|
return STATUS_OK; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub close |
73
|
|
|
|
|
|
|
{ |
74
|
224
|
|
|
224
|
0
|
32313
|
my $self = shift ; |
75
|
|
|
|
|
|
|
|
76
|
224
|
|
|
|
|
413
|
my $def = $self->{Def}; |
77
|
|
|
|
|
|
|
|
78
|
224
|
|
|
|
|
413
|
eval { $_[0] .= $def->end() } ; |
|
224
|
|
|
|
|
5098
|
|
79
|
|
|
|
|
|
|
|
80
|
224
|
50
|
|
|
|
822
|
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
|
|
|
|
|
550
|
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__ |