Table of Contents

Class ArchiveExtractor

Namespace
ZeroInstall.Archives.Extractors
Assembly
ZeroInstall.Archives.dll

Extracts implementation archives.

public abstract class ArchiveExtractor : IArchiveExtractor
Inheritance
ArchiveExtractor
Implements
Derived
Inherited Members

Constructors

ArchiveExtractor(ITaskHandler)

Extracts implementation archives.

protected ArchiveExtractor(ITaskHandler handler)

Parameters

handler ITaskHandler

A callback object used when the the user needs to be informed about IO tasks.

Fields

Handler

A callback object used when the the user needs to be informed about IO tasks.

protected readonly ITaskHandler Handler

Field Value

ITaskHandler

Properties

Tag

A Tag to set for see cref="ITask"/>s spawned by this extractor; can be null.

public object? Tag { get; set; }

Property Value

object

Methods

EnsureFile(Stream, Action<string>)

Ensures that a Stream represents an on-disk file, creating a temporary on-disk copy if necessary.

protected static void EnsureFile(Stream stream, Action<string> callback)

Parameters

stream Stream

The stream to read. May be Close()d.

callback Action<string>

Called with the file path.

EnsureSeekable(Stream, Action<Stream>)

Ensures that a Stream is fully seekable, creating a temporary on-disk copy if necessary.

protected void EnsureSeekable(Stream stream, Action<Stream> callback)

Parameters

stream Stream

The stream to read.

callback Action<Stream>

Called with the original stream or a temporary seekable copy.

Extract(IBuilder, Stream, string?)

Extracts an archive.

public abstract void Extract(IBuilder builder, Stream stream, string? subDir = null)

Parameters

builder IBuilder

The builder receiving the extracted files.

stream Stream

The archive data to be extracted.

subDir string

The Unix-style path of the subdirectory in the archive to extract; null to extract entire archive.

Exceptions

OperationCanceledException

The operation was canceled.

IOException

A problem occurred while extracting the archive.

For(string, ITaskHandler)

Creates a new IArchiveExtractor for a specific type of archive.

public static IArchiveExtractor For(string mimeType, ITaskHandler handler)

Parameters

mimeType string

The MIME type of archive format to extract.

handler ITaskHandler

A callback object used when the the user needs to be informed about IO tasks.

Returns

IArchiveExtractor

Exceptions

NotSupportedException

No extractor registered for mimeType.

NormalizePath(string, string?)

Normalizes the path of an archive entry.

protected static string? NormalizePath(string path, string? subDir)

Parameters

path string

The Unix-style path of the archive entry relative to the archive's root.

subDir string

The Unix-style path of the subdirectory in the archive to extract; null to extract entire archive.

Returns

string

The relative path without the subDir; null if the path doesn't lie within the subDir.

Register(string, Func<ITaskHandler, IArchiveExtractor>)

Registers an additional IArchiveExtractor.

public static void Register(string mimeType, Func<ITaskHandler, IArchiveExtractor> factory)

Parameters

mimeType string

The MIME type of archive format the extractor handles.

factory Func<ITaskHandler, IArchiveExtractor>

Callback providing instances of the extractor.