From 3f583916719eeef598d10a5d4e14ef14f008243b Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Tue, 11 May 2021 07:36:37 -0700 Subject: Merge Dtf --- .../WixToolset.Dtf.Compression.Zip/ZipFileInfo.cs | 104 +++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 src/dtf/WixToolset.Dtf.Compression.Zip/ZipFileInfo.cs (limited to 'src/dtf/WixToolset.Dtf.Compression.Zip/ZipFileInfo.cs') diff --git a/src/dtf/WixToolset.Dtf.Compression.Zip/ZipFileInfo.cs b/src/dtf/WixToolset.Dtf.Compression.Zip/ZipFileInfo.cs new file mode 100644 index 00000000..d865bbba --- /dev/null +++ b/src/dtf/WixToolset.Dtf.Compression.Zip/ZipFileInfo.cs @@ -0,0 +1,104 @@ +// 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); + } + } +} -- cgit v1.2.3-55-g6feb