GNURLOPT_FILETIME(3)

πŸ“¦ version 7.72.0, in nixos 26.05, nixpkgs unstable

πŸ’… GNURLOPT_FILETIME(3) β€” the group-chat guide

okay so bestie, this one is from the curl_easy_setopt options family (the gnurl flavor, specifically) and it's lowkey one of the cutest little flags ever. it's giving "can u pls tell me when this file was last touched" energy. πŸŽ€


✨ NAME ✨

CURLOPT_FILETIME β€” get the modification time of the remote resource πŸ•°οΈ


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <gnurl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FILETIME, long gettime);

🌸 DESCRIPTION 🌸

so you pass a long in here, right? if it's 1, libcurl will attempt to get the modification time of the remote document in this operation. attempt is the key word bestie β€” this requires that the remote server actually sends the time, or replies to a time querying command. no cap, the server has to cooperate. πŸ™ˆ

then, after the transfer, you can call curl_easy_getinfo(3) with the CURLINFO_FILETIME(3) argument to extract the received time (if any). the "(if any)" is doing a lot of heavy lifting there, just saying. πŸ’€


πŸ’œ DEFAULT πŸ’œ

0


🌈 PROTOCOLS 🌈

HTTP, FTP, SFTP, FILE


πŸ”₯ EXAMPLE πŸ”₯

curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_URL, url);
  /* Ask for filetime */
  curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
  res = curl_easy_perform(curl);
  if(CURLE_OK == res) {
    res = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime);
    if((CURLE_OK == res) && (filetime >= 0)) {
      time_t file_time = (time_t)filetime;
      printf("filetime %s: %s", filename, ctime(&file_time));
    }
  }
  /* always cleanup */
  curl_easy_cleanup(curl);
}

🧚 AVAILABILITY 🧚

always, babes β€” and for SFTP since 7.49.0 ⭐


πŸ‘‘ RETURN VALUE πŸ‘‘

returns CURLE_OK πŸ’–


🫢 SEE ALSO 🫢


and that's the whole vibe! πŸ“ no drama, no surprises, just a lil time query slay. this page came to you courtesy of libcurl 7.37.0, dated 17 Jun 2014 β€” like, a vintage. iconic behavior honestly. mwah πŸ’…βœ¨

πŸ“¦ where this page comes from