private bool WriteLocalFileHeader(bool isEmptyFile) { BinaryWriter binaryWriter = new BinaryWriter(this._archive.ArchiveStream); Zip64ExtraField zip64ExtraField = new Zip64ExtraField(); bool flag = false; uint num1; uint num2; if (isEmptyFile) { this.CompressionMethod = ZipArchiveEntry.CompressionMethodValues.Stored; num1 = 0U; num2 = 0U; } else if (this._archive.Mode == ZipArchiveMode.Create && !this._archive.ArchiveStream.CanSeek && !isEmptyFile) { this._generalPurposeBitFlag = this._generalPurposeBitFlag | ZipArchiveEntry.BitFlagValues.DataDescriptor; flag = false; num1 = 0U; num2 = 0U; } else if (this.SizesTooLarge()) { flag = true; num1 = uint.MaxValue; num2 = uint.MaxValue; zip64ExtraField.CompressedSize = new long?(this._compressedSize); zip64ExtraField.UncompressedSize = new long?(this._uncompressedSize); this.VersionToExtractAtLeast(ZipVersionNeededValues.Zip64); } else { flag = false; num1 = (uint)this._compressedSize; num2 = (uint)this._uncompressedSize; } this._offsetOfLocalHeader = binaryWriter.BaseStream.Position; int num3 = (flag ? (int)zip64ExtraField.TotalSize : 0) + (this._lhUnknownExtraFields != null ? ZipGenericExtraField.TotalSize(this._lhUnknownExtraFields) : 0); ushort num4; if (num3 > (int)ushort.MaxValue) { num4 = flag ? zip64ExtraField.TotalSize : (ushort)0; this._lhUnknownExtraFields = null; } else { num4 = (ushort)num3; } binaryWriter.Write(67324752U); binaryWriter.Write((ushort)this._versionToExtract); binaryWriter.Write((ushort)this._generalPurposeBitFlag); binaryWriter.Write((ushort)this.CompressionMethod); binaryWriter.Write(ZipHelper.DateTimeToDosTime(this._lastModified.DateTime)); binaryWriter.Write(this._crc32); binaryWriter.Write(num1); binaryWriter.Write(num2); binaryWriter.Write((ushort)this._storedEntryNameBytes.Length); binaryWriter.Write(num4); binaryWriter.Write(this._storedEntryNameBytes); if (flag) { zip64ExtraField.WriteBlock(this._archive.ArchiveStream); } if (this._lhUnknownExtraFields != null) { ZipGenericExtraField.WriteAllBlocks(this._lhUnknownExtraFields, this._archive.ArchiveStream); } return(flag); }
internal void WriteCentralDirectoryFileHeader() { BinaryWriter binaryWriter = new BinaryWriter(this._archive.ArchiveStream); Zip64ExtraField zip64ExtraField = new Zip64ExtraField(); bool flag = false; uint num1; uint num2; if (this.SizesTooLarge()) { flag = true; num1 = uint.MaxValue; num2 = uint.MaxValue; zip64ExtraField.CompressedSize = new long?(this._compressedSize); zip64ExtraField.UncompressedSize = new long?(this._uncompressedSize); } else { num1 = (uint)this._compressedSize; num2 = (uint)this._uncompressedSize; } uint num3; if (this._offsetOfLocalHeader > (long)uint.MaxValue) { flag = true; num3 = uint.MaxValue; zip64ExtraField.LocalHeaderOffset = new long?(this._offsetOfLocalHeader); } else { num3 = (uint)this._offsetOfLocalHeader; } if (flag) { this.VersionToExtractAtLeast(ZipVersionNeededValues.Zip64); } int num4 = (flag ? (int)zip64ExtraField.TotalSize : 0) + (this._cdUnknownExtraFields != null ? ZipGenericExtraField.TotalSize(this._cdUnknownExtraFields) : 0); ushort num5; if (num4 > (int)ushort.MaxValue) { num5 = flag ? zip64ExtraField.TotalSize : (ushort)0; this._cdUnknownExtraFields = null; } else { num5 = (ushort)num4; } binaryWriter.Write(33639248U); binaryWriter.Write((ushort)this._versionToExtract); binaryWriter.Write((ushort)this._versionToExtract); binaryWriter.Write((ushort)this._generalPurposeBitFlag); binaryWriter.Write((ushort)this.CompressionMethod); binaryWriter.Write(ZipHelper.DateTimeToDosTime(this._lastModified.DateTime)); binaryWriter.Write(this._crc32); binaryWriter.Write(num1); binaryWriter.Write(num2); binaryWriter.Write((ushort)this._storedEntryNameBytes.Length); binaryWriter.Write(num5); binaryWriter.Write(this._fileComment != null ? (ushort)this._fileComment.Length : (ushort)0); binaryWriter.Write((ushort)0); binaryWriter.Write((ushort)0); binaryWriter.Write((uint)this._externalFileAttributes); binaryWriter.Write(num3); binaryWriter.Write(this._storedEntryNameBytes); if (flag) { zip64ExtraField.WriteBlock(this._archive.ArchiveStream); } if (this._cdUnknownExtraFields != null) { ZipGenericExtraField.WriteAllBlocks(this._cdUnknownExtraFields, this._archive.ArchiveStream); } if (this._fileComment != null) { binaryWriter.Write(this._fileComment); } }