about summary refs log tree commit
diff options
context:
space:
mode:
authorGraham Barr <gbarr@pobox.com>2004-03-22 14:36:51 +0000
committerGraham Barr <gbarr@pobox.com>2009-02-24 08:51:37 -0600
commit0b6944c6957dc22d803493448f3fc7cc0ce78ae0 (patch)
tree2b502fcd508809638b586abae1e976e5b648d6a7
parentb01919ce94068f5018719b1785c97162c35e2fcf (diff)
downloadperl-libnet-0b6944c6957dc22d803493448f3fc7cc0ce78ae0.tar.gz
Don'ttry to delete . or .. when doing a recursive delete
-rw-r--r--Net/FTP.pm6
1 files changed, 3 insertions, 3 deletions
diff --git a/Net/FTP.pm b/Net/FTP.pm
index 0e31cf3..7aad1a6 100644
--- a/Net/FTP.pm
+++ b/Net/FTP.pm
@@ -593,14 +593,14 @@ sub rmdir
 
     # Try to delete the contents
     # Get a list of all the files in the directory
-    my $filelist = $ftp->ls($dir);
+    my @filelist = grep { !/^\.{1,2}$/ } $ftp->ls($dir);
 
     return undef
-        unless $filelist && @$filelist; # failed, it is probably not a directory
+        unless @filelist; # failed, it is probably not a directory
 
     # Go thru and delete each file or the directory
     my $file;
-    foreach $file (map { m,/, ? $_ : "$dir/$_" } @$filelist)
+    foreach $file (map { m,/, ? $_ : "$dir/$_" } @filelist)
     {
         next  # successfully deleted the file
             if $ftp->delete($file);