diff -c -r1.1 ftp.c *** ftp.c 2000/09/08 09:48:25 1.1 --- ftp.c 2000/09/09 07:17:17 *************** *** 451,457 **** /* make the server initiate the transfer */ if (verbose) _fetch_info("initiating transfer"); ! e = _ftp_cmd(cd, "%s %s", oper, _ftp_filename(file)); if (e != FTP_OPEN_DATA_CONNECTION) goto ouch; --- 451,460 ---- /* make the server initiate the transfer */ if (verbose) _fetch_info("initiating transfer"); ! if (*_ftp_filename(file) != '\0') ! e = _ftp_cmd(cd, "%s %s", oper, _ftp_filename(file)); ! else ! e = _ftp_cmd(cd, "%s", oper); if (e != FTP_OPEN_DATA_CONNECTION) goto ouch; *************** *** 541,547 **** /* make the server initiate the transfer */ if (verbose) _fetch_info("initiating transfer"); ! e = _ftp_cmd(cd, "%s %s", oper, _ftp_filename(file)); if (e != FTP_OPEN_DATA_CONNECTION) goto ouch; --- 544,553 ---- /* make the server initiate the transfer */ if (verbose) _fetch_info("initiating transfer"); ! if (*_ftp_filename(file) != '\0') ! e = _ftp_cmd(cd, "%s %s", oper, _ftp_filename(file)); ! else ! e = _ftp_cmd(cd, "%s", oper); if (e != FTP_OPEN_DATA_CONNECTION) goto ouch; *************** *** 782,787 **** --- 788,794 ---- fetchXGetFTP(struct url *url, struct url_stat *us, char *flags) { int cd; + register char *cp; if (_ftp_use_http_proxy()) return fetchXGetHTTP(url, us, flags); *************** *** 793,806 **** /* change directory */ if (_ftp_cwd(cd, url->doc) == -1) return NULL; ! /* stat file */ ! if (us && _ftp_stat(cd, url->doc, us) == -1 ! && fetchLastErrCode != FETCH_UNAVAIL) ! return NULL; ! ! /* initiate the transfer */ ! return _ftp_transfer(cd, "RETR", url->doc, "r", url->offset, flags); } /* --- 800,824 ---- /* change directory */ if (_ftp_cwd(cd, url->doc) == -1) return NULL; + + cp = url->doc + strlen(url->doc) - 1; + if (cp >= url->doc && *cp == '/') { + if (us) { + us->size = -1; + us->atime = us->mtime = 0; + } + /* list the directory */ + return _ftp_transfer(cd, "LIST", url->doc, "r", url->offset, flags); + } else { + /* stat file */ + if (us && _ftp_stat(cd, url->doc, us) == -1 + && fetchLastErrCode != FETCH_UNAVAIL + && fetchLastErrCode != FETCH_PROTO) + return NULL; ! /* initiate the transfer */ ! return _ftp_transfer(cd, "RETR", url->doc, "r", url->offset, flags); ! } } /*