From 1ebf3b0396b0402edda1d55798f503fb2ae9a04d Mon Sep 17 00:00:00 2001 From: Roman Kamyk Date: Sat, 2 Nov 2013 07:46:57 -0700 Subject: [PATCH] Fix the code that writes curl result following advise on http://stackoverflow.com/questions/8020640/libcurl-output-to-variable-instead-of-textfile --- src/downloader.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/downloader.cpp b/src/downloader.cpp index 0fa9b3c..14c30eb 100644 --- a/src/downloader.cpp +++ b/src/downloader.cpp @@ -1152,7 +1152,10 @@ size_t Downloader::writeMemoryCallback(char *ptr, size_t size, size_t nmemb, voi size_t Downloader::writeData(void *ptr, size_t size, size_t nmemb, FILE *stream) { - return fwrite(ptr, size, nmemb, stream); + std::ostream *ostream = (std::ostream*) stream; + size_t count = size * nmemb; + ostream->write((const char*)ptr, count); + return count; } size_t Downloader::readData(void *ptr, size_t size, size_t nmemb, FILE *stream)