Skip to content

Class PackSource

Namespace: Apogee.Content.Packs
Assembly: Apogee.Content.dll

A pack (see ) as a source of the virtual file system. Opening reads the headers and indexes of the first part and of the parts that follow it (name_001.pack…, which must all be there); files are read, decrypted, decompressed and checked against their hashes when asked for. A pack that is encrypted needs the key (without one, or with a wrong one, says so); damage anywhere is an naming the file. Reads are safe from several threads. A patch pack can paths of the packs mounted under it.

public sealed class PackSource : IFileSource, IDisposable

Inheritance

object ← PackSource

Implements

IFileSource, IDisposable

Inherited Members

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()

Properties

Description

What the source is, for messages: a folder's path, a zip's file name.

public string Description { get; }

Property Value

string

FileCount

The number of files (not counting removals).

public int FileCount { get; }

Property Value

int

IsEncrypted

True when the pack's index is encrypted.

public bool IsEncrypted { get; }

Property Value

bool

PartCount

The number of parts the pack is in.

public int PartCount { get; }

Property Value

int

Methods

Dispose()

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

public void Dispose()

Kind(string)

public FileKind Kind(string path)

Parameters

path string

Returns

FileKind

List(string, List<(string Name, FileKind Kind)>)

Adds the entries directly inside directory to into: their names and kinds, in any order (a source may list entries).

public void List(string directory, List<(string Name, FileKind Kind)> into)

Parameters

directory string

into List<(string Name, FileKind Kind)>

Open(string, PackKey?)

Opens the pack whose first part is path, and the parts after it.

public static PackSource Open(string path, PackKey? key = null)

Parameters

path string

key PackKey?

The key of an encrypted pack; ignored for one that is not.

Returns

PackSource

Exceptions

IOException

It is not a pack, a part is missing, it is encrypted and the key is missing or wrong, or it is damaged.

OpenRead(string)

A file that is neither compressed nor encrypted is streamed from the pack without being read whole (and without its hash checked); any other is read whole.

public Stream OpenRead(string path)

Parameters

path string

Returns

Stream

ReadAllBytes(string)

public byte[] ReadAllBytes(string path)

Parameters

path string

Returns

byte[]

Exceptions

FileNotFoundException

There is no such file.