cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: How to download only new files from FTP server

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 18 Aug 2009 11:11:05 +0200 (CEST)

On Mon, 17 Aug 2009, Ankur Saxena wrote:

> I want to poll an FTP server at regular intervals, and download only newly
> added files. I looked at CURLOPT_FILETIME / curl_easy_setopt() and
> CURLINFO_FILETIME / curl_easy_getinfo() functionality, but I am not sure if
> this is the way to go.
>
> Could someone tell me how to achieve this?

In short: it's a pain. libcurl offers the ability get a file conditionally
based on its date over FTP (with CURLOPT_TIMECONDITION), but you need to
specify exactly that file in the URL then.

If you want to list a directory to find out which files that are new, you're
really left to either to LIST or NLST and then parse the results in your app,
but none of the directory listing outputs are standardized so you'd have to
either make a very clever parser or you handicraft it specificly for the
server(s) you know you'll work with.

-- 
  / daniel.haxx.se
Received on 2009-08-18