I am connected to a SFTP site and require the list of files in a specific directory. What I get is only one line (so only one file) as if there is a terminator at the end of the string. This is my code:
My callbacck is:
static size_t getRemoteListCallback(char* buf, size_t size, size_t nmemb, void* up)
{
size_t realsize = size * nmemb;
((string*)up)->append(buf, realsize);
return realsize;
}
And my code is:
void GetRemoteList ()
{
string fileListBuffer = "";
curl_easy_setopt(m_curl, CURLOPT_URL, sRemoteURL.c_str()); // Target URL
curl_easy_setopt(m_curl, CURLOPT_WRITEFUNCTION, &getRemoteListCallback );
curl_easy_setopt(m_curl, CURLOPT_WRITEDATA, &fileListBuffer );
curl_easy_setopt(m_curl, CURLOPT_VERBOSE, 1);
curl_easy_setopt(m_curl, CURLOPT_DIRLISTONLY, 1L);
curl_easy_setopt(m_curl, CURLOPT_USERPWD, sUserPassword.c_str());
curl_easy_setopt(m_curl, CURLOPT_SSH_AUTH_TYPES, CURLSSH_AUTH_PASSWORD);
CURLcode res = curl_easy_perform(m_curl);
....
}
Someone have an idea ?