cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl-library Digest, Vol 39, Issue 13

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Thu, 6 Nov 2008 15:30:30 -0800

On Fri, Nov 07, 2008 at 09:27:21AM +1100, Sundar, Karthik wrote:
> I tried ..but couldn't get the size..It returns file size as 0.
>
> Can you please tell me watz wrong in the code below?

> #define REMOTE_URL "ftp://enterprise\\user:pwd@10.228.13.21/"

Your code is requesting the size of a directory. Provide a URL to a file
instead.

> curl_easy_setopt(curl,CURLOPT_URL, REMOTE_URL);
> sprintf(buf_1, "CWD %s" ,DEST_FILE_IN );
> headerlist = curl_slist_append(headerlist, buf_1);
> curl_easy_setopt(curl, CURLOPT_QUOTE, headerlist);

Doing CWD as a quote command is going to confuse curl, since that invalides
its own idea of CWD. Just put the directory in the URL instead.

> /*Size of the specific file */
> sprintf(buf_1, "SIZE ftplog");
>
> //
> curl_easy_getinfo(curl,CURLINFO_RESPONSE_CODE,&response);
> headerlist = curl_slist_append(headerlist, buf_1);
> curl_easy_setopt(curl, CURLOPT_QUOTE, headerlist);

curl already does a SIZE--you don't need to do it with a quote command, too.

> curl_easy_setopt(curl,CURLOPT_NOBODY,1);

CURLOPT_NOBODY takes a long argument, not an int.

> res2 = curl_easy_perform(curl);
>
> size =
> curl_easy_getinfo(curl,CURLINFO_CONTENT_LENGTH_DOWNLOAD,&filesize);

filesize can't be an int; it must be a double.

>>> Dan

-- 
http://www.MoveAnnouncer.com              The web change of address service
          Let webmasters know that your web site has moved
Received on 2008-11-07