about summary refs log tree commit
diff options
context:
space:
mode:
authorGraham Barr <gbarr@pobox.com>1999-05-05 06:56:14 +0000
committerGraham Barr <gbarr@pobox.com>1999-05-05 06:56:14 +0000
commit14fa89ca573adc2de041fbd67e96b71d62d91fda (patch)
treef3b5f0ea2fccd3dd8250592c05f97feb54119a4f
parentaa316052e1d5af463c1d3b08e7c4b20a503fa286 (diff)
downloadperl-libnet-14fa89ca573adc2de041fbd67e96b71d62d91fda.tar.gz
Net::FTP
- Fix bug ->size when SIZE and STAT are not implemented

-rw-r--r--Net/FTP.pm47
1 files changed, 23 insertions, 24 deletions
diff --git a/Net/FTP.pm b/Net/FTP.pm
index 35b96b6..376de49 100644
--- a/Net/FTP.pm
+++ b/Net/FTP.pm
@@ -21,7 +21,7 @@ use Net::Cmd;
 use Net::Config;
 # use AutoLoader qw(AUTOLOAD);
 
-$VERSION = "2.52"; # $Id: //depot/libnet/Net/FTP.pm#37 $
+$VERSION = "2.52"; # $Id: //depot/libnet/Net/FTP.pm#38 $
 @ISA     = qw(Exporter Net::Cmd IO::Socket::INET);
 
 # Someday I will "use constant", when I am not bothered to much about
@@ -191,32 +191,31 @@ sub mdtm
     : undef;
 }
 
-sub size
-{
- my $ftp  = shift;
- my $file = shift;
- my $io;
- if($ftp->supported("SIZE")) {
-        return $ftp->_SIZE($file)
-            ? ($ftp->message =~ /(\d+)/)[0]
-            : undef;
+sub size {
+  my $ftp  = shift;
+  my $file = shift;
+  my $io;
+  if($ftp->supported("SIZE")) {
+    return $ftp->_SIZE($file)
+        ? ($ftp->message =~ /(\d+)/)[0]
+        : undef;
  }
  elsif($ftp->supported("STAT")) {
-        my @msg;
-        return undef
-            unless $ftp->_STAT($file) && (@msg = $ftp->message) == 3;
-        my $line;
-        foreach $line (@msg) {
-            return (split(/\s+/,$line))[4]
-                if $line =~ /^[-rw]{10}/
-        }
+   my @msg;
+   return undef
+       unless $ftp->_STAT($file) && (@msg = $ftp->message) == 3;
+   my $line;
+   foreach $line (@msg) {
+     return (split(/\s+/,$line))[4]
+         if $line =~ /^[-rw]{10}/
+   }
  }
- elsif($io = $ftp->list($file)) {
-        my $line;
-        $io->read($line,1024);
-        $io->close;
-        return (split(/\s+/,$1))[4]
-            if $line =~ /^([-rw]{10}.*)\n/s;
+ else {
+   my @files = $ftp->dir($file);
+   if(@files) {
+     return (split(/\s+/,$1))[4]
+         if $files[0] =~ /^([-rw]{10}.*)$/;
+   }
  }
  undef;
 }