Sorry, but you sent your message to the wrong mailing-list. The current
mailing-list
is for cURLpp, which is a C++ wrapper for libcURL. Since, the code your
presenting
us is not using the C++ wrapper, I suggest to send your question to the
following:
http://cool.haxx.se/mailman/listinfo/curl-library

On Tue, Mar 10, 2009 at 12:50 AM, rajashri bhor <[email protected]>wrote:

> hello,
>
> i have written a code to download compressed (.zip) files using SFTP.
> It seems that zip file is not downloading complete file. size of source
> file and destination file is different.
>
> source file size is : 5103167 bytes
> downloaded file size is : 5095424 bytes
> difference in size is : 7743 bytes.
>
> after download if i try to gunzip the downloaded file i get following error
> :
>
> gunzip: <filename>.gz: unexpected end of file
>
> code snippet :
> static size_t my_fwrite (void *buffer, size_t size, size_t nmemb, void
> *stream)
> {
>   struct FtpFile *out = (struct FtpFile *) stream;
>
>   if (out && !out->stream) {
>     /* open file for writing */
>     out->stream = fopen (out->filename, "wb");
>
>     if (!out->stream) {
>       return (-1); /* failure, can't open file to write */
>     }
>   }
>   return ( fwrite (buffer, size, nmemb, out->stream));
> }
>
> int cmdGetFile (LoggerPtr loggerCxx, const char *username, const char
> *password,
>                 const char *hostip,
>                 const char *srcFile,
>                 const char *destFile, int resumeFlag,
>                 int largeFile /* =0 */)
> {
>   CURL          *curl = NULL;
>   CURLcode       res  = CURLE_OK;
>
>   /* get the file size of the local file */
>   struct stat    file_info;
>
>   if (stat (destFile, &file_info) == -1) {
>     EMS_LOG (loggerCxx, "Couldnt open '" << destFile << "': " <<
>              strerror (errno) << " resuming download from start")
>     file_info.st_size = 0;
>   }
>   else {
>     EMS_LOG (
>       loggerCxx, "Resuming download of '" << destFile << "': " << " from "
> <<
>       file_info.st_size)
>   }
>
>   struct FtpFile ftpfile;
>   ftpfile.filename = destFile;
>   ftpfile.stream   = NULL;
>
>   curl_global_init (CURL_GLOBAL_ALL);
>
>   curl             = curl_easy_init ();
>
>   if (curl) {
>     string url     = string ("sftp://";) + hostip + srcFile;
>     string userpwd = username + string (":") + password;
>     curl_easy_setopt (curl, CURLOPT_URL, url.c_str ());
>     curl_easy_setopt (curl, CURLOPT_TRANSFERTEXT, 1);
>     curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, my_fwrite);
>     curl_easy_setopt (curl, CURLOPT_WRITEDATA, &ftpfile);
>     curl_easy_setopt (curl, CURLOPT_VERBOSE, 1L);
>     curl_easy_setopt (curl, CURLOPT_USERPWD, userpwd.c_str ());
>
>     if (resumeFlag == 1) {
>       curl_easy_setopt (
>         curl, (largeFile) ? CURLOPT_RESUME_FROM_LARGE :
> CURLOPT_RESUME_FROM,
>         file_info.st_size);
>     }
>
>     /* Now run off and do what you've been told! */
>     res = curl_easy_perform (curl);
>
>    EMS_LOG (loggerCxx, "Curl returned: (" << res << ") " <<
> curl_easy_strerror (res))
>
>     /* always cleanup */
>     curl_easy_cleanup (curl);
>   }
>
>   curl_global_cleanup ();
>   return int(res);
> }
>
> int main(int argc, char **argv)
> {
>     cmdGetFile("userName", "password", "10.4.7.22", "sourcefile.gz",
> "destfile.gz", 0, 0);
>     return 0;
> }
>
> I am compiling above code on solaris platform.
> CURL version : 7.19.0 (SFTP enabled)
> LIBSSH2 version : 1.0
> OPENSSL version : 0.9.7g
>
>
>
> Thanks,
> Rajashri Bhor.
>
> ------------------------------
> Add more friends to your messenger and enjoy! Invite them 
> now.<http://in.rd.yahoo.com/tagline_messenger_6/*http://messenger.yahoo.com/invite/>
>
> _______________________________________________
> cURLpp mailing list
> [email protected]
> http://www.rrette.com/mailman/listinfo/curlpp
>
>
_______________________________________________
cURLpp mailing list
[email protected]
http://www.rrette.com/mailman/listinfo/curlpp

Reply via email to