quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

CURLOPT_FTP_CREATE_MISSING_DIRS.md (2209B)


      1 ---
      2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
      3 SPDX-License-Identifier: curl
      4 Title: CURLOPT_FTP_CREATE_MISSING_DIRS
      5 Section: 3
      6 Source: libcurl
      7 Protocol:
      8   - FTP
      9 See-also:
     10   - CURLOPT_FTP_FILEMETHOD (3)
     11   - CURLOPT_FTP_USE_EPSV (3)
     12 Added-in: 7.10.7
     13 ---
     14 
     15 # NAME
     16 
     17 CURLOPT_FTP_CREATE_MISSING_DIRS - create missing directories for FTP and SFTP
     18 
     19 # SYNOPSIS
     20 
     21 ~~~c
     22 #include <curl/curl.h>
     23 
     24 typedef enum {
     25   CURLFTP_CREATE_DIR_NONE,
     26   CURLFTP_CREATE_DIR,
     27   CURLFTP_CREATE_DIR_RETRY
     28 } curl_ftpcreatedir;
     29 
     30 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTP_CREATE_MISSING_DIRS,
     31                           long create);
     32 ~~~
     33 
     34 # DESCRIPTION
     35 
     36 Pass a long telling libcurl to *create* the dir. If the value is
     37 *CURLFTP_CREATE_DIR* (1), libcurl may create any remote directory that it
     38 fails to "move" into.
     39 
     40 For FTP requests, that means a CWD command fails. CWD being the command that
     41 changes working directory.
     42 
     43 For SFTP requests, libcurl may create the remote directory if it cannot obtain
     44 a handle to the target-location. The creation fails if a file of the same name
     45 as the directory to create already exists or lack of permissions prevents
     46 creation.
     47 
     48 Setting *create* to *CURLFTP_CREATE_DIR_RETRY* (2), tells libcurl to
     49 retry the CWD command again if the subsequent **MKD** command fails. This is
     50 especially useful if you are doing many simultaneous connections against the
     51 same server and they all have this option enabled, as then CWD may first fail
     52 but then another connection does **MKD** before this connection and thus
     53 **MKD** fails but trying CWD works.
     54 
     55 # DEFAULT
     56 
     57 CURLFTP_CREATE_DIR_NONE (0)
     58 
     59 # %PROTOCOLS%
     60 
     61 # EXAMPLE
     62 
     63 ~~~c
     64 int main(void)
     65 {
     66   CURL *curl = curl_easy_init();
     67   if(curl) {
     68     CURLcode res;
     69     curl_easy_setopt(curl, CURLOPT_URL,
     70                      "ftp://example.com/non-existing/new.txt");
     71     curl_easy_setopt(curl, CURLOPT_FTP_CREATE_MISSING_DIRS,
     72                      (long)CURLFTP_CREATE_DIR_RETRY);
     73 
     74     res = curl_easy_perform(curl);
     75 
     76     curl_easy_cleanup(curl);
     77   }
     78 }
     79 ~~~
     80 
     81 # %AVAILABILITY%
     82 
     83 # RETURN VALUE
     84 
     85 curl_easy_setopt(3) returns a CURLcode indicating success or error.
     86 
     87 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see
     88 libcurl-errors(3).