about summary refs log tree commit
diff options
context:
space:
mode:
authorGraham Barr <gbarr@pobox.com>1997-11-01 01:16:55 +0000
committerGraham Barr <gbarr@pobox.com>1997-11-01 01:16:55 +0000
commit46348d94b3c597a31083af726c72a47582f76d55 (patch)
tree569f00c9f82b4105f8698b46c2d163d17edc2b63
parent3511fc61f940ffe2ffae500c1f4f8f3680689b77 (diff)
downloadperl-libnet-46348d94b3c597a31083af726c72a47582f76d55.tar.gz
Net::FTP
- Added new supported() method

-rw-r--r--Net/FTP.pm23
1 files changed, 21 insertions, 2 deletions
diff --git a/Net/FTP.pm b/Net/FTP.pm
index fff6315..7dac11d 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.24";
+$VERSION = "2.25"; # $Id$
 @ISA     = qw(Exporter Net::Cmd IO::Socket::INET);
 
 1;
@@ -564,6 +564,21 @@ sub unique_name
  ${*$ftp}{'net_ftp_unique'} || undef;
 }
 
+sub supported {
+    @_ == 2 or croak 'usage: $ftp->supported( CMD )';
+    my $ftp = shift;
+    my $cmd = uc shift;
+    my $hash = ${*$ftp}{'net_ftp_supported'} ||= {};
+
+    return $hash->{$cmd}
+        if exists $hash->{$cmd};
+
+    my $ok = $ftp->_HELP($cmd) &&
+        $ftp->message !~ /unimplemented/i;
+
+    $hash->{$cmd} = $ok;
+}
+
 ##
 ## Depreciated methods
 ##
@@ -850,6 +865,7 @@ sub _ACCT { shift->command("ACCT",@_)->response() == CMD_OK }
 sub _RESP { shift->command("RESP",@_)->response() == CMD_OK }
 sub _MDTM { shift->command("MDTM",@_)->response() == CMD_OK }
 sub _SIZE { shift->command("SIZE",@_)->response() == CMD_OK }
+sub _HELP { shift->command("HELP",@_)->response() == CMD_OK }
 sub _APPE { shift->command("APPE",@_)->response() == CMD_INFO }
 sub _LIST { shift->command("LIST",@_)->response() == CMD_INFO }
 sub _NLST { shift->command("NLST",@_)->response() == CMD_INFO }
@@ -864,7 +880,6 @@ sub _AUTH { shift->command("AUTH",@_)->response() }
 
 sub _ALLO { shift->unsupported(@_) }
 sub _SMNT { shift->unsupported(@_) }
-sub _HELP { shift->unsupported(@_) }
 sub _MODE { shift->unsupported(@_) }
 sub _SITE { shift->unsupported(@_) }
 sub _SYST { shift->unsupported(@_) }
@@ -1095,6 +1110,10 @@ Returns the I<modification time> of the given file
 
 Returns the size in bytes for the given file.
 
+=item supported ( CMD )
+
+Returns TRUE if the remote server supports the given command.
+
 =back
 
 The following methods can return different results depending on