Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ WriteLocalFileHeader()

bool System.IO.Compression.ZipArchiveEntry.WriteLocalFileHeader ( bool isEmptyFile)
inlineprivate

Definition at line 812 of file ZipArchiveEntry.cs.

813 {
814 BinaryWriter binaryWriter = new BinaryWriter(_archive.ArchiveStream);
815 Zip64ExtraField zip64ExtraField = default(Zip64ExtraField);
816 bool flag = false;
817 uint value;
818 uint value2;
819 if (isEmptyFile)
820 {
821 CompressionMethod = CompressionMethodValues.Stored;
822 value = 0u;
823 value2 = 0u;
824 }
825 else if (_archive.Mode == ZipArchiveMode.Create && !_archive.ArchiveStream.CanSeek && !isEmptyFile)
826 {
827 _generalPurposeBitFlag |= BitFlagValues.DataDescriptor;
828 flag = false;
829 value = 0u;
830 value2 = 0u;
831 }
832 else
833 {
834 _generalPurposeBitFlag &= ~BitFlagValues.DataDescriptor;
835 if (SizesTooLarge())
836 {
837 flag = true;
838 value = uint.MaxValue;
839 value2 = uint.MaxValue;
840 zip64ExtraField.CompressedSize = _compressedSize;
841 zip64ExtraField.UncompressedSize = _uncompressedSize;
842 VersionToExtractAtLeast(ZipVersionNeededValues.Zip64);
843 }
844 else
845 {
846 flag = false;
847 value = (uint)_compressedSize;
849 }
850 }
851 _offsetOfLocalHeader = binaryWriter.BaseStream.Position;
852 int num = (flag ? zip64ExtraField.TotalSize : 0) + ((_lhUnknownExtraFields != null) ? ZipGenericExtraField.TotalSize(_lhUnknownExtraFields) : 0);
853 ushort value3;
854 if (num > 65535)
855 {
856 value3 = (ushort)(flag ? zip64ExtraField.TotalSize : 0);
858 }
859 else
860 {
861 value3 = (ushort)num;
862 }
863 binaryWriter.Write(67324752u);
864 binaryWriter.Write((ushort)_versionToExtract);
866 binaryWriter.Write((ushort)CompressionMethod);
867 binaryWriter.Write(ZipHelper.DateTimeToDosTime(_lastModified.DateTime));
868 binaryWriter.Write(_crc32);
869 binaryWriter.Write(value);
870 binaryWriter.Write(value2);
871 binaryWriter.Write((ushort)_storedEntryNameBytes.Length);
872 binaryWriter.Write(value3);
874 if (flag)
875 {
877 }
878 if (_lhUnknownExtraFields != null)
879 {
880 ZipGenericExtraField.WriteAllBlocks(_lhUnknownExtraFields, _archive.ArchiveStream);
881 }
882 return flag;
883 }
void VersionToExtractAtLeast(ZipVersionNeededValues value)
List< ZipGenericExtraField > _lhUnknownExtraFields
CompressionMethodValues CompressionMethod

References System.IO.Compression.ZipArchiveEntry._archive, System.IO.Compression.ZipArchiveEntry._compressedSize, System.IO.Compression.ZipArchiveEntry._crc32, System.IO.Compression.ZipArchiveEntry._generalPurposeBitFlag, System.IO.Compression.ZipArchiveEntry._lastModified, System.IO.Compression.ZipArchiveEntry._lhUnknownExtraFields, System.IO.Compression.ZipArchiveEntry._offsetOfLocalHeader, System.IO.Compression.ZipArchiveEntry._storedEntryNameBytes, System.IO.Compression.ZipArchiveEntry._uncompressedSize, System.IO.Compression.ZipArchiveEntry._versionToExtract, System.IO.Compression.ZipArchive.ArchiveStream, System.IO.Stream.CanSeek, System.IO.Compression.ZipArchiveEntry.CompressionMethod, System.DateTimeOffset.DateTime, System.IO.Compression.ZipHelper.DateTimeToDosTime(), System.IO.Compression.ZipArchive.Mode, System.IO.Compression.ZipArchiveEntry.SizesTooLarge(), System.IO.Compression.ZipGenericExtraField.TotalSize(), System.value, System.IO.Compression.ZipArchiveEntry.VersionToExtractAtLeast(), and System.IO.Compression.ZipGenericExtraField.WriteAllBlocks().

Referenced by System.IO.Compression.ZipArchiveEntry.DirectToArchiveWriterStream.Dispose(), System.IO.Compression.ZipArchiveEntry.DirectToArchiveWriterStream.Write(), System.IO.Compression.ZipArchiveEntry.DirectToArchiveWriterStream.Write(), System.IO.Compression.ZipArchiveEntry.DirectToArchiveWriterStream.WriteAsync(), and System.IO.Compression.ZipArchiveEntry.WriteLocalFileHeaderAndDataIfNeeded().