CURLOPT_FILETIME.3 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. .\" generated by cd2nroff 0.1 from CURLOPT_FILETIME.md
  2. .TH CURLOPT_FILETIME 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_FILETIME \- get the modification time of the remote resource
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FILETIME, long gettime);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a long. If it is 1, libcurl attempts to get the modification time of the
  12. remote document in this operation. This requires that the remote server sends
  13. the time or replies to a time querying command. The \fIcurl_easy_getinfo(3)\fP
  14. function with the \fICURLINFO_FILETIME(3)\fP argument can be used after a
  15. transfer to extract the received time (if any).
  16. .SH DEFAULT
  17. 0
  18. .SH PROTOCOLS
  19. This functionality affects file, ftp, http, sftp and smb
  20. .SH EXAMPLE
  21. .nf
  22. int main(void)
  23. {
  24. CURL *curl = curl_easy_init();
  25. if(curl) {
  26. CURLcode res;
  27. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/path.html");
  28. /* Ask for filetime */
  29. curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
  30. res = curl_easy_perform(curl);
  31. if(CURLE_OK == res) {
  32. long filetime;
  33. res = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime);
  34. if((CURLE_OK == res) && (filetime >= 0)) {
  35. time_t file_time = (time_t)filetime;
  36. printf("filetime: %s", ctime(&file_time));
  37. }
  38. }
  39. /* always cleanup */
  40. curl_easy_cleanup(curl);
  41. }
  42. }
  43. .fi
  44. .SH AVAILABILITY
  45. Added in curl 7.5
  46. .SH RETURN VALUE
  47. Returns CURLE_OK
  48. .SH SEE ALSO
  49. .BR CURLINFO_FILETIME (3),
  50. .BR curl_easy_getinfo (3)