CURLOPT_DIRLISTONLY.md (2179B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_DIRLISTONLY 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_CUSTOMREQUEST (3) 9 - CURLOPT_WILDCARDMATCH (3) 10 Protocol: 11 - FTP 12 - SFTP 13 - POP3 14 Added-in: 7.17.0 15 --- 16 17 # NAME 18 19 CURLOPT_DIRLISTONLY - ask for names only in a directory listing 20 21 # SYNOPSIS 22 23 ~~~c 24 #include <curl/curl.h> 25 26 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DIRLISTONLY, long listonly); 27 ~~~ 28 29 # DESCRIPTION 30 31 For FTP and SFTP based URLs a parameter set to 1 tells the library to list the 32 names of files in a directory, rather than performing a full directory listing 33 that would normally include file sizes, dates etc. 34 35 For POP3 a parameter of 1 tells the library to list the email message or 36 messages on the POP3 server. This can be used to change the default behavior 37 of 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 40 For FILE, this option has no effect yet as directories are always listed in 41 this mode. 42 43 Note: For FTP this causes a NLST command to be sent to the FTP server. Beware 44 that some FTP servers list only files in their response to NLST; they might 45 not include subdirectories and symbolic links. 46 47 Setting this option to 1 also implies a directory listing even if the URL 48 does not end with a slash, which otherwise is necessary. 49 50 Do not use this option if you also use CURLOPT_WILDCARDMATCH(3) as it 51 effectively breaks that feature. 52 53 # DEFAULT 54 55 0, disabled 56 57 # %PROTOCOLS% 58 59 # EXAMPLE 60 61 ~~~c 62 int 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 81 This option was known as CURLOPT_FTPLISTONLY up to 7.16.4. POP3 is supported 82 since 7.21.5. 83 84 # %AVAILABILITY% 85 86 # RETURN VALUE 87 88 curl_easy_setopt(3) returns a CURLcode indicating success or error. 89 90 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 91 libcurl-errors(3).