From cc0a458f92422a0039e46149d4f1ae30ab92a035 Mon Sep 17 00:00:00 2001 From: Huw Davies Date: Thu, 14 Feb 2008 13:53:49 +0000 Subject: [PATCH] inetcomm: Add IStream_CopyTo to the sub-stream implementation. --- dlls/inetcomm/mimeole.c | 42 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/dlls/inetcomm/mimeole.c b/dlls/inetcomm/mimeole.c index 1fd9983862..a0da6b951c 100644 --- a/dlls/inetcomm/mimeole.c +++ b/dlls/inetcomm/mimeole.c @@ -1251,8 +1251,46 @@ static HRESULT WINAPI sub_stream_CopyTo( ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten) { - FIXME("stub\n"); - return E_NOTIMPL; + HRESULT hr = S_OK; + BYTE tmpBuffer[128]; + ULONG bytesRead, bytesWritten, copySize; + ULARGE_INTEGER totalBytesRead; + ULARGE_INTEGER totalBytesWritten; + + TRACE("(%p)->(%p, %d, %p, %p)\n", iface, pstm, cb.LowPart, pcbRead, pcbWritten); + + totalBytesRead.QuadPart = 0; + totalBytesWritten.QuadPart = 0; + + while ( cb.QuadPart > 0 ) + { + if ( cb.QuadPart >= sizeof(tmpBuffer) ) + copySize = sizeof(tmpBuffer); + else + copySize = cb.u.LowPart; + + hr = IStream_Read(iface, tmpBuffer, copySize, &bytesRead); + if (FAILED(hr)) break; + + totalBytesRead.QuadPart += bytesRead; + + if (bytesRead) + { + hr = IStream_Write(pstm, tmpBuffer, bytesRead, &bytesWritten); + if (FAILED(hr)) break; + totalBytesWritten.QuadPart += bytesWritten; + } + + if (bytesRead != copySize) + cb.QuadPart = 0; + else + cb.QuadPart -= bytesRead; + } + + if (pcbRead) pcbRead->QuadPart = totalBytesRead.QuadPart; + if (pcbWritten) pcbWritten->QuadPart = totalBytesWritten.QuadPart; + + return hr; } static HRESULT WINAPI sub_stream_Commit( -- 2.32.0.93.g670b81a890