| 1 | package App::BCSSH::Handler::scp; | ||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 1 | my $have_pty; | |||||||||||||||||||||||||||
| 4 | 0 | ▶ | BEGIN { eval {require IO::Pty::Easy; $have_pty = 1} } | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.4
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | with 'App::BCSSH::Handler'; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | has destination => ( | ||||||||||||||||||||||||||||
| 9 | is => 'ro', | ||||||||||||||||||||||||||||
| 10 | 0 | ▶ | default => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 11 | -d && return $_ | ||||||||||||||||||||||||||||
| 12 | 0 | ▶ | for ("$ENV{HOME}/Desktop", "$ENV{HOME}/desktop", $ENV{HOME}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 13 | }, | ||||||||||||||||||||||||||||
| 14 | 1 | ); | |||||||||||||||||||||||||||
| 15 | has scp => ( | ||||||||||||||||||||||||||||
| 16 | is => 'ro', | ||||||||||||||||||||||||||||
| 17 | 0 | ▶ | default => sub { 'scp' }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 18 | 1 | ); | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 0 | ▶ | sub handle { | ||||||||||||||||||||||||||
|
Subroutine
handle: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 21 | 0 | my ($self, $send, $args) = @_; | |||||||||||||||||||||||||||
| 22 | 0 | my $files = $args->{files}; | |||||||||||||||||||||||||||
| 23 | 0 | for my $file (@$files) { | |||||||||||||||||||||||||||
| 24 | 0 | $file = $self->host.':'.$file; | |||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | 0 | my $socket = $send->(); | |||||||||||||||||||||||||||
| 27 | 0 | ▶ | fork and return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | 0 | ▶ | my @scp = ref $self->scp ? @{ $self->scp } : $self->scp; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | 0 | my @command = (@scp, '-r', '--', @$files, $self->destination); | |||||||||||||||||||||||||||
| 30 | 0 | ▶ | if ($have_pty) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | 0 | my $pty = IO::Pty::Easy->new; | |||||||||||||||||||||||||||
| 32 | 0 | $pty->spawn(@command); | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 0 | ▶ | while ($pty->is_active) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 0 | my $output = $pty->read; | |||||||||||||||||||||||||||
| 36 | 0 | ▶ | last if defined($output) && $output eq ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $output and $output eq ""
MC/DC0%0/2
defined $output and $output eq ""
defined $output
$output eq ""
Truth table0%0/3
A and B
A= defined $outputB= $output eq ""
| |||||||||||||||||||||||||||||
| 37 | 0 | $socket->syswrite($output); | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | 0 | $pty->close; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | else { | ||||||||||||||||||||||||||||
| 42 | 0 | system @command; | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | 0 | $socket->shutdown(2); | |||||||||||||||||||||||||||
| 45 | 0 | exit; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 1 | 1; | |||||||||||||||||||||||||||