GNURLOPT_N...TORY_PERMS(3)

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

πŸ’… GNURLOPT_N...TORY_PERMS(3) β€” your girl's guide to CURLOPT_NEW_DIRECTORY_PERMS

okay so this page lives in the curl_easy_setopt options section of the manual, and it's literally all about what permissions your freshly-made remote directories get. buckle up bestie, it's a short one but it's important πŸŽ€


✨ NAME ✨

CURLOPT_NEW_DIRECTORY_PERMS β€” the permissions for directories you create on the remote side πŸ’–


✨ SYNOPSIS ✨

#include <gnurl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_NEW_DIRECTORY_PERMS,
                          long mode);

🌸 DESCRIPTION 🌸

So you pass a long as the parameter, and that value is the permissions that get assigned to directories that are newly created on the remote server. like, brand new dirs, fresh out the box πŸ¦‹

The default value is 0755, but honestly any valid value can be used β€” you do you, boo.

The only protocols that can use this are sftp://, scp://, and file://. that's the whole guest list, no plus-ones πŸ’…


πŸŽ€ DEFAULT πŸŽ€

0755


🌈 PROTOCOLS 🌈

SFTP, SCP and FILE


πŸ”₯ EXAMPLE πŸ”₯

okay so here's the vibe in code form:

CURL *curl = curl_easy_init();
if(curl) {
  CURLcode ret;
  curl_easy_setopt(curl, CURLOPT_URL, "sftp://upload.example.com/newdir/file.zip");
  curl_easy_setopt(curl, CURLOPT_FTP_CREATE_MISSING_DIRS, 1L);
  curl_easy_setopt(curl, CURLOPT_NEW_DIRECTORY_PERMS, 0644L);
  ret = curl_easy_perform(curl);
}

⭐ AVAILABILITY ⭐

Added in 7.16.4 β€” she's been iconic for a minute πŸ‘‘


πŸ’œ RETURN VALUE πŸ’œ

  • Returns CURLE_OK if the option is supported 🫢
  • Returns CURLE_UNKNOWN_OPTION if it's not 😭

πŸ¦‹ SEE ALSO πŸ¦‹


ngl bestie, don't sleep on the difference between directory perms and file perms β€” they're two separate settings and they both matter, iykyk πŸ’€

mwah πŸ’‹ this page is from libcurl 7.37.0, dated 19 Jun 2014 β€” vintage but still slaying, periodt βœ¨πŸŽ€

πŸ“¦ where this page comes from