Revision: 254
Author:
gokturk...@gmail.com
Date: Sat Jun 29 12:06:27 2013
Log: Download card image files in chunks, not byte-by-byte.
This makes downloads noticeably faster.
http://code.google.com/p/ardb/source/detail?r=254
Modified:
/trunk/wxARDB/src/DownloadFile.cpp
=======================================
--- /trunk/wxARDB/src/DownloadFile.cpp Fri Feb 19 14:53:35 2010
+++ /trunk/wxARDB/src/DownloadFile.cpp Sat Jun 29 12:06:27 2013
@@ -52,7 +52,7 @@
void* wxDownloadFile::Entry()
{
- char c = 0;
+ char *buf = new char [m_nNotifyBytes];
int bytesread = 0;
m_bIsDownload = true;
wxDownloadEvent event(wxEVT_DOWNLOAD, GetId() );
@@ -121,9 +121,9 @@
wxInt64 nCount = 0;
file.Create(m_strDstDir + wxT("_dl") +
m_strFiles[m_nCurrentFile], true);
- while ((bytesread = (int)(pIn_Stream->Read(&c,
1)).LastRead()) > 0 &&
+ while ((bytesread = (int)(pIn_Stream->Read(buf,
m_nNotifyBytes)).LastRead()) > 0 &&
m_bIsDownload && !TestDestroy() ) {
- file.Write((const void *)&c, bytesread);
+ file.Write((const void *)buf, bytesread);
nCount += bytesread;
if (m_bNotifyDownloading &&
(nCount%m_nNotifyBytes) == 0 &&
nCount>=m_nNotifyBytes) {
@@ -184,6 +184,7 @@
fFilesLeftToDownload = FALSE;
}
}
+ delete [] buf;
event.SetDownLoadStatus(wxDownloadEvent::DOWNLOAD_COMPLETE);