CompressionEngine Class
Base class for an engine capable of packing and unpacking a particular compressed file format.
Methods
Section titled “Methods”| Method | Description |
|---|---|
| Dispose() | Disposes of resources allocated by the compression engine. |
| Dispose(disposing) | Disposes of resources allocated by the compression engine. |
| Finalize() | Disposes the compression engine. |
| FindArchiveOffset(stream) | Gets the offset of an archive that is positioned 0 or more bytes from the start of the Stream. |
| GetFileInfo(stream) | Gets information about all files in an archive stream. |
| GetFiles(stream) | Gets the list of files in an archive Stream. |
| IsArchive(stream) | Checks whether a Stream begins with a header that indicates it is a valid archive. |
| OnProgress(e) | Called by sublcasses to distribute a packing or unpacking progress event to listeners. |
| Unpack(stream, path) | Reads a single file from an archive stream. |
Properties
Section titled “Properties”| Property | Description |
|---|---|
| CompressionLevel | Compression level to use when compressing files. |
| UseTempFiles | Gets or sets a flag indicating whether temporary files are created and used during compression. |
Events
Section titled “Events”| Event | Description |
|---|---|
| Progress | Occurs when the compression engine reports progress in packing or unpacking an archive. |
WixToolset.Dtf.Compression.dll version 5.0.0+41e11442b2ca93e444b60213b5ae99dcbab787d8 |
Dispose() Method
Section titled “Dispose() Method”Disposes of resources allocated by the compression engine.
Declaration
Section titled “Declaration”public void Dispose()Dispose(disposing) Method
Section titled “Dispose(disposing) Method”Disposes of resources allocated by the compression engine.
Declaration
Section titled “Declaration”protected void Dispose( bool disposing)Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
| disposing | bool | If true, the method has been called directly or indirectly by a user’s code, so managed and unmanaged resources will be disposed. If false, the method has been called by the runtime from inside the finalizer, and only unmanaged resources will be disposed. |
Finalize() Method
Section titled “Finalize() Method”Disposes the compression engine.
Declaration
Section titled “Declaration”protected void Finalize()FindArchiveOffset(stream) Method
Section titled “FindArchiveOffset(stream) Method”Gets the offset of an archive that is positioned 0 or more bytes from the start of the Stream.
Declaration
Section titled “Declaration”public System.Int64 FindArchiveOffset( System.IO.Stream stream)Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
| stream | System.IO.Stream | A stream for reading the archive. |
Return value
Section titled “Return value”System.Int64 The offset in bytes of the archive, or -1 if no archive is found in the Stream.
Remarks
Section titled “Remarks”The archive must begin on a 4-byte boundary.
GetFileInfo(stream) Method
Section titled “GetFileInfo(stream) Method”Gets information about all files in an archive stream.
Declaration
Section titled “Declaration”public IList<WixToolset.Dtf.Compression.ArchiveFileInfo> GetFileInfo( System.IO.Stream stream)Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
| stream | System.IO.Stream | A stream for reading the archive. |
Return value
Section titled “Return value”IList<WixToolset.Dtf.Compression.ArchiveFileInfo> Information about all files in the archive stream.
Exceptions
Section titled “Exceptions”| Exception | Description |
|---|---|
| T:WixToolset.Dtf.Compression.ArchiveException | The stream is not a valid |
archive. |GetFiles(stream) Method
Section titled “GetFiles(stream) Method”Gets the list of files in an archive Stream.
Declaration
Section titled “Declaration”public IList<System.String> GetFiles( System.IO.Stream stream)Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
| stream | System.IO.Stream | A stream for reading the archive. |
Return value
Section titled “Return value”IList<System.String> A list of the paths of all files contained in the archive.
Exceptions
Section titled “Exceptions”| Exception | Description |
|---|---|
| T:WixToolset.Dtf.Compression.ArchiveException | The stream is not a valid |
archive. |IsArchive(stream) Method
Section titled “IsArchive(stream) Method”Checks whether a Stream begins with a header that indicates it is a valid archive.
Declaration
Section titled “Declaration”public bool IsArchive( System.IO.Stream stream)Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
| stream | System.IO.Stream | Stream for reading the archive file. |
Return value
Section titled “Return value”bool True if the stream is a valid archive (with no offset); false otherwise.
OnProgress(e) Method
Section titled “OnProgress(e) Method”Called by sublcasses to distribute a packing or unpacking progress event to listeners.
Declaration
Section titled “Declaration”protected void OnProgress( ArchiveProgressEventArgs e)Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
| e | ArchiveProgressEventArgs | Event details. |
Unpack(stream, path) Method
Section titled “Unpack(stream, path) Method”Reads a single file from an archive stream.
Declaration
Section titled “Declaration”public System.IO.Stream Unpack( System.IO.Stream stream, string path)Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
| stream | System.IO.Stream | A stream for reading the archive. |
| path | string | The path of the file within the archive (not the external file path). |
Return value
Section titled “Return value”System.IO.Stream A stream for reading the extracted file, or null if the file does not exist in the archive.
Remarks
Section titled “Remarks”The entire extracted file is cached in memory, so this method requires enough free memory to hold the file.
Exceptions
Section titled “Exceptions”| Exception | Description |
|---|---|
| T:WixToolset.Dtf.Compression.ArchiveException | The stream is not a valid |
archive. |CompressionLevel Property
Section titled “CompressionLevel Property”Compression level to use when compressing files.
Declaration
Section titled “Declaration”public CompressionLevel CompressionLevel { get; set; }UseTempFiles Property
Section titled “UseTempFiles Property”Gets or sets a flag indicating whether temporary files are created and used during compression.
Declaration
Section titled “Declaration”public bool UseTempFiles { get; set; }Remarks
Section titled “Remarks”The value of this property is true by default. Using temporary files can greatly reduce the memory requirement of compression, especially when compressing large archives. However, setting this property to false may yield slightly better performance when creating small archives. Or it may be necessary if the process does not have sufficient privileges to create temporary files.
Progress Event
Section titled “Progress Event”Occurs when the compression engine reports progress in packing or unpacking an archive.
Declaration
Section titled “Declaration”public System.EventHandler<WixToolset.Dtf.Compression.ArchiveProgressEventArgs> ProgressSystem.EventHandler<WixToolset.Dtf.Compression.ArchiveProgressEventArgs>
See also
Section titled “See also”- T:WixToolset.Dtf.Compression.ArchiveProgressType