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
ITaskHandlerA callback object used when the user needs to be informed about IO tasks.
Fields
Handler
A callback object used when the user needs to be informed about IO tasks.
protected readonly ITaskHandler Handler
Field Value
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
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
StreamThe 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
StreamThe 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
IBuilderThe builder receiving the extracted files.
stream
StreamThe archive data to be extracted.
subDir
stringThe 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
stringThe MIME type of archive format to extract.
handler
ITaskHandlerA callback object used when the user needs to be informed about IO tasks.
Returns
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
stringThe Unix-style path of the archive entry relative to the archive's root.
subDir
stringThe 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 thepath
doesn't lie within thesubDir
.
Register(string, Func<ITaskHandler, IArchiveExtractor>)
Registers an additional IArchiveExtractor.
public static void Register(string mimeType, Func<ITaskHandler, IArchiveExtractor> factory)
Parameters
mimeType
stringThe MIME type of archive format the extractor handles.
factory
Func<ITaskHandler, IArchiveExtractor>Callback providing instances of the extractor.