Skip to content

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.

C#
public sealed class ZipContentSource : IContentSource, IDisposable

Inheritance

object ← ZipContentSource

Implements

IContentSource, IDisposable

Extension Methods

ContentSources.ReadAllBytes(IContentSource, string)

Constructors

ZipContentSource(string)

Opens the zip archive at path; the source keeps the file open until disposed.

C#
public ZipContentSource(string path)

Parameters

path string

Exceptions

FileNotFoundException

The file does not exist.

InvalidDataException

The file is not a valid zip archive.

ZipContentSource(Stream, string, bool)

Reads the zip archive in archive (a readable, seekable stream).

C#
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

InvalidDataException

The stream is not a valid zip archive.

Properties

Location

The archive’s path or the description it was opened with.

C#
public string Location { get; }

Property Value

string

Methods

Dispose()

Closes the archive.

C#
public void Dispose()

Exists(string)

Whether a file exists at path. False for a missing file and for a path outside the source.

C#
public bool Exists(string path)

Parameters

path string

Returns

bool

Files(string)

The files directly inside folder (“” for the top), as paths relative to the source, in ordinal order.

C#
public IReadOnlyList<string> Files(string folder)

Parameters

folder string

Returns

IReadOnlyList<string>

Exceptions

DirectoryNotFoundException

The folder does not exist.

Open(string)

Opens the file at path for reading; the caller disposes the stream.

C#
public Stream Open(string path)

Parameters

path string

Returns

Stream

Exceptions

ArgumentException

The path leaves the source.

FileNotFoundException

No such file, or its name is spelled with another letter case.