Ejemplo n.º 1
1
size_t FileDownloader::write_data(void *ptr, size_t size, size_t nmemb, void *fileDownloader)
{
    FileDownloader * fd = (FileDownloader*)fileDownloader;
    File * destFile = fd->fileForWrite;
    
    int written = destFile->Write(ptr, size * nmemb);
    
    if ( fd->delegate != NULL )
    {
        fd->delegate->DownloadGetPacket(written);
    }
    
    // Pause & resume download 
    if ( fd->state == FD_PAUSE && !fd->isPauseChangeApplied )
    {
        curl_easy_pause( fd->GetCurlHandler(), CURLPAUSE_ALL );
        fd->isPauseChangeApplied = true;
        Logger::Instance()->Debug(" ----- Downloader pause");
    }
    
    // Stop download
    if ( fd->state == FD_STOP )
    {
        return CURL_READFUNC_ABORT;
    }
    
    return written;
}