1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_DIRLISTONLY
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_CUSTOMREQUEST (3)
9  - CURLOPT_WILDCARDMATCH (3)
10Protocol:
11  - FTP
12  - SFTP
13  - POP3
14Added-in: 7.17.0
15---
16
17# NAME
18
19CURLOPT_DIRLISTONLY - ask for names only in a directory listing
20
21# SYNOPSIS
22
23~~~c
24#include <curl/curl.h>
25
26CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DIRLISTONLY, long listonly);
27~~~
28
29# DESCRIPTION
30
31For FTP and SFTP based URLs a parameter set to 1 tells the library to list the
32names of files in a directory, rather than performing a full directory listing
33that would normally include file sizes, dates etc.
34
35For POP3 a parameter of 1 tells the library to list the email message or
36messages on the POP3 server. This can be used to change the default behavior
37of libcurl, when combined with a URL that contains a message ID, to perform a
38"scan listing" which can then be used to determine the size of an email.
39
40For FILE, this option has no effect yet as directories are always listed in
41this mode.
42
43Note: For FTP this causes a NLST command to be sent to the FTP server. Beware
44that some FTP servers list only files in their response to NLST; they might
45not include subdirectories and symbolic links.
46
47Setting this option to 1 also implies a directory listing even if the URL
48does not end with a slash, which otherwise is necessary.
49
50Do not use this option if you also use CURLOPT_WILDCARDMATCH(3) as it
51effectively breaks that feature.
52
53# DEFAULT
54
550, disabled
56
57# %PROTOCOLS%
58
59# EXAMPLE
60
61~~~c
62int main(void)
63{
64  CURL *curl = curl_easy_init();
65  if(curl) {
66    CURLcode res;
67    curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/dir/");
68
69    /* list only */
70    curl_easy_setopt(curl, CURLOPT_DIRLISTONLY, 1L);
71
72    res = curl_easy_perform(curl);
73
74    curl_easy_cleanup(curl);
75  }
76}
77~~~
78
79# HISTORY
80
81This option was known as CURLOPT_FTPLISTONLY up to 7.16.4. POP3 is supported
82since 7.21.5.
83
84# %AVAILABILITY%
85
86# RETURN VALUE
87
88Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
89