LibCurl SFTP 获取文件的完整列表

LibCurl SFTP get full list of files

我需要使用 libcurl 从 2 个服务器(ftp 和 sftp)获取完整的文件列表。

Libcurl 信息:

System: Windows 7;
Wrapper: SourcePawn;
Version: libcurl/7.23.1 OpenSSL/0.9.8r zlib/1.2.5 libssh2/1.3.0;
Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp scp sftp smtp smtps telnet tftp.

重点是,我的代码 returns ftp 服务器的完整文件列表,但不是 sftp。对于 sftp 服务器,我只有一个(第一行)。

这是我的代码:

public RequestFileList()
{   
    new Handle:curl = curl_easy_init();
    if(curl != INVALID_HANDLE)
    {
        LogMessage("RequestFileList");

        CURL_DEFAULT_OPT(curl);


        curl_easy_setopt_function(curl, CURLOPT_WRITEFUNCTION, GetFileList);
        curl_easy_setopt_string(curl, CURLOPT_URL, "sftp://xxxxx:5000/");
        curl_easy_setopt_string(curl, CURLOPT_USERPWD, "xxx:xxx");
        curl_easy_setopt_int(curl, CURLOPT_USE_SSL, CURLUSESSL_TRY);
        curl_easy_setopt_int(curl, CURLOPT_VERBOSE, 1);
        curl_easy_perform_thread(curl, onCompleteFilelist, 1);
    }
}
public GetFileList(Handle:hndl, const String:buffer[], const bytes, const nmemb)
{

    LogMessage("%s %i %i", buffer, bytes, nmemb);
}

输出:

drwxr-xr-x   11 root     root            0 Mar 27  2014 sys
 1 60

如果我用 cmd 执行它:

curl -k -u xxx:xxx sftp://xxxx:5000/

我得到了完整的文件列表:

drwxr-xr-x   11 root     root            0 Mar 27  2014 sys
drwx------    2 root     root        16384 Jul 30  2009 lost+found
drwxr-xr-x   22 root     root         4096 Dec 31  2013 work
drwxr-xr-x    2 root     root         4096 Jul 30  2009 plugin

我应该更改什么以获得完整的文件列表?

这是完整的日志:

* About to connect() to xxxxxxxxxxx port 5000 (#0)
*   Trying xxx.xxx.xxx.xxx... 
* connected
* SSH authentication methods available: publickey,gssapi-keyex,gssapi-with-mic,password
* Using ssh public key file id_dsa.pub
* Using ssh private key file id_dsa
* SSH public key authentication failed: Unable to open public key file
* Initialized password authentication
* Authentication complete
L 02/07/2016 - 13:57:36: [pl.smx] STR - drwxr-xr-x   11 root     root            0 Mar 27  2014 sys
 1 60
* Connection #0 to host xxxxxxxxxxxxxxxx left intact
* Closing connection #0

您的 write callback returns 错误值,因此 libcurl 停在那里。