curl-library
Delete downloaded files after using wildcard ftp download
Date: Tue, 2 Apr 2013 13:52:07 -0400
I have an operation that downloads a directory using the ftp wildcard
feature similar to below. Is it possible to add a command using
CURLOPT_POSTQUOTE
or some other feature that will make libcurl automatically send a delete
request to the server for each file after it is downloaded? Or is it
necessary for my file transfer to get the info on the directory, parse the
files and folders, then individually download each file with a postquote
saying to delete the file with the file name, then repeat this process for
each subdirectory?
std::string target;
target += strsrcdir;
target += "*";
m_curl = curl_easy_init();
curl_easy_setopt(m_curl, CURLOPT_WILDCARDMATCH, 1L);
curl_easy_setopt(m_curl, CURLOPT_USERPWD, m_usnpwd.c_str());
curl_easy_setopt(m_curl, CURLOPT_CHUNK_BGN_FUNCTION, file_is_comming);
curl_easy_setopt(m_curl, CURLOPT_CHUNK_END_FUNCTION,
file_is_downloaded);
curl_easy_setopt(m_curl, CURLOPT_WRITEFUNCTION, file_write);
curl_easy_setopt(m_curl, CURLOPT_URL, target.c_str());
curl_easy_setopt(m_curl, CURLOPT_CHUNK_DATA, &data);
curl_easy_setopt(m_curl, CURLOPT_WRITEDATA, &data);
res = curl_easy_perform(m_curl);
if ((CURLE_OK != res) && (CURLE_REMOTE_FILE_NOT_FOUND != res))
{
// cURL returns file not found on empty directories.
// Since we're only looking for files that exist and
// this error may happen we ignore this.
}
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-04-02