Add two new options for the SFTP/SCP/FILE protocols: CURLOPT_NEW_FILE_PERMS

and CURLOPT_NEW_DIRECTORY_PERMS.  These control the premissions for files
and directories created on the remote server.  CURLOPT_NEW_FILE_PERMS
defaults to 0644 and CURLOPT_NEW_DIRECTORY_PERMS defaults to 0755
This commit is contained in:
James Housley 2007-06-27 20:15:48 +00:00
parent edd35cab5c
commit 4cd7f85410
7 changed files with 63 additions and 27 deletions

View file

@ -217,8 +217,23 @@ static CURLcode file_upload(struct connectdata *conn)
if(data->reqdata.resume_from)
fp = fopen( file->path, "ab" );
else
else {
int fd;
#if defined(WIN32) || defined(MSDOS) || defined(__EMX__)
fd = open(file->path, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY,
conn->data->set.new_file_perms);
#else /* !(WIN32 || MSDOS || __EMX__) */
fd = open(file->path, O_WRONLY|O_CREAT|O_TRUNC,
conn->data->set.new_file_perms);
#endif /* !(WIN32 || MSDOS || __EMX__) */
if (fd < 0) {
failf(data, "Can't open %s for writing", file->path);
return CURLE_WRITE_ERROR;
}
close(fd);
fp = fopen(file->path, "wb");
}
if(!fp) {
failf(data, "Can't open %s for writing", file->path);