|
|
@ -56,6 +56,7 @@ download(const string& address)
|
|
|
|
if(curl)
|
|
|
|
if(curl)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CURLcode res;
|
|
|
|
CURLcode res;
|
|
|
|
|
|
|
|
double file_size;
|
|
|
|
curl_easy_setopt(curl, CURLOPT_URL, address.c_str());
|
|
|
|
curl_easy_setopt(curl, CURLOPT_URL, address.c_str());
|
|
|
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
|
|
|
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
|
|
|
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
|
|
|
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
|
|
|
@ -65,6 +66,11 @@ download(const string& address)
|
|
|
|
fprintf(stderr, "curl_easy_perform() failed: %s\n",curl_easy_strerror(res));
|
|
|
|
fprintf(stderr, "curl_easy_perform() failed: %s\n",curl_easy_strerror(res));
|
|
|
|
exit(1);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &file_size);
|
|
|
|
|
|
|
|
cerr<<"File size: "<<file_size<<" bytes";
|
|
|
|
|
|
|
|
}
|
|
|
|
curl_easy_cleanup(curl);
|
|
|
|
curl_easy_cleanup(curl);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|