| 1 | package File::Copy::Reliable; | ||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 2 | ▶ | use Carp qw(croak); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 2 | ▶ | use File::Copy; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 2 | ▶ | use Path::Class; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 2 | ▶ | use Exporter 'import'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 2 | our @EXPORT = qw(copy_reliable move_reliable); | |||||||||||
| 9 | 2 | our $VERSION = '0.32'; | |||||||||||
| 10 | |||||||||||||
| 11 | 5 | ▶ | sub copy_reliable { | ||||||||||
|
Subroutine
copy_reliable: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||
| 12 | 5 | my ( $source, $destination ) = @_; | |||||||||||
| 13 | 5 | ▶ | my $source_size = (-s $source) || 0; | ||||||||||
|
Condition100%2/2
-s $source || 0
MC/DC100%1/1
-s $source || 0
-s $source
Truth table100%2/2
A
A= -s $source
| |||||||||||||
| 14 | |||||||||||||
| 15 | 5 | ▶ | copy( $source, $destination ) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 16 | || croak("copy_reliable($source, $destination) failed: $!"); | ||||||||||||
| 17 | 3 | my $destination_file = $destination; | |||||||||||
| 18 | 3 | ▶ | if (-d $destination) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 19 | 1 | $destination_file = file( $destination, file( $source )->basename ); | |||||||||||
| 20 | } | ||||||||||||
| 21 | 3 | ▶ | my $destination_size = (-s $destination_file) || 0; | ||||||||||
|
Condition100%2/2
-s $destination_file || 0
MC/DC100%1/1
-s $destination_file || 0
-s $destination_file
Truth table100%2/2
A
A= -s $destination_file
| |||||||||||||
| 22 | 3 | ▶ | croak( | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 23 | "copy_reliable($source, $destination) failed copied $destination_size bytes out of $source_size" | ||||||||||||
| 24 | ) | ||||||||||||
| 25 | if ( $source_size != $destination_size ); | ||||||||||||
| 26 | 2 | 1; | |||||||||||
| 27 | |||||||||||||
| 28 | } | ||||||||||||
| 29 | |||||||||||||
| 30 | 4 | ▶ | sub move_reliable { | ||||||||||
|
Subroutine
move_reliable: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||
| 31 | 4 | my ( $source, $destination ) = @_; | |||||||||||
| 32 | 4 | ▶ | my $source_size = (-s $source) || 0; | ||||||||||
|
Condition100%2/2
-s $source || 0
MC/DC100%1/1
-s $source || 0
-s $source
Truth table100%2/2
A
A= -s $source
| |||||||||||||
| 33 | |||||||||||||
| 34 | 4 | ▶ | move( $source, $destination ) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 35 | || croak("move_reliable($source, $destination) failed: $!"); | ||||||||||||
| 36 | 2 | my $destination_file = $destination; | |||||||||||
| 37 | 2 | ▶ | if (-d $destination) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 38 | 0 | $destination_file = file( $destination, file( $source )->basename ); | |||||||||||
| 39 | } | ||||||||||||
| 40 | 2 | ▶ | my $destination_size = (-s $destination_file) || 0; | ||||||||||
|
Condition100%2/2
-s $destination_file || 0
MC/DC100%1/1
-s $destination_file || 0
-s $destination_file
Truth table100%2/2
A
A= -s $destination_file
| |||||||||||||
| 41 | 2 | ▶ | croak( | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 42 | "move_reliable($source, $destination) failed copied $destination_size bytes out of $source_size" | ||||||||||||
| 43 | ) | ||||||||||||
| 44 | if ( $source_size != $destination_size ); | ||||||||||||
| 45 | 1 | 1; | |||||||||||
| 46 | } | ||||||||||||
| 47 | |||||||||||||
| 48 | 2 | 1; | |||||||||||
| 49 | |||||||||||||
| 50 | __END__ | ||||||||||||