1CURLOPT_FILETIME(3) curl_easy_setopt options CURLOPT_FILETIME(3)
2
3
4
6 CURLOPT_FILETIME - get the modification time of the remote resource
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FILETIME, long gettime);
12
14 Pass a long. If it is 1, libcurl will attempt to get the modification
15 time of the remote document in this operation. This requires that the
16 remote server sends the time or replies to a time querying command. The
17 curl_easy_getinfo(3) function with the CURLINFO_FILETIME(3) argument
18 can be used after a transfer to extract the received time (if any).
19
21 0
22
24 HTTP(S), FTP(S), SFTP, FILE, SMB(S)
25
27 curl = curl_easy_init();
28 if(curl) {
29 curl_easy_setopt(curl, CURLOPT_URL, url);
30 /* Ask for filetime */
31 curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
32 res = curl_easy_perform(curl);
33 if(CURLE_OK == res) {
34 res = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime);
35 if((CURLE_OK == res) && (filetime >= 0)) {
36 time_t file_time = (time_t)filetime;
37 printf("filetime %s: %s", filename, ctime(&file_time));
38 }
39 }
40 /* always cleanup */
41 curl_easy_cleanup(curl);
42 }
43
45 Always, for SFTP since 7.49.0
46
48 Returns CURLE_OK
49
51 curl_easy_getinfo(3),
52
53
54
55libcurl 8.0.1 January 02, 2023 CURLOPT_FILETIME(3)