| 1 | package IO::Compress::Adapter::Zstd ; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 11 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 11 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 11 | ▶ | use bytes; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 11 | ▶ | use IO::Compress::Base::Common 2.224 qw(:Status); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 11 | ▶ | use Compress::Stream::Zstd qw(ZSTD_MAX_CLEVEL); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 11 | ▶ | use Compress::Stream::Zstd::Compressor qw(ZSTD_CSTREAM_IN_SIZE); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 11 | our ($VERSION); | |||||||||||||||||||||||||||
| 12 | 11 | $VERSION = '2.224'; | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | sub mkCompObject | ||||||||||||||||||||||||||||
| 15 | 225 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
mkCompObject: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 16 | 225 | my $level = shift ; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | # TODO - parameterise level | ||||||||||||||||||||||||||||
| 19 | 225 | my $compressor = Compress::Stream::Zstd::Compressor->new($level); | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 225 | 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 | 231 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
compr: called CC=3 SCAR=12.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 33 | 231 | my $self = shift ; | |||||||||||||||||||||||||||
| 34 | 231 | my $buffer = shift ; | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 231 | my $def = $self->{Def}; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 231 | eval { $_[0] .= $def->compress($$buffer) ; }; | |||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 231 | ▶ | if ($@ || $def->isError()) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$@ or $def->isError
MC/DC0%0/2
$@ or $def->isError
$@
$def->isError
Truth table33%1/3
A or B
A= $@B= $def->isError
| |||||||||||||||||||||||||||||
| 41 | { | ||||||||||||||||||||||||||||
| 42 | 0 | $self->{Error} = $def->getErrorName(); | |||||||||||||||||||||||||||
| 43 | 0 | $self->{ErrorNo} = $def->status() ; | |||||||||||||||||||||||||||
| 44 | 0 | return STATUS_ERROR ; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 231 | $self->{Error} = ''; | |||||||||||||||||||||||||||
| 48 | 231 | $self->{ErrorNo} = 0; | |||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 231 | return STATUS_OK; | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | sub flush | ||||||||||||||||||||||||||||
| 54 | 4 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
flush: called CC=2 SCAR=7.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 55 | 4 | my $self = shift ; | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 4 | my $def = $self->{Def}; | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 4 | eval { $_[0] .= $def->flush() } ; | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 4 | ▶ | if ($@) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | { | ||||||||||||||||||||||||||||
| 63 | 0 | $self->{ErrorNo} = $def->status() ; | |||||||||||||||||||||||||||
| 64 | 0 | return STATUS_ERROR ; | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 4 | $self->{ErrorNo} = 0; | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 4 | return STATUS_OK; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | sub close | ||||||||||||||||||||||||||||
| 73 | 224 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
close: called CC=2 SCAR=7.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 74 | 224 | my $self = shift ; | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 224 | my $def = $self->{Def}; | |||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 224 | eval { $_[0] .= $def->end() } ; | |||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 224 | ▶ | if ($@) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | { | ||||||||||||||||||||||||||||
| 82 | 0 | $self->{ErrorNo} = $def->status() ; | |||||||||||||||||||||||||||
| 83 | 0 | return STATUS_ERROR ; | |||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | 224 | $self->{ErrorNo} = 0; | |||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 224 | return STATUS_OK; | |||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | sub reset | ||||||||||||||||||||||||||||
| 93 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
reset: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 94 | 0 | my $self = shift ; | |||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 0 | my $def = $self->{Def}; | |||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 0 | eval { $_[0] = $def->init() } ; | |||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 0 | ▶ | if ($@) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
compressedBytes: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 113 | 0 | my $self = shift ; | |||||||||||||||||||||||||||
| 114 | 0 | $self->{CompBytes}; | |||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | sub uncompressedBytes | ||||||||||||||||||||||||||||
| 118 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
uncompressedBytes: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 119 | 0 | my $self = shift ; | |||||||||||||||||||||||||||
| 120 | 0 | $self->{UnCompBytes}; | |||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 11 | 1; | |||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | __END__ | ||||||||||||||||||||||||||||