diff options
author | Graham Barr <gbarr@pobox.com> | 1999-05-05 07:08:07 +0000 |
---|---|---|
committer | Graham Barr <gbarr@pobox.com> | 1999-05-05 07:08:07 +0000 |
commit | 6e20c7178b991896e16f76de3ff218a4dd2358b9 (patch) | |
tree | 452b43896b9b58f8db8febe68e5832b1d913b5d9 | |
parent | 14fa89ca573adc2de041fbd67e96b71d62d91fda (diff) | |
download | perl-libnet-6e20c7178b991896e16f76de3ff218a4dd2358b9.tar.gz |
Net::FTP
- Check that writes to local file succeed
-rw-r--r-- | Net/FTP.pm | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -21,7 +21,7 @@ use Net::Cmd; use Net::Config; # use AutoLoader qw(AUTOLOAD); -$VERSION = "2.52"; # $Id: //depot/libnet/Net/FTP.pm#38 $ +$VERSION = "2.52"; # $Id: //depot/libnet/Net/FTP.pm#39 $ @ISA = qw(Exporter Net::Cmd IO::Socket::INET); # Someday I will "use constant", when I am not bothered to much about @@ -406,26 +406,34 @@ sub get { carp "Cannot binmode Local file $local: $!\n"; $data->abort; + close($loc) unless $localfd; return undef; } $buf = ''; - my $swlen; my($count,$hashh,$hashb,$ref) = (0); ($hashh,$hashb) = @$ref if($ref = ${*$ftp}{'net_ftp_hash'}); - do + while(1) { - $len = $data->read($buf,1024); + last unless $len = $data->read($buf,1024); if($hashh) { $count += $len; print $hashh "#" x (int($count / $hashb)); $count %= $hashb; } + my $written = syswrite($loc,$buf,$len); + unless(defined($written) && $written == $len) + { + carp "Cannot write to Local file $local: $!\n"; + $data->abort; + close($loc) + unless defined $localfd; + return undef; + } } - while($len && defined($swlen = syswrite($loc,$buf,$len)) && $swlen == $len); print $hashh "\n" if $hashh; |