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