Index: src/libchcore/TLocalFilesystem.cpp =================================================================== diff -u -r3c343f2e7aa0d489706136e78f2f56cdd5d417a9 -rb75259a9158d8b46d747e20ab4960dd002adb4b1 --- src/libchcore/TLocalFilesystem.cpp (.../TLocalFilesystem.cpp) (revision 3c343f2e7aa0d489706136e78f2f56cdd5d417a9) +++ src/libchcore/TLocalFilesystem.cpp (.../TLocalFilesystem.cpp) (revision b75259a9158d8b46d747e20ab4960dd002adb4b1) @@ -40,6 +40,7 @@ #include "TFileTime.h" #include "TOverlappedDataBuffer.h" #include "RoundingFunctions.h" +#include BEGIN_CHCORE_NAMESPACE @@ -458,7 +459,8 @@ if (!IsOpen()) THROW_CORE_EXCEPTION(eErr_InternalProblem); - if (!::ReadFileEx(m_hFile, rBuffer.GetBufferPtr(), rBuffer.GetRequestedDataSize(), &rBuffer, OverlappedReadCompleted)) + ATLTRACE(_T("Reading %lu bytes\n"), rBuffer.GetRequestedDataSize()); + if(!::ReadFileEx(m_hFile, rBuffer.GetBufferPtr(), rBuffer.GetRequestedDataSize(), &rBuffer, OverlappedReadCompleted)) { DWORD dwLastError = GetLastError(); switch(dwLastError) @@ -494,6 +496,7 @@ if (m_bNoBuffering && rBuffer.IsLastPart()) dwToWrite = RoundUp(dwToWrite, MaxSectorSize); + ATLTRACE(_T("Writing %lu bytes\n"), dwToWrite); if (!::WriteFileEx(m_hFile, rBuffer.GetBufferPtr(), dwToWrite, &rBuffer, OverlappedWriteCompleted)) { if (GetLastError() == ERROR_IO_PENDING) @@ -511,9 +514,11 @@ if (m_bNoBuffering && rBuffer.IsLastPart()) { - DWORD dwToWrite = boost::numeric_cast(rBuffer.GetBytesTransferred()); + DWORD dwToWrite = boost::numeric_cast(rBuffer.GetRealDataSize()); DWORD dwReallyWritten = RoundUp(dwToWrite, MaxSectorSize); + ATLTRACE(_T("Finalize file - size diff: written: %I64u, required: %I64u\n"), dwReallyWritten, dwToWrite); + if (dwToWrite != dwReallyWritten) { unsigned long long ullNewFileSize = rBuffer.GetFilePosition() + dwToWrite; // new size @@ -522,6 +527,7 @@ return false; //seek + ATLTRACE(_T("Truncating file to %I64u bytes\n"), ullNewFileSize); if (!SetFilePointer(ullNewFileSize, FILE_BEGIN)) return false; Index: src/libchcore/TOverlappedDataBuffer.cpp =================================================================== diff -u -r3c343f2e7aa0d489706136e78f2f56cdd5d417a9 -rb75259a9158d8b46d747e20ab4960dd002adb4b1 --- src/libchcore/TOverlappedDataBuffer.cpp (.../TOverlappedDataBuffer.cpp) (revision 3c343f2e7aa0d489706136e78f2f56cdd5d417a9) +++ src/libchcore/TOverlappedDataBuffer.cpp (.../TOverlappedDataBuffer.cpp) (revision b75259a9158d8b46d747e20ab4960dd002adb4b1) @@ -35,9 +35,10 @@ /////////////////////////////////////////////////////////////////////////////////// // class TOverlappedDataBuffer -VOID CALLBACK OverlappedReadCompleted(DWORD dwErrorCode, DWORD /*dwNumberOfBytesTransfered*/, LPOVERLAPPED lpOverlapped) +VOID CALLBACK OverlappedReadCompleted(DWORD dwErrorCode, DWORD dwNumberOfBytesTransfered, LPOVERLAPPED lpOverlapped) { TOverlappedDataBuffer* pBuffer = (TOverlappedDataBuffer*) lpOverlapped; + ATLTRACE(_T("OverlappedReadCompleted - read %I64u bytes\n"), pBuffer->GetBytesTransferred()); bool bEof = (dwErrorCode == ERROR_HANDLE_EOF || pBuffer->GetStatusCode() == STATUS_END_OF_FILE || @@ -50,14 +51,16 @@ if (dwErrorCode != ERROR_SUCCESS) ATLTRACE(_T("OverlappedReadCompleted error: %lu, status code: %I64u\n"), dwErrorCode, pBuffer->GetStatusCode()); + pBuffer->SetRealDataSize(dwNumberOfBytesTransfered); pBuffer->SetLastPart(bEof); pBuffer->RequeueAsFull(); } VOID CALLBACK OverlappedWriteCompleted(DWORD dwErrorCode, DWORD /*dwNumberOfBytesTransfered*/, LPOVERLAPPED lpOverlapped) { TOverlappedDataBuffer* pBuffer = (TOverlappedDataBuffer*) lpOverlapped; - if (dwErrorCode != ERROR_SUCCESS) + ATLTRACE(_T("OverlappedWriteCompleted - written %I64u bytes\n"), pBuffer->GetBytesTransferred()); + if(dwErrorCode != ERROR_SUCCESS) ATLTRACE(_T("OverlappedWriteCompleted error: %lu, status code: %I64u\n"), dwErrorCode, pBuffer->GetStatusCode()); pBuffer->RequeueAsFinished(); @@ -68,7 +71,8 @@ m_stBufferSize(0), m_bLastPart(false), m_pQueue(pQueue), - m_dwRequestedDataSize(0) + m_dwRequestedDataSize(0), + m_dwRealDataSize(0) { if (!m_pQueue) THROW_CORE_EXCEPTION(eErr_InvalidPointer); Index: src/libchcore/TOverlappedDataBuffer.h =================================================================== diff -u -r3c343f2e7aa0d489706136e78f2f56cdd5d417a9 -rb75259a9158d8b46d747e20ab4960dd002adb4b1 --- src/libchcore/TOverlappedDataBuffer.h (.../TOverlappedDataBuffer.h) (revision 3c343f2e7aa0d489706136e78f2f56cdd5d417a9) +++ src/libchcore/TOverlappedDataBuffer.h (.../TOverlappedDataBuffer.h) (revision b75259a9158d8b46d747e20ab4960dd002adb4b1) @@ -72,6 +72,9 @@ void SetBytesTransferred(ULONG_PTR ulBytes) { InternalHigh = ulBytes; } ULONG_PTR GetBytesTransferred() const { return InternalHigh; } + DWORD GetRealDataSize() const { return m_dwRealDataSize; } + void SetRealDataSize(DWORD dwRealDataSize) { m_dwRealDataSize = dwRealDataSize; } + unsigned long long GetFilePosition() const { return (unsigned long long)OffsetHigh << 32 | Offset; } void SetFilePosition(unsigned long long ullPosition) { OffsetHigh = (DWORD) (ullPosition >> 32); Offset = (DWORD) ullPosition; } @@ -85,7 +88,7 @@ LPVOID m_pBuffer; // pointer to the allocated buffer size_t m_stBufferSize; // total buffer size DWORD m_dwRequestedDataSize; // part of the buffer that is to be used for data transfer (<= m_stBufferSize) - + DWORD m_dwRealDataSize; // data size as reported by read operation DWORD m_dwErrorCode; // win32 error code bool m_bLastPart; // marks the last part of the file unsigned long long m_ullBufferOrder; // marks the order of this buffer Index: src/libchcore/TSubTaskCopyMove.cpp =================================================================== diff -u -r3c343f2e7aa0d489706136e78f2f56cdd5d417a9 -rb75259a9158d8b46d747e20ab4960dd002adb4b1 --- src/libchcore/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision 3c343f2e7aa0d489706136e78f2f56cdd5d417a9) +++ src/libchcore/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision b75259a9158d8b46d747e20ab4960dd002adb4b1) @@ -295,6 +295,8 @@ AdjustBufferIfNeeded(pData->dbBuffer, pData->tBufferSizes); pData->dbBuffer.DataSourceChanged(); + ATLTRACE(_T("CustomCopyFile: %s\n"), pData->spSrcFile->GetFullFilePath().ToString()); + // establish count of data to read TBufferSizes::EBufferType eBufferIndex = GetBufferIndex(pData->tBufferSizes, pData->spSrcFile); m_tSubTaskStats.SetCurrentBufferIndex(eBufferIndex);