Exemplo n.º 1
0
 private void AddEntry(ZipFile workFile, ZipUpdate update)
 {
     Stream source = null;
     if (update.Entry.IsFile)
     {
         source = update.GetSource();
         if (source == null)
         {
             source = updateDataSource_.GetSource(update.Entry, update.Filename);
         }
     }
     if (source != null)
     {
         using (source)
         {
             long length = source.Length;
             if (update.OutEntry.Size < 0L)
             {
                 update.OutEntry.Size = length;
             }
             else if (update.OutEntry.Size != length)
             {
                 throw new ZipException("Entry size/stream size mismatch");
             }
             workFile.WriteLocalEntryHeader(update);
             long position = workFile.baseStream_.Position;
             using (Stream stream2 = workFile.GetOutputStream(update.OutEntry))
             {
                 CopyBytes(update, stream2, source, length, true);
             }
             long num3 = workFile.baseStream_.Position;
             update.OutEntry.CompressedSize = num3 - position;
             if ((update.OutEntry.Flags & 8) == 8)
             {
                 new ZipHelperStream(workFile.baseStream_).WriteDataDescriptor(update.OutEntry);
             }
             return;
         }
     }
     workFile.WriteLocalEntryHeader(update);
     update.OutEntry.CompressedSize = 0L;
 }
Exemplo n.º 2
0
 private void CopyEntryDirect(ZipFile workFile, ZipUpdate update, ref long destinationPosition)
 {
     bool flag = false;
     if (update.Entry.Offset == destinationPosition)
     {
         flag = true;
     }
     if (!flag)
     {
         baseStream_.Position = destinationPosition;
         workFile.WriteLocalEntryHeader(update);
         destinationPosition = baseStream_.Position;
     }
     long offset = update.Entry.Offset + 0x1aL;
     baseStream_.Seek(offset, SeekOrigin.Begin);
     uint num3 = ReadLEUshort();
     uint num4 = ReadLEUshort();
     long sourcePosition = (baseStream_.Position + num3) + num4;
     if (flag)
     {
         if (update.OffsetBasedSize != -1L)
         {
             destinationPosition += update.OffsetBasedSize;
         }
         else
         {
             destinationPosition += (((sourcePosition - offset) + 0x1aL) + update.Entry.CompressedSize) + GetDescriptorSize(update);
         }
     }
     else
     {
         if (update.Entry.CompressedSize > 0L)
         {
             CopyEntryDataDirect(update, baseStream_, false, ref destinationPosition, ref sourcePosition);
         }
         CopyDescriptorBytesDirect(update, baseStream_, ref destinationPosition, sourcePosition);
     }
 }
Exemplo n.º 3
0
 private void ModifyEntry(ZipFile workFile, ZipUpdate update)
 {
     workFile.WriteLocalEntryHeader(update);
     long position = workFile.baseStream_.Position;
     if (update.Entry.IsFile && (update.Filename != null))
     {
         using (Stream stream = workFile.GetOutputStream(update.OutEntry))
         {
             using (Stream stream2 = GetInputStream(update.Entry))
             {
                 CopyBytes(update, stream, stream2, stream2.Length, true);
             }
         }
     }
     long num2 = workFile.baseStream_.Position;
     update.Entry.CompressedSize = num2 - position;
 }
Exemplo n.º 4
0
 private void CopyEntry(ZipFile workFile, ZipUpdate update)
 {
     workFile.WriteLocalEntryHeader(update);
     if (update.Entry.CompressedSize > 0L)
     {
         long offset = update.Entry.Offset + 0x1aL;
         baseStream_.Seek(offset, SeekOrigin.Begin);
         uint num2 = ReadLEUshort();
         uint num3 = ReadLEUshort();
         baseStream_.Seek(num2 + num3, SeekOrigin.Current);
         CopyBytes(update, workFile.baseStream_, baseStream_, update.Entry.CompressedSize, false);
     }
     CopyDescriptorBytes(update, workFile.baseStream_, baseStream_);
 }