Any/OS/MSWin/DPipe.pm untested

filter: Statementstmt 0.0% 0 / 59 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 14 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 83 CC 4 SCAR 14.4
CC
4
Cov
0%
send_eof
12.0
_close_fhs
6.0
_in
2.0
CRAP 4.2
1 package Net::SSH::Any::OS::MSWin::DPipe;
2  
3 use strict;
4 use warnings;
5  
6 use Carp;
7 use Socket;
8 use Errno;
9 use Net::SSH::Any::Util qw($debug _debug _debug_hexdump _first_defined _array_or_scalar_to_list);
10 use Net::SSH::Any::Constants qw(SSHA_CHANNEL_ERROR);
11 use Time::HiRes qw(sleep);
12  
13 require Net::SSH::Any::OS::_Base::DPipe;
14 our @ISA = qw(Net::SSH::Any::OS::_Base::DPipe);
15  
16 sub _in { ${*{shift()}}{_ssha_os_in} }
17  
18 for my $method (qw(syswrite print printf say autoflush)) {
19 my $m = $method;
20 no strict 'refs';
21 *{$m} = sub { shift->_in->$m(@_) }
22 }
23  
24 sub _upgrade_fh_to_dpipe {
25 my ($class, $dpipe, $any, $proc, $in) = @_;
26 $class->SUPER::_upgrade_fh_to_dpipe($dpipe, $any, $proc);
27 bless $in, 'IO::Handle';
28 ${*$dpipe}{_ssha_os_in} = $in;
29 $in->autoflush(1);
30 $dpipe;
31 }
32  
33 sub _close_fhs {
34 my $dpipe = shift;
35 my $ok = $dpipe->send_eof;
36 unless (close $dpipe) {
37 $dpipe->_any->_set_error(SSHA_CHANNEL_ERROR, "unable to close dpipe reading side: $!");
38 undef $ok;
39 }
40 return $ok;
41 }
42  
43 sub send_eof {
44 my $dpipe = shift;
45 if (defined (my $in = delete ${*$dpipe}{_ssha_os_in})) {
46 unless (close $in) {
47 $dpipe->_any->_set_error(SSHA_CHANNEL_ERROR, "unable to close dpipe writing side: $!");
48 return undef
49 }
50 }
51 1
52 }
53  
54 1;