title: Using the sftp protocol with libcurl -- How do I list the contents of a directory?
body: <p>I have a little doubt. I need to get a list of the files inside a specific directory on a SFTP server. I will use CUROPT_DIRLISTONLY in order to get just the names, but I'm not sure how to get them. This is the peace of code I have by now:</p>
  
  <pre><code>   string baseUrl(serverAddr + "/" + __destDir);
     curl_easy_setopt(anEasyHandle, CURLOPT_URL, (baseUrl).c_str());
     curl_easy_setopt(anEasyHandle, CURLOPT_VERBOSE,      1L);
     curl_easy_setopt(anEasyHandle, CURLOPT_DIRLISTONLY, 1);
     curl_easy_setopt(anEasyHandle, CURLOPT_QUOTE, commandList);
  
     curl_easy_perform(anEasyHandle);
  
     curl_easy_reset(anEasyHandle);
  </code></pre>
  
  <p>If I'm right, curl_easy_perform just returns an ERROR_CODE (success or error ir it applies), correct? So where can I get the files list?</p>
  
  <p>If I run it on a terminal: curl -u user:pass sftp://server/path/ -l I get the list I want....</p>
  
  <p>Any help would be appreciated.</p>
  
  <p>Thanks in advance,
  George</p>