[ardb] r255 committed - Use buffered output stream for saving files in DownloadFile class.

1 view
Skip to first unread message

codesite...@google.com

unread,
Jun 29, 2013, 3:13:44 PM6/29/13
to ardb-...@googlegroups.com
Revision: 255
Author: gokturk...@gmail.com
Date: Sat Jun 29 12:13:31 2013
Log: Use buffered output stream for saving files in DownloadFile class.
http://code.google.com/p/ardb/source/detail?r=255

Modified:
/trunk/wxARDB/src/DownloadFile.cpp

=======================================
--- /trunk/wxARDB/src/DownloadFile.cpp Sat Jun 29 12:06:27 2013
+++ /trunk/wxARDB/src/DownloadFile.cpp Sat Jun 29 12:13:31 2013
@@ -23,6 +23,7 @@
#ifdef __WXMSW__
#include <wx/msw/registry.h>
#endif
+#include <wx/wfstream.h>

wxDownloadFile::wxDownloadFile(wxWindow *pParent, wxString strURL,
wxArrayString &strFiles,
wxString strDstDir, bool bNotify, wxInt64
nBytes)
@@ -120,10 +121,12 @@
wxFile file;
wxInt64 nCount = 0;
file.Create(m_strDstDir + wxT("_dl") +
m_strFiles[m_nCurrentFile], true);
+ wxFileOutputStream pOut_Stream(file);
+ wxBufferedOutputStream pBuffered_Out_Stream(pOut_Stream);

while ((bytesread = (int)(pIn_Stream->Read(buf,
m_nNotifyBytes)).LastRead()) > 0 &&
m_bIsDownload && !TestDestroy() ) {
- file.Write((const void *)buf, bytesread);
+ pBuffered_Out_Stream.Write(buf, bytesread);
nCount += bytesread;
if (m_bNotifyDownloading &&
(nCount%m_nNotifyBytes) == 0 &&
nCount>=m_nNotifyBytes) {
@@ -133,7 +136,9 @@
}
}

- file.Close();
+ pBuffered_Out_Stream.Sync();
+ pOut_Stream.Close();
+ file.Close();
delete pIn_Stream;

//File downloaded.
Reply all
Reply to author
Forward
0 new messages