我将从wxFTP ( wxWidgets )迁移到libcurl。我只需提供URL就可以连接和获取所有目录和/目录下的文件。现在,我需要切换到另一个目录(假设为/public_html/mysite)。我不能用胡言乱语来做这个。
我不敢相信,在胡言乱语中这么难做到,所以我倾向于得出结论,我在这里错过了一些东西。我的相关代码如下所示,我所拥有的只是像/www这样的相对路径,而不是像ftp://someurl.com/www/那样的ftp
对不起,如果这是明显的东西,这是非常新鲜的,而且已经工作了许多小时,已经不成功了。
CURL* handle = curl_easy_init();
SetHandleOptions(handle); //set options
CURLcode res;
if(handle)
{
wxString command ="CWD "+path;
curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST , command.ToStdString().c_str());
res = curl_easy_perform(handle);
if(res==CURLE_OK)
{
wxString str(curl_easy_strerror(res));
SendMessage(str);
curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST , "MLSD");
res = curl_easy_perform(handle);
if(res==CURLE_OK)
{
wxString str(curl_easy_strerror(res));
SendMessage(str);
}
else
{
//send error message
wxString str(curl_easy_strerror(res));
SendMessage(str);
}
}
else
{
//send error message
wxString str(curl_easy_strerror(res));
SendMessage(str);
}
}
curl_easy_cleanup(handle);发布于 2013-11-29 21:06:00
这是我的错误,因为这是一段以ftp://ftp.hosanna.site40.net:21/public_html格式发送URL的代码,所以我改变了使用端口的方法。
因此,这不是curl的问题,但我的问题(虽然对我来说很微妙)也要确保所有的目录都以/或libray结尾,将它们解释为文件。
例如
ftp://ftp.hosanna.site40.net/public_html //interpreted as file
ftp://ftp.hosanna.site40.net/public_html/ //interpreted as directoryhttps://stackoverflow.com/questions/20292125
复制相似问题