internal static ZipIOLocalFileHeader CreateNew(string fileName, Encoding encoding, CompressionMethodEnum compressionMethod, DeflateOptionEnum deflateOption, bool streaming) { byte[] bytes = encoding.GetBytes(fileName); if (bytes.Length > ZipIOBlockManager.MaxFileNameSize) { throw new ArgumentOutOfRangeException("fileName"); } ZipIOLocalFileHeader header = new ZipIOLocalFileHeader(); header._signature = 0x4034b50; header._compressionMethod = (ushort)compressionMethod; if (streaming) { header._versionNeededToExtract = 0x2d; } else { header._versionNeededToExtract = (ushort)ZipIOBlockManager.CalcVersionNeededToExtractFromCompression(compressionMethod); } if (compressionMethod != CompressionMethodEnum.Stored) { header.DeflateOption = deflateOption; } if (streaming) { header.StreamingCreationFlag = true; } header._lastModFileDateTime = ZipIOBlockManager.ToMsDosDateTime(DateTime.Now); header._fileNameLength = (ushort)bytes.Length; header._fileName = bytes; header._extraField = ZipIOExtraField.CreateNew(!streaming); header._extraFieldLength = header._extraField.Size; header._stringFileName = fileName; return(header); }
internal void UpdateZip64Structures(long compressedSize, long uncompressedSize, long offset) { if (((compressedSize >= 0xffffffffL) || (uncompressedSize >= 0xffffffffL)) || (offset >= 0xffffffffL)) { this._extraField.CompressedSize = compressedSize; this._extraField.UncompressedSize = uncompressedSize; this._compressedSize = uint.MaxValue; this._uncompressedSize = uint.MaxValue; this._versionNeededToExtract = 0x2d; } else { this._compressedSize = (uint)compressedSize; this._uncompressedSize = (uint)uncompressedSize; this._extraField.Zip64ExtraFieldUsage = ZipIOZip64ExtraFieldUsage.None; this._versionNeededToExtract = (ushort)ZipIOBlockManager.CalcVersionNeededToExtractFromCompression(this.CompressionMethod); } }
private void UpdateZip64Structures(long compressedSize, long uncompressedSize, long offset) { if (((compressedSize >= 0xffffffffL) || (uncompressedSize >= 0xffffffffL)) || (offset >= 0xffffffffL)) { this._extraField.CompressedSize = compressedSize; this._extraField.UncompressedSize = uncompressedSize; this._extraField.OffsetOfLocalHeader = offset; this._compressedSize = uint.MaxValue; this._uncompressedSize = uint.MaxValue; this._relativeOffsetOfLocalHeader = uint.MaxValue; this._versionNeededToExtract = 0x2d; } else { this._compressedSize = (uint)compressedSize; this._uncompressedSize = (uint)uncompressedSize; this._relativeOffsetOfLocalHeader = (uint)offset; this._extraField.Zip64ExtraFieldUsage = ZipIOZip64ExtraFieldUsage.None; this._versionNeededToExtract = (ushort)ZipIOBlockManager.CalcVersionNeededToExtractFromCompression((CompressionMethodEnum)this._compressionMethod); } }