b0da4faa275f10ba22657bf9321bfd2b39e5189f galt Fri Jan 14 00:06:28 2011 -0800 add FTP LIST option for directories identified by trailing slash in URL diff --git src/lib/net.c src/lib/net.c index eb7e3df..91989c7 100644 --- src/lib/net.c +++ src/lib/net.c @@ -721,31 +721,32 @@ close(sd); return -1; } /* 227 Entering Passive Mode (128,231,210,81,222,250) */ if (npu.byteRangeStart != -1) { safef(cmd,sizeof(cmd),"REST %lld\r\n", (long long) npu.byteRangeStart); if (!sendFtpCommand(sd, cmd, NULL)) { close(sd); return -1; } } -safef(cmd,sizeof(cmd),"RETR %s\r\n", npu.file); +/* RETR for files, LIST for directories ending in / */ +safef(cmd,sizeof(cmd),"%s %s\r\n",((npu.file[strlen(npu.file)-1]) == '/') ? "LIST" : "RETR", npu.file); sendFtpCommandOnly(sd, cmd); int sdata = netConnect(npu.host, parsePasvPort(rs->string)); dyStringFree(&rs); if (sdata < 0) { close(sd); return -1; } int secondsWaited = 0; while (TRUE) { if (secondsWaited >= 10) {