cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: How to get FTP Dir file list including the FILE SIZE ?

From: Jeff Pohlmeyer <yetanothergeek_at_gmail.com>
Date: Thu, 21 May 2009 09:31:40 -0500

On May 21, 2009 Cogentree CT wrote:

> I want to get FTP directory file list including the file size.
> I read a thread with similar subject line : ftp-dir
> curl_easy_setopt(curl, CURLOPT_FTPLISTONLY,TRUE);
>
> With the help of that i could get the directory file list.
> But, I want to know the file size also.
> I would also like to know how to get the size of individual files.

If you want the file sizes, then you should not use CURLOPT_FTPLISTONLY,
that tells libcurl to only list the names. Instead, just make sure that
your CURLOPT_URL ends with a trailing slash / and libcurl will return the
directory listing in whatever format the server provides (which usually
includes the sizes). From there, you can either try to parse the output
yourself, or use a ready-made parser like this one:

http://cr.yp.to/ftpparse.html

 - Jeff
Received on 2009-05-21