| 1 | package Brackup::DecryptedFile; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 13 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 13 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 13 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 13 | ▶ | use Brackup::Decrypt; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 9 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=14.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 9 | 9 | my ($class, %opts) = @_; | |||||||||||||||||||||||||||
| 10 | 9 | my $self = bless {}, $class; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 9 | $self->{original_file} = delete $opts{filename}; # filename we're restoring from | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | die "File $self->{original_file} does not exist" | ||||||||||||||||||||||||||||
| 15 | 9 | ▶ | unless $self->{original_file} && -f $self->{original_file}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"original_file"} and -f $self->{"original_file"}
MC/DC0%0/2
$self->{"original_file"} and -f $self->{"original_file"}
$self->{"original_file"}
-f $self->{"original_file"}
Truth table33%1/3
A and B
A= $self->{"original_file"}B= -f $self->{"original_file"}
| |||||||||||||||||||||||||||||
| 16 | 9 | ▶ | croak("Unknown options: " . join(', ', keys %opts)) if %opts; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | # decrypted_file might be undef if no decryption was needed. | ||||||||||||||||||||||||||||
| 19 | 9 | $self->{decrypted_file} = Brackup::Decrypt::decrypt_file_if_needed($self->{original_file}); | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 9 | return $self; | |||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 9 | ▶ | sub name { | ||||||||||||||||||||||||||
|
Subroutine
name: called CC=2 SCAR=8.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 25 | 9 | my $self = shift; | |||||||||||||||||||||||||||
| 26 | 9 | ▶ | return $self->{decrypted_file} || $self->{original_file}; | ||||||||||||||||||||||||||
|
Condition33%1/3
$self->{'decrypted_file'} || $self->{'original_file'}
MC/DC0%0/2
$self->{'decrypted_file'} || $self->{'original_file'}
$self->{'decrypted_file'}
$self->{'original_file'}
Truth table33%1/3
A || B
A= $self->{'decrypted_file'}B= $self->{'original_file'}
| |||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 9 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 30 | 9 | my $self = shift; | |||||||||||||||||||||||||||
| 31 | 9 | unlink(grep { $_ } ($self->{decrypted_file})); | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 13 | 1; | |||||||||||||||||||||||||||