title: libcurl download file size exceed buffer size
body: <p>I have a question regarding this code at <a href="https://curl.haxx.se/libcurl/c/ftpget.html" rel="nofollow noreferrer">https://curl.haxx.se/libcurl/c/ftpget.html</a></p>
  
  <p>In the call back function </p>
  
  <pre><code>static size_t my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream)
  {
    struct FtpFile *out=(struct FtpFile *)stream;
    if(out &amp;&amp; !out-&gt;stream) {
      /* open file for writing */ 
      out-&gt;stream=fopen(out-&gt;filename, "wb");
      if(!out-&gt;stream)
        return -1; /* failure, can't open file to write */ 
    }
    return fwrite(buffer, size, nmemb, out-&gt;stream);
  }
  </code></pre>
  
  <p>What if the file size exceed the buffer size? I think the function will not be called iteratively since it overwrites the file everytime. Is there a work-around of it? Thanks!</p>