cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: ftp-dir

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 26 Oct 2005 20:22:01 +0200 (CEST)

On Wed, 26 Oct 2005, iler_ml_at_fastmail.fm wrote:

> I want to do ftp-dir using easy interface.

You mean you want to list all entries within a directory?

> I searched the libcurl docs for how to do ftp-dir.

You add a slash to the end of the URL. Like ftp://host/dir/

> I found CURLOPT_FTPLISTONLY and CURLOPT_CUSTOMREQUEST options, but I am
> still in the dark about the call sequence needed for the ftp-dir.

Set the options, call curl_easy_perform().

> Can anyone post a pseudocode/outline of easy-interface call sequence for
> ftp-dir ?

   handle = curl_easy_init();

   curl_easy_setopt(handle, CURLOPT_FTPLISTONLY, TRUE);
   curl_easy_setopt(handle, CURLOPT_URL, "ftp://host/dir/");
   curl_easy_perform(handle);

   curl_easy_cleanup(handle);

> P.S. The only guess I can make is that to perform ftp-dir, is the wild guess
> I need to set CURLOPT_CUSTOMREQUEST to "DIR". Is this correct ?

"DIR" is not a FTP command. See RFC959 for details.

And you only need to use CURLOPT_CUSTOMREQUEST if you don't want the command
it sends by default when you request a directory list.

And CURLOPT_FTPLISTONLY isn't strictly necessary either, only if you want to
use NLST instead of LIST...

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2005-10-26