mirror of
https://github.com/curl/curl.git
synced 2026-08-26 21:24:08 +03:00
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:
parent
edd35cab5c
commit
4cd7f85410
7 changed files with 63 additions and 27 deletions
17
lib/file.c
17
lib/file.c
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue