Index: lib/libfetch/ftp.c =================================================================== --- lib/libfetch/ftp.c (revision 11) +++ lib/libfetch/ftp.c (working copy) @@ -776,7 +776,11 @@ /* make the server initiate the transfer */ if (verbose) fetch_info("initiating transfer"); - e = ftp_cmd(conn, "%s %.*s", oper, filenamelen, filename); + if (*filename != '\0') + e = ftp_cmd(conn, "%s %.*s", oper, filenamelen, + filename); + else + e = ftp_cmd(conn, "%s", oper); if (e != FTP_CONNECTION_ALREADY_OPEN && e != FTP_OPEN_DATA_CONNECTION) goto ouch; @@ -867,7 +871,11 @@ /* make the server initiate the transfer */ if (verbose) fetch_info("initiating transfer"); - e = ftp_cmd(conn, "%s %.*s", oper, filenamelen, filename); + if (*filename != '\0') + e = ftp_cmd(conn, "%s %.*s", oper, filenamelen, + filename); + else + e = ftp_cmd(conn, "%s", oper); if (e != FTP_CONNECTION_ALREADY_OPEN && e != FTP_OPEN_DATA_CONNECTION) goto ouch; @@ -1099,6 +1107,7 @@ { conn_t *conn; int oflag; + char *cp; /* check if we should use HTTP instead */ if (purl && strcasecmp(purl->scheme, SCHEME_HTTP) == 0) { @@ -1123,6 +1132,18 @@ if (ftp_cwd(conn, url->doc) == -1) goto errsock; + cp = url->doc + strlen(url->doc) - 1; + if (cp >= url->doc && *cp == '/') { + /* list directory */ + if (us) { + us->size = -1; + us->atime = us->mtime = 0; + } + /* list the directory */ + return ftp_transfer(conn, "LIST", url->doc, O_RDONLY, + url->offset, flags); + } + /* stat file */ if (us && ftp_stat(conn, url->doc, us) == -1 && fetchLastErrCode != FETCH_PROTO