cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: How to preserve remote file datestamp

From: Tony Metters <tony_metters_at_hotmail.com>
Date: Tue, 21 Feb 2006 15:09:22 +0000

many thanks Daniel,

I have enclosed a small segment of how I did it. somebody may be interested

// ---------------------------------------------------------
long filetime;
curl_easy_setopt(_curl, CURLOPT_FILETIME, 1);
. ...do the curl stuff here.
.
.
curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime);

struct utimbuf utb; utb.modtime = utb.actime = filetime;
if( utime( filename, &utb ) == -1 ) {
   error something wrong maybe permissions!
}

// -----------------------------------------------
regards
tonym

<snip>

>>> curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime);
>>
>>I understand that this will get me the datestamp for the file on the
>>server, but what I am unsure of is how to make my writecallback (which
>>uses 'fwrite() to dump the file to the client disk) change the timestamp
>>of the file to that of 'filetime'.
>
>Well, that is not libcurl's responsibility and it is more a problem you
>need to work out with your operating system. On most systems you can use
>utime() to achieve what you want.
Received on 2006-02-21