// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. namespace WixToolset.Dtf.Compression.Zip { using System; using System.IO; using System.Runtime.Serialization; /// /// Object representing a compressed file within a zip package; provides operations for getting /// the file properties and extracting the file. /// [Serializable] public class ZipFileInfo : ArchiveFileInfo { private long compressedLength; private ZipCompressionMethod compressionMethod; /// /// Creates a new ZipFileInfo object representing a file within a zip in a specified path. /// /// An object representing the zip archive containing the file. /// The path to the file within the zip archive. Usually, this is a simple file /// name, but if the zip archive contains a directory structure this may include the directory. public ZipFileInfo(ZipInfo zipInfo, string filePath) : base(zipInfo, filePath) { if (zipInfo == null) { throw new ArgumentNullException("zipInfo"); } } /// /// Creates a new ZipFileInfo object with all parameters specified, /// used internally when reading the metadata out of a zip archive. /// /// The internal path and name of the file in the zip archive. /// The zip archive number where the file starts. /// The stored attributes of the file. /// The stored last write time of the file. /// The uncompressed size of the file. /// The compressed size of the file. /// Compression algorithm used for this file. internal ZipFileInfo( string filePath, int zipNumber, FileAttributes attributes, DateTime lastWriteTime, long length, long compressedLength, ZipCompressionMethod compressionMethod) : base(filePath, zipNumber, attributes, lastWriteTime, length) { this.compressedLength = compressedLength; this.compressionMethod = compressionMethod; } /// /// Initializes a new instance of the ZipFileInfo class with serialized data. /// /// The SerializationInfo that holds the serialized object data about the exception being thrown. /// The StreamingContext that contains contextual information about the source or destination. protected ZipFileInfo(SerializationInfo info, StreamingContext context) : base(info, context) { this.compressedLength = info.GetInt64("compressedLength"); } /// /// Gets the compressed size of the file in bytes. /// public long CompressedLength { get { return this.compressedLength; } } /// /// Gets the method used to compress this file. /// public ZipCompressionMethod CompressionMethod { get { return this.compressionMethod; } } /// /// Sets the SerializationInfo with information about the archive. /// /// The SerializationInfo that holds the serialized object data. /// The StreamingContext that contains contextual information /// about the source or destination. public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); info.AddValue("compressedLength", this.compressedLength); } } }