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
handlerITaskHandlerA 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
streamStreamThe stream to read. May be Close()d.
callbackAction<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
streamStreamThe stream to read.
callbackAction<Stream>Called with the original
streamor a temporary seekable copy.
Extract(IBuilder, Stream, string?)
Extracts an archive.
public abstract void Extract(IBuilder builder, Stream stream, string? subDir = null)
Parameters
builderIBuilderThe builder receiving the extracted files.
streamStreamThe archive data to be extracted.
subDirstringThe Unix-style path of the subdirectory in the archive to extract;
nullto 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
mimeTypestringThe MIME type of archive format to extract.
handlerITaskHandlerA 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
pathstringThe Unix-style path of the archive entry relative to the archive's root.
subDirstringThe Unix-style path of the subdirectory in the archive to extract;
nullto extract entire archive.
Returns
- string
The relative path without the
subDir;nullif thepathdoesn't lie within thesubDir.
Register(string, Func<ITaskHandler, IArchiveExtractor>)
Registers an additional IArchiveExtractor.
public static void Register(string mimeType, Func<ITaskHandler, IArchiveExtractor> factory)
Parameters
mimeTypestringThe MIME type of archive format the extractor handles.
factoryFunc<ITaskHandler, IArchiveExtractor>Callback providing instances of the extractor.