cURL / Mailing Lists / curl-library / Single Mail


Re: The problem of implementing ftp client function: listDirContents()

From: Dan Fandrich <>
Date: Mon, 23 Aug 2010 09:59:26 -0700

On Mon, Aug 23, 2010 at 04:31:00PM +0800, HU Chengzhe wrote:
> Dan,
> Thank you for your qucikly answer.
> But I am still confused about pre- or post-quote command usage.
> As you said "Sending a CWD as a pre- or post-quote command is not recommended as it messes up the ftp state machine",
> so why do that would mess up the dtp state machine? Could you please explain more about this topic?
> Thank you very much.

The state machine keeps track of the current directory of the remote
server, so apps can download several files from the same directory without
an unnecessary CWD command being sent. libcurl doesn't parse quote commands
so it doesn't realize if one has changed the CWD. If the app subsequently
attempts to download a file from the original directory, it won't send a
CWD and the download will fail.

You shouldn't normally worry about sending CWD on your own. Just set the
URL correctly and libcurl will handle all the mechanics for you. There is
even an option (CURLOPT_FTP_FILEMETHOD) to select how libcurl sends the
CWD commands for you.

>>> Dan
List admin:
Received on 2010-08-23