public Delete ( int headerID ) : bool | ||
headerID | int | The identifier of the field to delete. |
return | bool |
public bool Delete(int headerID) {
bool result=false;
if (Find(headerID)) {
result=true;
int trueStart=_readValueStart-4;
var newData=new byte[_data.Length-(ValueLength+4)];
Array.Copy(_data, 0, newData, 0, trueStart);
int trueEnd=trueStart+ValueLength+4;
Array.Copy(_data, trueEnd, newData, trueStart, _data.Length-trueEnd);
_data=newData;
}
return result;
}
private void WriteLocalHeader(ZipEntry entry, EntryPatchData patchData) { CompressionMethod compressionMethod = entry.CompressionMethod; bool flag = true; bool flag2 = false; this.WriteLEInt(67324752); this.WriteLEShort(entry.Version); this.WriteLEShort(entry.Flags); this.WriteLEShort((int)((byte)compressionMethod)); this.WriteLEInt((int)entry.DosTime); if (flag) { this.WriteLEInt((int)entry.Crc); if (entry.LocalHeaderRequiresZip64) { this.WriteLEInt(-1); this.WriteLEInt(-1); } else { this.WriteLEInt((!entry.IsCrypted) ? ((int)entry.CompressedSize) : ((int)entry.CompressedSize + 12)); this.WriteLEInt((int)entry.Size); } } else { if (patchData != null) { patchData.CrcPatchOffset = this.stream_.Position; } this.WriteLEInt(0); if (patchData != null) { patchData.SizePatchOffset = this.stream_.Position; } if (entry.LocalHeaderRequiresZip64 && flag2) { this.WriteLEInt(-1); this.WriteLEInt(-1); } else { this.WriteLEInt(0); this.WriteLEInt(0); } } byte[] array = ZipConstants.ConvertToArray(entry.Flags, entry.Name); if (array.Length > 65535) { throw new Exception("Entry name too long."); } ZipExtraData zipExtraData = new ZipExtraData(entry.ExtraData); if (entry.LocalHeaderRequiresZip64 && (flag || flag2)) { zipExtraData.StartNewEntry(); if (flag) { zipExtraData.AddLeLong(entry.Size); zipExtraData.AddLeLong(entry.CompressedSize); } else { zipExtraData.AddLeLong(-1L); zipExtraData.AddLeLong(-1L); } zipExtraData.AddNewEntry(1); if (!zipExtraData.Find(1)) { throw new Exception("Internal error cant find extra data"); } if (patchData != null) { patchData.SizePatchOffset = (long)zipExtraData.CurrentReadIndex; } } else { zipExtraData.Delete(1); } byte[] entryData = zipExtraData.GetEntryData(); this.WriteLEShort(array.Length); this.WriteLEShort(entryData.Length); if (array.Length > 0) { this.stream_.Write(array, 0, array.Length); } if (entry.LocalHeaderRequiresZip64 && flag2) { patchData.SizePatchOffset += this.stream_.Position; } if (entryData.Length > 0) { this.stream_.Write(entryData, 0, entryData.Length); } }