curl-library
Problems with GetFile
Date: Wed, 12 Dec 2001 16:00:50 +0200
I am using this function to get a file.It works ok,but if i perform a file listing and then try to retrieve a file, i get the files with zero length and with no error returned!!!
Any suggestions?
void ICMFtpWrapper::GetFile(const char* localFileName, const char* remoteFileName, long& fileTime) {
CURLcode result;
FILE* localFile;
if (ftpServerAddrAlreadySet) {
if (!(localFile = fopen(localFileName, "wb"))) {
throw ICMFtpWrapperMemoryEx(errno);
}
if (!(strcpy(ftpFullAddr, ftpServerAddr))) {
throw ICMFtpWrapperMemoryEx(errno);
}
// cout << "ftpFullAddr: " << ftpFullAddr << endl;
if (!(strcat(ftpFullAddr, remoteFileName))) {
throw ICMFtpWrapperMemoryEx(errno);
}
// cout << "ftpFullAddr: " << ftpFullAddr << endl;
if ((result = curl_easy_setopt(curl, CURLOPT_URL, ftpFullAddr)) != CURLE_OK) {
throw ICMFtpWrapperCurlEx(result);
}
if ((result = curl_easy_setopt(curl, CURLOPT_FILE, localFile)) != CURLE_OK) {
throw ICMFtpWrapperCurlEx(result);
}
if ((result = curl_easy_setopt(curl, CURLOPT_USERPWD, userPwd)) != CURLE_OK) {
throw ICMFtpWrapperCurlEx(result);
}
if (fileTime)
if ((result = curl_easy_setopt(curl, CURLOPT_FILETIME, (long) TRUE)) != CURLE_OK) {
throw ICMFtpWrapperCurlEx(result);
}
// Perform the request
if ((result = curl_easy_perform(curl)) != CURLE_OK) {
throw ICMFtpWrapperCurlEx(result);
}
if (fileTime)
// Retrieve file time
if ((result = curl_easy_getinfo(curl, CURLINFO_FILETIME, &fileTime)) != CURLE_OK) {
throw ICMFtpWrapperCurlEx(result);
}
if (fflush(localFile) == EOF) {
throw ICMFtpWrapperMemoryEx(errno);
}
if (fclose(localFile) == EOF) {
throw ICMFtpWrapperMemoryEx(errno);
}
}
else {
throw ICMFtpWrapperInvalidFtpAddress(0);
}
}
- text/x-vcard attachment: Giorgos_Poulis.vcf