2

我对此一无所知。我需要检查远程 FTP 服务器上是否存在目录。这就是我的想法:

//ls - lists the names of the files in the remote directory
string query = "ls /public_html/somefolder/";

//prepare to send
headers = curl_slist_append(headers, query.c_str());
curl_easy_setopt(curl, CURLOPT_QUOTE, headers); 

//send query to ftp server
res = curl_easy_perform(curl);

//check result
if(res == CURLE_OK) {
    cout << "FOLDER EXISTS";
} else {
    cout << "FOLDER DOESN'T EXIST";
}

当我检查res变量包含的内容时,它会输出:

CURLE_QUOTE_ERROR (21)。

关于如何正确执行此操作的任何想法?我已经大量搜索了谷歌。

4

1 回答 1

3

不要尝试CURLOPT_QUOTE用于此。ALIST是数据传输,因此它作为CURLOPT_URL.

CURL *curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, "ftp://ftp@ftp.gnu.org/pub/");
curl_easy_setopt(curl, CURLOPT_NOBODY, 1L);
CURLcode res = curl_easy_perform(curl);
if(res == CURLE_OK) std::cout << "FOLDER EXISTS\n";
else std::cout << "FOLDER DOESN'T EXIST\n";
于 2012-08-21T07:02:35.063 回答