]> git.saurik.com Git - wxWidgets.git/commitdiff
corrected code to not suppose that Write() always writes all the data it was given
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 21 Jul 2004 10:41:17 +0000 (10:41 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 21 Jul 2004 10:41:17 +0000 (10:41 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28351 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/exec/exec.cpp

index 969f242b46d09b4d2a90dfb8c725217e167075bc..2ff98f261010c819373003a36b7f9e8e2e7e2d77 100644 (file)
@@ -1114,9 +1114,11 @@ void MyPipeFrame::OnBtnSendFile(wxCommandEvent& WXUNUSED(event))
     while ( len )
     {
         const size_t CHUNK_SIZE = 4096;
-        size_t lenChunk = len > CHUNK_SIZE ? CHUNK_SIZE : len;
+        m_out.Write(pc, len > CHUNK_SIZE ? CHUNK_SIZE : len);
 
-        m_out.Write(pc, lenChunk);
+        // note that not all data could have been written as we don't block on
+        // the write end of the pipe
+        const size_t lenChunk = m_out.LastWrite();
 
         pc += lenChunk;
         len -= lenChunk;