cURL / Mailing Lists / curl-library / Single Mail

curl-library

Error in ftpget.c example?

From: Juan Manuel Lopez Baio <jmbaio_at_gmail.com>
Date: Tue, 19 Sep 2006 11:30:22 -0300

Hello.
In the ftpget.c example that comes with the distribution, the function
below is provided to write data to disk:

int my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream)
{
  struct FtpFile *out=(struct FtpFile *)stream;
  if(out && !out->stream) {
    /* open file for writing */
    out->stream=fopen(out->filename, "wb");
    if(!out->stream)
      return -1; /* failure, can't open file to write */
  }
  return fwrite(buffer, size, nmemb, out->stream);
}

Shouldn't this function close the file stream, since it opens it, or
does curl take care of that?

Thanks!

Juan
Received on 2006-09-19