Class ZipAssetSource
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
archiveZipArchiveThe ZIP archive to read from.
basePathstringAn 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
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
streamStreamA readable stream containing the ZIP data.
basePathstringAn optional entry path prefix.
Returns
Create(string, string)
Creates a ZipAssetSource from a ZIP file on disk.
public static ZipAssetSource Create(string zipPath, string basePath = "")
Parameters
Returns
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
relativePathstringA forward-slash separated relative path to the asset.
cancellationTokenCancellationTokenA cancellation token.