API reference
Class ZipContentSource
Namespace: MicroEngine.Content
Assembly: MicroEngine.Content.dll
Guide: Assets
Content files inside a zip archive: a game’s content shipped as one file. Names follow the folder rules (exact letter case everywhere, ‘/’ separators, no way out of the archive). Each file is decompressed into memory when it is opened, so streams are independent and the source can be read from several threads.
public sealed class ZipContentSource : IContentSource, IDisposableInheritance
Implements
Extension Methods
ContentSources.ReadAllBytes(IContentSource, string)
Constructors
ZipContentSource(string)
Opens the zip archive at path; the source keeps the file open until disposed.
public ZipContentSource(string path)Parameters
path string
Exceptions
The file does not exist.
The file is not a valid zip archive.
ZipContentSource(Stream, string, bool)
Reads the zip archive in archive (a readable, seekable stream).
public ZipContentSource(Stream archive, string location, bool leaveOpen = false)Parameters
archive Stream
The archive’s bytes.
location string
A description of where it came from, for messages.
leaveOpen bool
Whether disposing the source leaves archive open.
Exceptions
The stream is not a valid zip archive.
Properties
Location
The archive’s path or the description it was opened with.
public string Location { get; }Property Value
Methods
Dispose()
Closes the archive.
public void Dispose()Exists(string)
Whether a file exists at path. False for a missing file and for a path outside the source.
public bool Exists(string path)Parameters
path string
Returns
Files(string)
The files directly inside folder (“” for the top), as paths relative to the source, in ordinal order.
public IReadOnlyList<string> Files(string folder)Parameters
folder string
Returns
Exceptions
The folder does not exist.
Open(string)
Opens the file at path for reading; the caller disposes the stream.
public Stream Open(string path)Parameters
path string
Returns
Exceptions
The path leaves the source.
No such file, or its name is spelled with another letter case.