cURL / Mailing Lists / curl-library / Single Mail


problem with empty files (ftp downloading on win32)

From: James Brannan <>
Date: Fri, 07 Dec 2001 18:06:04 -0500

The curl documentation doesnt seem to be much help on win32 issues....
(I'm using the latest curl version)

I have a Singleton class that calls global init with the win32 param
curl_global_init(CURL_GLOBAL_WIN32) when constructed
when destructed.

*** The problem is in a class I call FTPWrapper class , I have a download method and an upload method. The upload method seems to work fine, but the download method creates empty files on the client with the exception of the last file. (I am calling download in a loop passing a new file path and name to download each time - only the last loop returns a file with content - but when I step through the code they ALL return content?????)

I suspect its something to do with the curl handle - but I cant make heads or tails of the documentation on this - I pretty much followed the example simpleget.c code exactly. Anyone know the problem?

Code follows:

int FTPWrapper::download(char *chrLocalFile, char *chrAddress, char *chrUserPass, bool blnBinary)
        char test[1000];
        CURL *curl = curl_easy_init();;
        CURLcode res;
        FILE *ftpfile;
        int intSuccess = 0;

                if (curl)
                                                ftpfile = fopen(chrLocalFile, "wb");
                        curl_easy_setopt(curl, CURLOPT_USERPWD, chrUserPass);
                        curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, test);
                        curl_easy_setopt(curl, CURLOPT_URL, chrAddress);
                        curl_easy_setopt(curl, CURLOPT_FILE, ftpfile);
                        res = curl_easy_perform(curl);
                        if(res == 0) intSuccess = 1;
                           this->myLog->write2Log("\nerror downloading file: \n");
                        intSuccess = 0;
                        intSuccess = 0;
                return intSuccess;
                if (ftpfile) fclose(ftpfile);
                return 0;

Received on 2001-12-08