]> sjero.net Git - wget/commitdiff
[svn] Add support for download of hidden files from FTP.
authormtortonesi <devnull@localhost>
Thu, 9 Mar 2006 13:50:03 +0000 (05:50 -0800)
committermtortonesi <devnull@localhost>
Thu, 9 Mar 2006 13:50:03 +0000 (05:50 -0800)
src/ChangeLog
src/ftp-basic.c

index 35df03755ba8c4644856f439ca89aaa79561572e..04fea0d5d645dc2630cb42ec5215947e6be29665 100644 (file)
@@ -1,3 +1,8 @@
+2006-03-09  Mauro Tortonesi  <mauro@ferrara.linux.it>
+
+       * ftp.c (ftp_list): Try `LIST -a' command first and revert to `LIST'
+       in case of failure.
+
 2006-03-06  Hrvoje Niksic  <hniksic@xemacs.org>
 
        * hash.c (TOLOWER): Fix definition when STANDALONE.
index dd7d7b7addec75f8fe2da76b9a5b2caa9a661ea9..4127b686dc1af884875483f7537eb78c52ea91da 100644 (file)
@@ -962,33 +962,45 @@ ftp_list (int csock, const char *file)
   char *request, *respline;
   int nwritten;
   uerr_t err;
-
-  /* Send LIST request.  */
-  request = ftp_request ("LIST", file);
-  nwritten = fd_write (csock, request, strlen (request), -1);
-  if (nwritten < 0)
-    {
-      xfree (request);
-      return WRITEFAILED;
-    }
-  xfree (request);
-  /* Get appropriate respone.  */
-  err = ftp_response (csock, &respline);
-  if (err != FTPOK)
-    return err;
-  if (*respline == '5')
-    {
-      xfree (respline);
-      return FTPNSFOD;
-    }
-  if (*respline != '1')
-    {
-      xfree (respline);
-      return FTPRERR;
-    }
-  xfree (respline);
-  /* All OK.  */
-  return FTPOK;
+  bool ok = false;
+  int i = 0;
+  /* Try `LIST -a' first and revert to `LIST' in case of failure.  */
+  const char *list_commands[] = { "LIST -a", 
+                                  "LIST" };
+
+  do {
+    /* Send request.  */
+    request = ftp_request (list_commands[i], file);
+    nwritten = fd_write (csock, request, strlen (request), -1);
+    if (nwritten < 0)
+      {
+        xfree (request);
+        return WRITEFAILED;
+      }
+    xfree (request);
+    /* Get appropriate response.  */
+    err = ftp_response (csock, &respline);
+    if (err == FTPOK)
+      {
+        if (*respline == '5')
+          {
+            err = FTPNSFOD;
+          }
+       else if (*respline == '1')
+          {
+            err = FTPOK;
+            ok = true;
+          }
+        else 
+          {
+           err = FTPRERR;
+          }
+        xfree (respline);
+      }
+    ++i;
+  } while (i < countof (list_commands) && !ok);
+  
+  return err;
 }
 
 /* Sends the SYST command to the server. */