Table of Contents

Class ZipAssetSource

Namespace
EncDotNet.S100.Core
Assembly
EncDotNet.S100.Core.dll

An asset source backed by a ZIP archive.

public sealed class ZipAssetSource : IAssetSource, IDisposable, IAsyncDisposable
Inheritance
ZipAssetSource
Implements
Inherited Members

Remarks

Safe to read from several threads at once. A ZipArchive reads every entry through one underlying stream, so each entry is read whole under a lock and returned as a MemoryStream.

Methods

Create(ZipArchive, string)

Creates a ZipAssetSource wrapping an existing archive. The source takes ownership and will dispose it.

public static ZipAssetSource Create(ZipArchive archive, string basePath = "")

Parameters

archive ZipArchive

The ZIP archive to read from.

basePath string

An optional path prefix prepended to all relative paths when locating entries (e.g. "S101/" if entries are stored under that folder in the archive).

Returns

ZipAssetSource

Create(Stream, string)

Creates a ZipAssetSource from a stream containing ZIP data. The source takes ownership of the stream.

public static ZipAssetSource Create(Stream stream, string basePath = "")

Parameters

stream Stream

A readable stream containing the ZIP data.

basePath string

An optional entry path prefix.

Returns

ZipAssetSource

Create(string, string)

Creates a ZipAssetSource from a ZIP file on disk.

public static ZipAssetSource Create(string zipPath, string basePath = "")

Parameters

zipPath string

The path to the ZIP file.

basePath string

An optional entry path prefix.

Returns

ZipAssetSource

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

OpenAsync(string, CancellationToken)

Opens a readable stream for the asset at the given relative path within the source.

public Task<Stream> OpenAsync(string relativePath, CancellationToken cancellationToken = default)

Parameters

relativePath string

A forward-slash separated relative path to the asset.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<Stream>