Logo Search packages:      
Sourcecode: harbour version File versions  Download package

void CZipArchive::MovePackedFiles ( DWORD  uStartOffset,
DWORD  uEndOffset,
DWORD  uMoveBy,
CZipActionCallback pCallback,
bool  bForward = false 
) [protected]

Move the range of data in the archive specified by the uStartOffset and uEndOffset by uToMove

Definition at line 3185 of file ziparchive.cpp.

References CZipException::abortedAction, CZipCentralDir::GetBytesBefore(), CZipAutoBuffer::GetSize(), m_centralDir, m_info, CZipArchive::CZipInternalInfo::m_pBuffer, CZipStorage::m_pFile, m_storage, and ThrowError().

Referenced by DeleteFiles(), MakeSpaceForReplace(), and RenameFile().

{
      ASSERT(m_info.m_pBuffer.GetSize() > 0);
      uStartOffset += m_centralDir.GetBytesBefore();
      uEndOffset += m_centralDir.GetBytesBefore();


      DWORD uTotalToMove = uEndOffset - uStartOffset;
      DWORD uPack = uTotalToMove > m_info.m_pBuffer.GetSize() ? m_info.m_pBuffer.GetSize() : uTotalToMove;
      char* buf = (char*)m_info.m_pBuffer;


      DWORD size_read;
      bool bBreak = false;
      do
      {

            if (uEndOffset - uStartOffset < uPack)
            {
                  uPack = uEndOffset - uStartOffset;
                  if (!uPack)
                        break;
                  bBreak = true;

            }
            DWORD uPosition = bForward ? uEndOffset - uPack : uStartOffset;

            m_storage.m_pFile->Seek(uPosition, CZipAbstractFile::begin);
            size_read = m_storage.m_pFile->Read(buf, uPack);
            if (!size_read)
                  break;

            if (bForward)
                  uPosition += uMoveBy;
            else
                  uPosition -= uMoveBy;
            m_storage.m_pFile->Seek(uPosition, CZipAbstractFile::begin);
            m_storage.m_pFile->Write(buf, size_read);
            if (bForward)
                  uEndOffset -= size_read;
            else
                  uStartOffset += size_read;
            if (pCallback)
                  if (!(*pCallback)(size_read))
                        ThrowError(CZipException::abortedAction);
      }
      while (!bBreak);

      if (uEndOffset != uStartOffset)
            ThrowError(CZipException::internal);

}


Generated by  Doxygen 1.6.0   Back to index