[svn] Add support for download of hidden files from FTP.

This commit is contained in:
mtortonesi 2006-03-09 05:50:03 -08:00
parent c3cd00a5a1
commit d34270c536
2 changed files with 43 additions and 26 deletions

View 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> 2006-03-06 Hrvoje Niksic <hniksic@xemacs.org>
* hash.c (TOLOWER): Fix definition when STANDALONE. * hash.c (TOLOWER): Fix definition when STANDALONE.

View File

@ -962,33 +962,45 @@ ftp_list (int csock, const char *file)
char *request, *respline; char *request, *respline;
int nwritten; int nwritten;
uerr_t err; uerr_t err;
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" };
/* Send LIST request. */ do {
request = ftp_request ("LIST", file); /* Send request. */
nwritten = fd_write (csock, request, strlen (request), -1); request = ftp_request (list_commands[i], file);
if (nwritten < 0) nwritten = fd_write (csock, request, strlen (request), -1);
{ if (nwritten < 0)
xfree (request); {
return WRITEFAILED; xfree (request);
} return WRITEFAILED;
xfree (request); }
/* Get appropriate respone. */ xfree (request);
err = ftp_response (csock, &respline); /* Get appropriate response. */
if (err != FTPOK) err = ftp_response (csock, &respline);
return err; if (err == FTPOK)
if (*respline == '5') {
{ if (*respline == '5')
xfree (respline); {
return FTPNSFOD; err = FTPNSFOD;
} }
if (*respline != '1') else if (*respline == '1')
{ {
xfree (respline); err = FTPOK;
return FTPRERR; ok = true;
} }
xfree (respline); else
/* All OK. */ {
return FTPOK; err = FTPRERR;
}
xfree (respline);
}
++i;
} while (i < countof (list_commands) && !ok);
return err;
} }
/* Sends the SYST command to the server. */ /* Sends the SYST command to the server. */