cURL / Mailing Lists / curl-library / Single Mail

curl-library

Example C++ code to "read/pull" an FTP file in small chunks

From: Rich Chomiczewski <rchomiczewski_at_gmail.com>
Date: Mon, 22 Nov 2010 20:41:45 -0500

I'm looking for some example C++ code to read an FTP file just like any
other file i.e. read/pull the file in variable-length chunks. Specifically,
I need to implement an interface like this (without having to first download
the entire file ahead of time):

class IInputStream
{
public:
    virtual unsigned int Read(char *buffer, unsigned int bufferSize) =0;
};

Example usage:

    IInputStream* s = factory.CreateProtocolStream( url ); // e.g. file: or
ftp:

    while (bytesRead = s->Read(buffer, 1024) > 0)
    {
        Parser::Result result;
        if (!Parser::Parse(buffer, bytesRead, &result))
            break;
        /* ... */
    }

Thanks!
Rich

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-11-23