【发布时间】:2012-01-17 10:28:38
【问题描述】:
我有一个简单的例子:
include <curl/curl.h>
char tmp[] = "/var/tmp/tmp";
char fullpath[] = "/var/tmp/test";
FILE* fp;
CURL* curl;
char bufferError[CURL_ERROR_SIZE];
CURLcode result;
int main() {
curl = curl_easy_init();
fp = fopen(tmp, "wb");
char url[] = "http://10.100.1.5/promorolik/Skoro_Shrek_4_obrez.mp4";
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, bufferError);
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_HEADER, 0);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
result = curl_easy_perform(curl);
curl_easy_cleanup(curl);
fclose(fp);
rename(tmp, fullpath);
return 0;
}
如何从服务器中的文件中设置下载文件“测试”属性? (从最后修改的字段创建文件的时间)?
【问题讨论】: