public ZipArchive( Stream stream, ZipArchiveMode mode, bool leaveOpen, Encoding entryNameEncoding, CompressionSettings compressionSettings, EncryptionSettings encryptionSettings) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } this.EntryNameEncoding = entryNameEncoding; if (compressionSettings == null) { compressionSettings = (CompressionSettings) new DeflateSettings() { HeaderType = CompressedStreamHeader.None } } ; this.CompressionSettings = compressionSettings; this.CompressionSettings.PrepareForZip((CentralDirectoryHeader)null); this.EncryptionSettings = encryptionSettings; this.Init(stream, mode, leaveOpen); } ~ZipArchive() { this.Dispose(false); }
internal ZipArchiveEntry(ZipArchive archive, string entryName, CompressionSettings settings) : this(archive, entryName) { this.settings = settings; this.settings.PrepareForZip((CentralDirectoryHeader)null); this.CompressionMethod = settings.Method; }
internal static CompressionSettings GetCompressionSettings( CompressionMethod method, CompressionSettings baseSettings) { CompressionSettings compressionSettings; switch (method) { case CompressionMethod.Stored: compressionSettings = (CompressionSettings) new StoreSettings(); break; case CompressionMethod.Deflate: compressionSettings = (CompressionSettings) new DeflateSettings(); break; case CompressionMethod.Lzma: compressionSettings = (CompressionSettings) new LzmaSettings(); break; default: throw new NotSupportedException(string.Format("Compression method {0} is not supported.", (object)method)); } if (baseSettings != null && (object)compressionSettings.GetType() == (object)baseSettings.GetType()) { compressionSettings.CopyFrom(baseSettings); } return(compressionSettings); }
internal static ICompressionAlgorithm GetCompressionAlgorithm( CompressionSettings settings) { ICompressionAlgorithm compressionAlgorithm; switch (settings.Method) { case CompressionMethod.Stored: compressionAlgorithm = (ICompressionAlgorithm) new StoreAlgorithm(); break; case CompressionMethod.Deflate: compressionAlgorithm = (ICompressionAlgorithm) new DeflateAlgorithm(); break; case CompressionMethod.Lzma: compressionAlgorithm = (ICompressionAlgorithm) new LzmaAlgorithm(); break; default: throw new NotSupportedException(string.Format("Compression method {0} is not supported.", (object)settings)); } compressionAlgorithm?.Initialize(settings); return(compressionAlgorithm); }
public CompressedStream( Stream baseStream, StreamOperationMode mode, CompressionSettings settings) : this(baseStream, mode, settings, true, (EncryptionSettings)null) { }
public void Initialize(CompressionSettings settings) { this.deflateSettings = settings as DeflateSettings; if (this.deflateSettings == null) { throw new ArgumentException("Wrong settings type."); } }
internal ZipArchiveEntry(ZipArchive archive, CentralDirectoryHeader header) { this.Archive = archive; this.header = header; this.settings = ZipHelper.GetCompressionSettings((CompressionMethod)this.header.CompressionMethod, this.Archive.CompressionSettings); this.settings.PrepareForZip((CentralDirectoryHeader)null); this.existedInArchive = true; }
public ZipArchiveEntry CreateEntry( string entryName, CompressionSettings settings) { ZipArchiveEntry zipArchiveEntry = new ZipArchiveEntry(this, entryName, settings); this.entries.Add(zipArchiveEntry.FullName, zipArchiveEntry); return(zipArchiveEntry); }
public CompressedStream( Stream baseStream, StreamOperationMode mode, CompressionSettings settings, bool useCrc32, EncryptionSettings encryptionSettings) : base(baseStream, mode) { baseStream = encryptionSettings != null ? (Stream) new CryptoStream(baseStream, mode, PlatformSettings.Manager.GetCryptoProvider(encryptionSettings)) : baseStream; ICompressionAlgorithm compressionAlgorithm = ZipHelper.GetCompressionAlgorithm(settings); IChecksumAlgorithm checksumAlgorithm = useCrc32 ? (IChecksumAlgorithm) new Crc32() : (IChecksumAlgorithm) new Adler32(); this.Initialize(baseStream, compressionAlgorithm, checksumAlgorithm); }
internal ZipArchiveEntry(ZipArchive archive, string entryName) { this.Archive = archive; this.settings = this.Archive.CompressionSettings; this.header = new CentralDirectoryHeader(); this.header.VersionNeededToExtract = (ushort)10; this.header.GeneralPurposeBitFlag = (ushort)8; if (this.Archive.EncryptionSettings is DefaultEncryptionSettings) { this.header.GeneralPurposeBitFlag |= (ushort)1; this.ValidateVersionNeeded(VersionNeededToExtract.Deflate); } this.FullName = entryName; this.LastWriteTime = DateTimeOffset.Now; }
internal virtual void CopyFrom(CompressionSettings baseSettings) { }