Skip to content

ArchiveFileStreamContext Class

Provides a basic implementation of the archive pack and unpack stream context interfaces, based on a list of archive files, a default directory, and an optional mapping from internal to external file paths.

MethodDescription
CloseArchiveReadStream(archiveNumber, archiveName, stream)Closes a stream where an archive was read.
CloseArchiveWriteStream(archiveNumber, archiveName, stream)Closes a stream where an archive package was written.
CloseFileReadStream(path, stream)Closes a stream that has been used to read a file.
CloseFileWriteStream(path, stream, attributes, lastWriteTime)Closes a stream where an extracted file was written.
GetArchiveName(archiveNumber)Gets the name of the archive with a specified number.
GetOption(optionName, parameters)Gets extended parameter information specific to the compression format being used.
OpenArchiveReadStream(archiveNumber, archiveName, compressionEngine)Opens the archive stream for reading.
OpenArchiveWriteStream(archiveNumber, archiveName, truncate, compressionEngine)Opens a stream for writing an archive.
OpenFileWriteStream(path, fileSize, lastWriteTime)Opens a stream for writing extracted file bytes.
PropertyDescription
ArchiveFilesGets or sets the list of archive files that are created or extracted.
DirectoryGets or sets the default root directory where files are located.
EnableOffsetOpenGets or sets a flag that enables creating or extracting an archive at an offset within an existing file. (This is typically used to open archive-based self-extracting packages.)
ExtractOnlyNewerFilesGets or sets a flag that can prevent extracted files from overwriting newer files that already exist.
FilesGets or sets the mapping from internal file paths to external file paths.

This class can also handle creating or extracting chained archive packages. WixToolset.Dtf.Compression.dll version 5.0.0+41e11442b2ca93e444b60213b5ae99dcbab787d8

CloseArchiveReadStream(archiveNumber, archiveName, stream) Method

Section titled “CloseArchiveReadStream(archiveNumber, archiveName, stream) Method”

Closes a stream where an archive was read.

public void CloseArchiveReadStream(
int archiveNumber,
string archiveName,
System.IO.Stream stream
)
ParameterTypeDescription
archiveNumberintThe archive number of the stream to close.
archiveNamestringThe name of the archive being closed.
streamSystem.IO.StreamThe stream that was previously returned by and is now ready to be closed.

CloseArchiveWriteStream(archiveNumber, archiveName, stream) Method

Section titled “CloseArchiveWriteStream(archiveNumber, archiveName, stream) Method”

Closes a stream where an archive package was written.

public void CloseArchiveWriteStream(
int archiveNumber,
string archiveName,
System.IO.Stream stream
)
ParameterTypeDescription
archiveNumberintThe 0-based index of the archive within the chain.
archiveNamestringThe name of the archive that was previously returned by .
streamSystem.IO.StreamA stream that was previously returned by and is now ready to be closed.

Closes a stream that has been used to read a file.

public void CloseFileReadStream(
string path,
System.IO.Stream stream
)
ParameterTypeDescription
pathstringThe path of the file within the archive; the same as the path provided when the stream was opened.
streamSystem.IO.StreamA stream that was previously returned by and is now ready to be closed.

CloseFileWriteStream(path, stream, attributes, lastWriteTime) Method

Section titled “CloseFileWriteStream(path, stream, attributes, lastWriteTime) Method”

Closes a stream where an extracted file was written.

public void CloseFileWriteStream(
string path,
System.IO.Stream stream,
System.IO.FileAttributes attributes,
System.DateTime lastWriteTime
)
ParameterTypeDescription
pathstringThe path of the file within the archive.
streamSystem.IO.StreamThe stream that was previously returned by and is now ready to be closed.
attributesSystem.IO.FileAttributesThe attributes of the extracted file.
lastWriteTimeSystem.DateTimeThe last write time of the file.

After closing the extracted file stream, this method applies the date and attributes to that file.

Gets the name of the archive with a specified number.

public string GetArchiveName(
int archiveNumber
)
ParameterTypeDescription
archiveNumberintThe 0-based index of the archive within the chain.

string The name of the requested archive. May be an empty string for non-chained archives, but may never be null.

This method returns the file name of the archive from the «see F:WixToolset.Dtf.Compression.ArchiveFileStreamContext.archiveFiles» list with the specified index, or an empty string if the archive number is outside the bounds of the list. The file name should not include any directory path.

Gets extended parameter information specific to the compression format being used.

public System.Object GetOption(
string optionName,
System.Object[] parameters
)
ParameterTypeDescription
optionNamestringName of the option being requested.
parametersSystem.Object[]Parameters for the option; for per-file options, the first parameter is typically the internal file path.

System.Object Option value, or null to use the default behavior.

This implementation does not handle any options. Subclasses may override this method to allow for non-default behavior.

OpenArchiveReadStream(archiveNumber, archiveName, compressionEngine) Method

Section titled “OpenArchiveReadStream(archiveNumber, archiveName, compressionEngine) Method”

Opens the archive stream for reading.

public System.IO.Stream OpenArchiveReadStream(
int archiveNumber,
string archiveName,
CompressionEngine compressionEngine
)
ParameterTypeDescription
archiveNumberintThe zero-based index of the archive to open.
archiveNamestringThe name of the archive being opened.
compressionEngineCompressionEngineInstance of the compression engine doing the operations.

System.IO.Stream A stream from which archive bytes are read, or null to cancel extraction of the archive.

This method opens the file from the «see P:WixToolset.Dtf.Compression.ArchiveFileStreamContext.ArchiveFiles» list with the specified index. If the archive number is outside the bounds of the list, this method returns null.If the «see P:WixToolset.Dtf.Compression.ArchiveFileStreamContext.EnableOffsetOpen» flag is set, this method will seek to the start of any existing archive in the file, or to the end of the file if the existing file is not an archive.

OpenArchiveWriteStream(archiveNumber, archiveName, truncate, compressionEngine) Method

Section titled “OpenArchiveWriteStream(archiveNumber, archiveName, truncate, compressionEngine) Method”

Opens a stream for writing an archive.

public System.IO.Stream OpenArchiveWriteStream(
int archiveNumber,
string archiveName,
bool truncate,
CompressionEngine compressionEngine
)
ParameterTypeDescription
archiveNumberintThe 0-based index of the archive within the chain.
archiveNamestringThe name of the archive that was returned by .
truncateboolTrue if the stream should be truncated when opened (if it already exists); false if an existing stream is being re-opened for writing additional data.
compressionEngineCompressionEngineInstance of the compression engine doing the operations.

System.IO.Stream A writable Stream where the compressed archive bytes will be written, or null to cancel the archive creation.

This method opens the file from the «see P:WixToolset.Dtf.Compression.ArchiveFileStreamContext.ArchiveFiles» list with the specified index. If the archive number is outside the bounds of the list, this method returns null.If the «see P:WixToolset.Dtf.Compression.ArchiveFileStreamContext.EnableOffsetOpen» flag is set, this method will seek to the start of any existing archive in the file, or to the end of the file if the existing file is not an archive.

OpenFileWriteStream(path, fileSize, lastWriteTime) Method

Section titled “OpenFileWriteStream(path, fileSize, lastWriteTime) Method”

Opens a stream for writing extracted file bytes.

public System.IO.Stream OpenFileWriteStream(
string path,
System.Int64 fileSize,
System.DateTime lastWriteTime
)
ParameterTypeDescription
pathstringThe path of the file within the archive.
fileSizeSystem.Int64The uncompressed size of the file to be extracted.
lastWriteTimeSystem.DateTimeThe last write time of the file to be extracted.

System.IO.Stream A stream where extracted file bytes are to be written, or null to skip extraction of the file and continue to the next file.

This method opens a file using the following logic:

  • If the «see P:WixToolset.Dtf.Compression.ArchiveFileStreamContext.Directory» and the «see P:WixToolset.Dtf.Compression.ArchiveFileStreamContext.Files» mapping are both null, the path is treated as relative to the current directory, and that file is opened.
  • If the «see P:WixToolset.Dtf.Compression.ArchiveFileStreamContext.Directory» is not null but the «see P:WixToolset.Dtf.Compression.ArchiveFileStreamContext.Files» mapping is null, the path is treated as relative to that directory, and that file is opened.
  • If the «see P:WixToolset.Dtf.Compression.ArchiveFileStreamContext.Directory» is null but the «see P:WixToolset.Dtf.Compression.ArchiveFileStreamContext.Files» mapping is not null, the path parameter is used as a key into the mapping, and the resulting value is the file path that is opened, relative to the current directory (or it may be an absolute path). If no mapping exists, the file is skipped.
  • If both the «see P:WixToolset.Dtf.Compression.ArchiveFileStreamContext.Directory» and the «see P:WixToolset.Dtf.Compression.ArchiveFileStreamContext.Files» mapping are specified, the path parameter is used as a key into the mapping, and the resulting value is the file path that is opened, relative to the specified directory (or it may be an absolute path). If no mapping exists, the file is skipped. If the «see P:WixToolset.Dtf.Compression.ArchiveFileStreamContext.ExtractOnlyNewerFiles» flag is set, the file is skipped if a file currently exists in the same path with an equal or newer write time.

Gets or sets the list of archive files that are created or extracted.

public IList<System.String> ArchiveFiles { get; set; }

Gets or sets the default root directory where files are located.

public string Directory { get; set; }

For details about how the default directory is used, see «see M:WixToolset.Dtf.Compression.ArchiveFileStreamContext.OpenFileReadStream(System.String,System.IO.FileAttributes@,System.DateTime@)» and «see M:WixToolset.Dtf.Compression.ArchiveFileStreamContext.OpenFileWriteStream(System.String,System.Int64,System.DateTime)» .

Gets or sets a flag that enables creating or extracting an archive at an offset within an existing file. (This is typically used to open archive-based self-extracting packages.)

public bool EnableOffsetOpen { get; set; }

Gets or sets a flag that can prevent extracted files from overwriting newer files that already exist.

public bool ExtractOnlyNewerFiles { get; set; }

Gets or sets the mapping from internal file paths to external file paths.

public System.Collections.Generic.IDictionary<System.String,System.String> Files { get; set; }

For details about how the files mapping is used, see «see M:WixToolset.Dtf.Compression.ArchiveFileStreamContext.OpenFileReadStream(System.String,System.IO.FileAttributes@,System.DateTime@)» and «see M:WixToolset.Dtf.Compression.ArchiveFileStreamContext.OpenFileWriteStream(System.String,System.Int64,System.DateTime)» .