void CopyEntryDirect(ZipFile workFile, ZipUpdate update, ref long destinationPosition)
{
bool skipOver = false;
if ( update.Entry.Offset == destinationPosition ) {
skipOver = true;
}
if ( !skipOver ) {
baseStream_.Position = destinationPosition;
workFile.WriteLocalEntryHeader(update);
destinationPosition = baseStream_.Position;
}
long sourcePosition = 0;
const int NameLengthOffset = 26;
// TODO: Add base for SFX friendly handling
long entryDataOffset = update.Entry.Offset + NameLengthOffset;
baseStream_.Seek(entryDataOffset, SeekOrigin.Begin);
// Clumsy way of handling retrieving the original name and extra data length for now.
// TODO: Stop re-reading name and data length in CopyEntryDirect.
uint nameLength = ReadLEUshort();
uint extraLength = ReadLEUshort();
sourcePosition = baseStream_.Position + nameLength + extraLength;
if (skipOver) {
if (update.OffsetBasedSize != -1)
destinationPosition += update.OffsetBasedSize;
else
// TODO: Find out why this calculation comes up 4 bytes short on some entries in ODT (Office Document Text) archives.
// WinZip produces a warning on these entries:
// "caution: value of lrec.csize (compressed size) changed from ..."
destinationPosition +=
(sourcePosition - entryDataOffset) + NameLengthOffset + // Header size
update.Entry.CompressedSize + GetDescriptorSize(update);
}
else {
if ( update.Entry.CompressedSize > 0 ) {
CopyEntryDataDirect(update, baseStream_, false, ref destinationPosition, ref sourcePosition );
}
CopyDescriptorBytesDirect(update, baseStream_, ref destinationPosition, sourcePosition);
}
}