H4x0

Download File [curl]

May 8th, 2013
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.72 KB | None | 0 0
  1. #define CURL_STATICLIB
  2. #include "stdafx.h"
  3. #include <curl.h>
  4. #include <types.h>
  5. #include <easy.h>
  6. #include <string>
  7.  
  8. bool downloadFile(char *url, const char *out) {
  9.     CURL *curl;
  10.     FILE *fp;
  11.     CURLcode res;
  12.     curl = curl_easy_init();
  13.  
  14.     if (curl) {
  15.         fp = fopen(out, "wb");
  16.         curl_easy_setopt(curl, CURLOPT_URL, url);
  17.         curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
  18.         curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
  19.         curl_easy_setopt(curl, CURLOPT_NOPROGRESS, FALSE);
  20.         curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_func);
  21.         res = curl_easy_perform(curl);
  22.         curl_easy_cleanup(curl);
  23.         fclose(fp);
  24.         return true;
  25.     }
  26.  
  27.     return false;
  28. }
Add Comment
Please, Sign In to add comment