CURLOPT_FTP_CREATE_MISSING_DIRS.3 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, 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.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. .\" * SPDX-License-Identifier: curl
  22. .\" *
  23. .\" **************************************************************************
  24. .\"
  25. .TH CURLOPT_FTP_CREATE_MISSING_DIRS 3 "January 02, 2023" "libcurl 7.88.1" "curl_easy_setopt options"
  26. .SH NAME
  27. CURLOPT_FTP_CREATE_MISSING_DIRS \- create missing directories for FTP and SFTP
  28. .SH SYNOPSIS
  29. .nf
  30. #include <curl/curl.h>
  31. typedef enum {
  32. CURLFTP_CREATE_DIR_NONE,
  33. CURLFTP_CREATE_DIR,
  34. CURLFTP_CREATE_DIR_RETRY
  35. } curl_ftpcreatedir;
  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. For FTP requests, that means a CWD command fails. CWD being the command that
  43. changes working directory.
  44. For SFTP requests, libcurl will attempt to create the remote directory if it
  45. cannot obtain a handle to the target-location. The creation will fail if a file
  46. of the same name as the directory to create already exists or lack of
  47. permissions prevents creation.
  48. Setting \fIcreate\fP to \fICURLFTP_CREATE_DIR_RETRY\fP (2), tells libcurl to
  49. retry the CWD command again if the subsequent \fBMKD\fP 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 \fBMKD\fP before this connection and thus
  53. \fBMKD\fP fails but trying CWD works!
  54. .SH DEFAULT
  55. CURLFTP_CREATE_DIR_NONE (0)
  56. .SH PROTOCOLS
  57. FTP and SFTP
  58. .SH EXAMPLE
  59. .nf
  60. CURL *curl = curl_easy_init();
  61. if(curl) {
  62. curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/non-existing/new.txt");
  63. curl_easy_setopt(curl, CURLOPT_FTP_CREATE_MISSING_DIRS,
  64. (long)CURLFTP_CREATE_DIR_RETRY);
  65. ret = curl_easy_perform(curl);
  66. curl_easy_cleanup(curl);
  67. }
  68. .fi
  69. .SH AVAILABILITY
  70. Added in 7.10.7. SFTP support added in 7.16.3. The retry option was added in
  71. 7.19.4.
  72. .SH RETURN VALUE
  73. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if the
  74. create value is not.
  75. .SH "SEE ALSO"
  76. .BR CURLOPT_FTP_FILEMETHOD "(3), " CURLOPT_FTP_USE_EPSV "(3), "