| 1 |
.\" ************************************************************************** |
| 2 |
.\" * _ _ ____ _ |
| 3 |
.\" * Project ___| | | | _ \| | |
| 4 |
.\" * / __| | | | |_) | | |
| 5 |
.\" * | (__| |_| | _ <| |___ |
| 6 |
.\" * \___|\___/|_| \_\_____| |
| 7 |
.\" * |
| 8 |
.\" * Copyright (C) 1998 - 2014, 2017, Daniel Stenberg, <[email protected]>, et al. |
| 9 |
.\" * |
| 10 |
.\" * This software is licensed as described in the file COPYING, which |
| 11 |
.\" * you should have received as part of this distribution. The terms |
| 12 |
.\" * are also available at https://curl.haxx.se/docs/copyright.html. |
| 13 |
.\" * |
| 14 |
.\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell |
| 15 |
.\" * copies of the Software, and permit persons to whom the Software is |
| 16 |
.\" * furnished to do so, under the terms of the COPYING file. |
| 17 |
.\" * |
| 18 |
.\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 19 |
.\" * KIND, either express or implied. |
| 20 |
.\" * |
| 21 |
.\" ************************************************************************** |
| 22 |
.\" |
| 23 |
.TH CURLOPT_FTP_CREATE_MISSING_DIRS 3 "19 Jun 2014" "libcurl 7.37.0" "curl_easy_setopt options" |
| 24 |
.SH NAME |
| 25 |
CURLOPT_FTP_CREATE_MISSING_DIRS \- create missing dirs for FTP and SFTP |
| 26 |
.SH SYNOPSIS |
| 27 |
.nf |
| 28 |
#include <curl/curl.h> |
| 29 |
|
| 30 |
typedef enum { |
| 31 |
CURLFTP_CREATE_DIR_NONE, |
| 32 |
CURLFTP_CREATE_DIR, |
| 33 |
CURLFTP_CREATE_DIR_RETRY |
| 34 |
} curl_ftpcreatedir; |
| 35 |
|
| 36 |
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTP_CREATE_MISSING_DIRS, |
| 37 |
long create); |
| 38 |
.SH DESCRIPTION |
| 39 |
Pass a long telling libcurl to \fIcreate\fP the dir. If the value is |
| 40 |
\fICURLFTP_CREATE_DIR\fP (1), libcurl will attempt to create any remote |
| 41 |
directory that it fails to "move" into. |
| 42 |
|
| 43 |
For FTP requests, that means a CWD command fails. CWD being the command that |
| 44 |
changes working directory. |
| 45 |
|
| 46 |
For SFTP requests, libcurl will attempt to create the remote directory if it |
| 47 |
can't obtain a handle to the target-location. The creation will fail if a file |
| 48 |
of the same name as the directory to create already exists or lack of |
| 49 |
permissions prevents creation. |
| 50 |
|
| 51 |
Setting \fIcreate\fP to \fICURLFTP_CREATE_DIR_RETRY\fP (2), tells libcurl to |
| 52 |
retry the CWD command again if the subsequent MKD command fails. This is |
| 53 |
especially useful if you're doing many simultaneous connections against the |
| 54 |
same server and they all have this option enabled, as then CWD may first fail |
| 55 |
but then another connection does MKD before this connection and thus MKD fails |
| 56 |
but trying CWD works! |
| 57 |
.SH DEFAULT |
| 58 |
CURLFTP_CREATE_DIR_NONE (0) |
| 59 |
.SH PROTOCOLS |
| 60 |
FTP and SFTP |
| 61 |
.SH EXAMPLE |
| 62 |
.nf |
| 63 |
CURL *curl = curl_easy_init(); |
| 64 |
if(curl) { |
| 65 |
curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/non-existing/new.txt"); |
| 66 |
curl_easy_setopt(curl, CURLOPT_FTP_CREATE_MISSING_DIRS, |
| 67 |
CURLFTP_CREATE_DIR_RETRY); |
| 68 |
|
| 69 |
ret = curl_easy_perform(curl); |
| 70 |
|
| 71 |
curl_easy_cleanup(curl); |
| 72 |
} |
| 73 |
.fi |
| 74 |
.SH AVAILABILITY |
| 75 |
Added in 7.10.7. SFTP support added in 7.16.3. The retry option was added in |
| 76 |
7.19.4. |
| 77 |
.SH RETURN VALUE |
| 78 |
Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if the |
| 79 |
create value is not. |
| 80 |
.SH "SEE ALSO" |
| 81 |
.BR CURLOPT_FTP_FILEMETHOD "(3), " CURLOPT_FTP_USE_EPSV "(3), " |