1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_FTP_FILEMETHOD
5Section: 3
6Source: libcurl
7Protocol:
8  - FTP
9See-also:
10  - CURLOPT_DIRLISTONLY (3)
11  - CURLOPT_FTP_SKIP_PASV_IP (3)
12Added-in: 7.15.1
13---
14
15# NAME
16
17CURLOPT_FTP_FILEMETHOD - select directory traversing method for FTP
18
19# SYNOPSIS
20
21~~~c
22#include <curl/curl.h>
23
24CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTP_FILEMETHOD,
25                          long method);
26~~~
27
28# DESCRIPTION
29
30Pass a long telling libcurl which *method* to use to reach a file on a
31FTP(S) server.
32
33This option exists because some server implementations are not compliant to
34what the standards say should work.
35
36The argument should be one of the following alternatives:
37
38## CURLFTPMETHOD_MULTICWD
39
40libcurl does a single CWD operation for each path part in the given URL. For
41deep hierarchies this means many commands. This is how RFC 1738 says it should
42be done. This is the default but the slowest behavior.
43
44## CURLFTPMETHOD_NOCWD
45
46libcurl makes no CWD at all. libcurl does SIZE, RETR, STOR etc and gives a
47full path to the server for all these commands. This is the fastest behavior
48since it skips having to change directories.
49
50## CURLFTPMETHOD_SINGLECWD
51
52libcurl does one CWD with the full target directory and then operates on the
53file &"normally" (like in the multicwd case). This is somewhat more standards
54compliant than 'nocwd' but without the full penalty of 'multicwd'.
55
56# DEFAULT
57
58CURLFTPMETHOD_MULTICWD
59
60# %PROTOCOLS%
61
62# EXAMPLE
63
64~~~c
65int main(void)
66{
67  CURL *curl = curl_easy_init();
68  if(curl) {
69    CURLcode res;
70    curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/1/2/3/4/new.txt");
71    curl_easy_setopt(curl, CURLOPT_FTP_FILEMETHOD,
72                     (long)CURLFTPMETHOD_SINGLECWD);
73
74    res = curl_easy_perform(curl);
75
76    curl_easy_cleanup(curl);
77  }
78}
79~~~
80
81# %AVAILABILITY%
82
83# RETURN VALUE
84
85Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
86