CURLOPT_NEW_DIRECTORY_PERMS(3)

πŸ’… CURLOPT_NEW_DIRECTORY_PERMS(3) πŸ’…

okay bestie, welcome to the Library Functions Manual β€” this one's a libcurl page, and it's genuinely so useful if you're the kind of girl who makes folders on a remote server. which, apparently, we are now. πŸŽ€


✨ NAME ✨

CURLOPT_NEW_DIRECTORY_PERMS β€” literally the permissions for directories that get created remotely πŸ¦‹


✨ SYNOPSIS ✨

#include <curl/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 set on newly created directories on the remote server. 🫢

the default value is 0755, but ngl any valid value can be used. no gatekeeping here.

the only protocols that can use this are sftp://, scp://, and file://. that's the whole guest list, periodt. πŸ‘‘


✨ DEFAULT ✨

0755 β€” the blueprint, the standard, the main character default πŸ’…


✨ PROTOCOLS ✨

this functionality affects file, scp and sftp 🌸


✨ EXAMPLE ✨

the way this little program just... does it. iconic. ✨

int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    CURLcode result;
    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);
    result = curl_easy_perform(curl);
  }
}

✨ AVAILABILITY ✨

added in curl 7.16.4 β€” yes she's been around, she's a legacy icon 🧚


✨ RETURN VALUE ✨

curl_easy_setopt(3) returns a CURLcode indicating success or error. πŸ“‹

CURLE_OK (0) means everything was OK β€” slay, no notes. non-zero means an error occurred, so go check libcurl-errors(3) and figure out what went wrong. 😭


✨ SEE ALSO ✨


πŸ’– quick vibe check: this option is about directories, not files β€” if you're after file perms, that's CURLOPT_NEW_FILE_PERMS(3) right up there in SEE ALSO. iykyk. πŸ¦‹

okay that's the whole page, bestie β€” stay hydrated, set your perms, and remember: remote directories deserve cute permissions too. πŸ“

this has been libcurl, dated 2026-10-12 β€” mwah, catch you in the next manpage πŸ’œπŸŒˆ

πŸ“¦ where this page comes from