// 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 { using System; using System.IO; /// /// This interface provides the methods necessary for the to open /// and close streams for archives and files. The implementor of this interface can use any /// kind of logic to determine what kind of streams to open and where /// public interface IUnpackStreamContext { /// /// Opens the archive stream for reading. /// /// The zero-based index of the archive to open. /// The name of the archive being opened. /// Instance of the compression engine doing the operations. /// A stream from which archive bytes are read, or null to cancel extraction /// of the archive. /// /// When the first archive in a chain is opened, the name is not yet known, so the /// provided value will be an empty string. When opening further archives, the /// provided value is the next-archive name stored in the previous archive. This /// name is often, but not necessarily, the same as the filename of the archive /// package to be opened. /// If this method returns null, the archive engine will throw a /// FileNotFoundException. /// Stream OpenArchiveReadStream(int archiveNumber, string archiveName, CompressionEngine compressionEngine); /// /// Closes a stream where an archive package was read. /// /// The archive number of the stream to close. /// The name of the archive being closed. /// The stream that was previously returned by /// and is now ready to be closed. void CloseArchiveReadStream(int archiveNumber, string archiveName, Stream stream); /// /// Opens a stream for writing extracted file bytes. /// /// The path of the file within the archive. This is often, but /// not necessarily, the same as the relative path of the file outside the archive. /// The uncompressed size of the file to be extracted. /// The last write time of the file to be extracted. /// A stream where extracted file bytes are to be written, or null to skip /// extraction of the file and continue to the next file. /// /// The implementor may use the path, size and date information to dynamically /// decide whether or not the file should be extracted. /// Stream OpenFileWriteStream(string path, long fileSize, DateTime lastWriteTime); /// /// Closes a stream where an extracted file was written. /// /// The path of the file within the archive. /// The stream that was previously returned by /// and is now ready to be closed. /// The attributes of the extracted file. /// The last write time of the file. /// /// The implementor may wish to apply the attributes and date to the newly-extracted file. /// void CloseFileWriteStream(string path, Stream stream, FileAttributes attributes, DateTime lastWriteTime); } }