Index: lib/libfetch/ftp.c =================================================================== --- lib/libfetch/ftp.c (revision 7) +++ lib/libfetch/ftp.c (working copy) @@ -780,7 +780,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; @@ -871,7 +875,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; @@ -1105,6 +1113,7 @@ { conn_t *conn; int oflag; + char *cp; /* check if we should use HTTP instead */ if (purl && (strcmp(purl->scheme, SCHEME_HTTP) == 0 || @@ -1130,6 +1139,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