public ZipWritingStream(ZipWriter writer, Stream originalStream, ZipCentralDirectoryEntry entry, CompressionInfo compressionInfo) { this.writer = writer; this.entry = entry; this.compressionInfo = compressionInfo == null ? writer.zipCompressionInfo : new ZipCompressionInfo(compressionInfo); writeStream = GetWriteStream(originalStream); }
internal ZipWritingStream(ZipWriter writer, Stream originalStream, ZipCentralDirectoryEntry entry) { this.writer = writer; this.originalStream = originalStream; writeStream = GetWriteStream(originalStream); this.writer = writer; this.entry = entry; }
public Stream WriteToStream(string entryPath, DateTime?modificationTime, string comment, string password = null, Crc32?crc = null, CompressionInfo compressionInfo = null) { entryPath = NormalizeFilename(entryPath); modificationTime = modificationTime ?? DateTime.Now; comment = comment ?? string.Empty; var explicitPassword = password ?? this.password; bool doEncryption = !String.IsNullOrEmpty(explicitPassword); var entry = new ZipCentralDirectoryEntry() { Comment = comment, FileName = entryPath, ModificationTime = modificationTime, HeaderOffset = (uint)streamPosition, IsEncrypted = doEncryption }; var headersize = (uint)WriteHeader(entryPath, modificationTime, doEncryption, compressionInfo); Stream outputStream; if (doEncryption) { byte[] encryptionHeader; PkwareTraditionalEncryptionData pkwareTraditionalEncryptionData; if (OutputStream.CanSeek) { if (crc.HasValue) { pkwareTraditionalEncryptionData = PkwareTraditionalEncryptionData.ForWrite(explicitPassword, (uint)(int)crc, out encryptionHeader); } else { throw new ArgumentNullException(nameof(crc), "Crc32 must be provided when password is set and target archive stream supports seeking"); } } else { pkwareTraditionalEncryptionData = PkwareTraditionalEncryptionData.ForWrite(explicitPassword, modificationTime, out encryptionHeader); } OutputStream.Write(encryptionHeader, 0, encryptionHeader.Length); entry.Compressed += (uint)encryptionHeader.Length; outputStream = new PkwareTraditionalCryptoStream(OutputStream, pkwareTraditionalEncryptionData, CryptoMode.Encrypt); } else { outputStream = OutputStream; } streamPosition += headersize; return(new ZipWritingStream(this, outputStream, entry, compressionInfo)); }
public Stream WriteToStream(string entryPath, DateTime? modificationTime, string comment, CompressionInfo compressionInfo) { entryPath = this.NormalizeFilename(entryPath); DateTime? nullable = modificationTime; modificationTime = new DateTime?(nullable.HasValue ? nullable.GetValueOrDefault() : DateTime.Now); comment = comment ?? ""; ZipCentralDirectoryEntry entry2 = new ZipCentralDirectoryEntry(); entry2.Comment = comment; entry2.FileName = entryPath; entry2.ModificationTime = modificationTime; entry2.HeaderOffset = (uint) this.streamPosition; ZipCentralDirectoryEntry entry = entry2; uint num = (uint) this.WriteHeader(entryPath, modificationTime, compressionInfo); this.streamPosition += num; return new ZipWritingStream(this, base.OutputStream, entry); }
public Stream WriteToStream(string entryPath, DateTime?modificationTime, string comment) { entryPath = NormalizeFilename(entryPath); modificationTime = modificationTime ?? DateTime.Now; comment = comment ?? ""; var entry = new ZipCentralDirectoryEntry { Comment = comment, FileName = entryPath, ModificationTime = modificationTime, HeaderOffset = (uint)streamPosition, }; var headersize = (uint)WriteHeader(entryPath, modificationTime); streamPosition += headersize; return(new ZipWritingStream(this, OutputStream, entry)); }
public Stream WriteToStream(string entryPath, DateTime? modificationTime, string comment, CompressionInfo compressionInfo = null) { entryPath = NormalizeFilename(entryPath); modificationTime = modificationTime ?? DateTime.Now; comment = comment ?? ""; var entry = new ZipCentralDirectoryEntry { Comment = comment, FileName = entryPath, ModificationTime = modificationTime, HeaderOffset = (uint) streamPosition, }; var headersize = (uint)WriteHeader(entryPath, modificationTime, compressionInfo); streamPosition += headersize; return new ZipWritingStream(this, OutputStream, entry, compressionInfo); }
public Stream WriteToStream(string entryPath, DateTime?modificationTime, string comment, CompressionInfo compressionInfo) { entryPath = this.NormalizeFilename(entryPath); DateTime?nullable = modificationTime; modificationTime = new DateTime?(nullable.HasValue ? nullable.GetValueOrDefault() : DateTime.Now); comment = comment ?? ""; ZipCentralDirectoryEntry entry2 = new ZipCentralDirectoryEntry(); entry2.Comment = comment; entry2.FileName = entryPath; entry2.ModificationTime = modificationTime; entry2.HeaderOffset = (uint)this.streamPosition; ZipCentralDirectoryEntry entry = entry2; uint num = (uint)this.WriteHeader(entryPath, modificationTime, compressionInfo); this.streamPosition += num; return(new ZipWritingStream(this, base.OutputStream, entry)); }
internal ZipWritingStream(ZipWriter writer, Stream originalStream, ZipCentralDirectoryEntry entry, CompressionInfo compressionInfo) { this.writer = writer; this.originalStream = originalStream; this.writer = writer; this.entry = entry; this.compressionInfo = compressionInfo == null ? writer.zipCompressionInfo : new ZipCompressionInfo(compressionInfo); writeStream = GetWriteStream(originalStream); }