16,471
社区成员
发帖
与我相关
我的任务
分享
UINT CMultiFiles::Read(void* lpBuf, UINT nCount)
{
DWORD dwRead;
do
{
if (!ReadFile(m_hFile, lpBuf, nCount, &dwRead, NULL))
{
break;
}
if (dwRead != nCount && (m_nCurPart < 0 || (size_t)m_nCurPart < m_strFiles.GetCount() - 1))
{
OpenPart(m_nCurPart + 1);
lpBuf = (void*)((BYTE*)lpBuf + dwRead);
nCount -= dwRead;
}
} while (nCount != dwRead && (m_nCurPart < 0 || (size_t)m_nCurPart < m_strFiles.GetCount() - 1));
//逆序
void* pTmp = NULL;
void* pEnd = NULL;
pEnd = (void*)((BYTE*)lpBuf + nCount);
for(int i=0; i<nCount/2; i++)
{
*((BYTE*)pTmp) = *((BYTE*)lpBuf);
*((BYTE*)lpBuf) = *((BYTE*)pEnd);
lpBuf = (void*)((BYTE*)lpBuf + 1);
*((BYTE*)pEnd) = *((BYTE*)pTmp);
pEnd = (void*)((BYTE*)pEnd - 1);
}
return dwRead;
}