cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: directory transfers with ftp

From: Daniel Stenberg <daniel-curl_at_haxx.se>
Date: Wed, 31 Mar 2004 08:43:13 +0200 (CEST)

On Tue, 30 Mar 2004, Chris Silverberg wrote:

> I'm working on a project to use the C interface of libcurl to perform ftp
> downloads and uploads. Single file downloads are of course easy to
> accomplish... and I've done that complete with a GUI progress window, etc.
> All very straight-forward and fast. But now I need to support downloading
> and uploading directories, perhaps with subdirectories.

> From my reading of the API's, it doesn't look like libcurl has any special
> support for this, so I'll essentially be layering on top of libcurl to do
> this.

It sounds as if you have understood the API properly. libcurl doesn't offer
many dir-specific options so you will need to parse the dir listing on your
own. This is tricky business. Beware! ;-)

> For example, to download a directory, i'll download the directory listing,
> then I'll have to parse it (probably using http://cr.yp.to/ftpparse.html),

If I'm not mistaking, that code uses a weird license. Just take notice before
you venture further down that road.

You can also check into the wget source code as they are doing quite a bit of
ftp parsing in there and I'm assuming they do it at least mostly in a
successful manner!

> I'll probably have to do a pre-scan to collect the total bytes if I want an
> accurate progress window. Does that sound about right?

It does!

> Does anyone have any tips/suggestions based on previous experience?

Just that parsing FTP dir listings is one of those things in life that will
haunt you and make you wake up in the middle of the night screaming for weeks
ahead. ;-)

But then the reward is so much bigger when you make it work.

-- 
     Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se
      Dedicated custom curl help for hire: http://haxx.se/curl.html
Received on 2004-03-31