Table of Contents

Class Manifest

Namespace
ZeroInstall.Store.Manifests
Assembly
ZeroInstall.Store.dll

A manifest lists every directory, file and symlink in a directory and contains a digest of each file's content.

[Serializable]
public sealed class Manifest : IReadOnlyDictionary<string, IDictionary<string, ManifestElement>>, IReadOnlyCollection<KeyValuePair<string, IDictionary<string, ManifestElement>>>, IEnumerable<KeyValuePair<string, IDictionary<string, ManifestElement>>>, IEnumerable
Inheritance
Manifest
Implements
Inherited Members

Remarks

Constructors

Manifest(ManifestFormat)

Creates a new manifest.

public Manifest(ManifestFormat format)

Parameters

format ManifestFormat

The format used to calculate digests, also specifies the algorithm used in Digest.

Fields

ManifestFile

The well-known file name used to store manifest files in directories.

public const string ManifestFile = ".manifest"

Field Value

string

Properties

Count

Gets the number of elements in the collection.

public int Count { get; }

Property Value

int

The number of elements in the collection.

Format

The format of the manifest (which file details are listed, which digest method is used, etc.).

public ManifestFormat Format { get; }

Property Value

ManifestFormat

this[string]

Gets or adds directory in the manifest.

public IDictionary<string, ManifestElement> this[string key] { get; }

Parameters

key string

The Unix path of the directory relative to the implementation root. Empty for root.

Property Value

IDictionary<string, ManifestElement>

Keys

Gets an enumerable collection that contains the keys in the read-only dictionary.

public IEnumerable<string> Keys { get; }

Property Value

IEnumerable<string>

An enumerable collection that contains the keys in the read-only dictionary.

Lines

The directories and ManifestElements comprising the manifest in line format.

public IEnumerable<string> Lines { get; }

Property Value

IEnumerable<string>

TotalSize

The combined size of all files listed in the manifest in bytes.

public long TotalSize { get; }

Property Value

long

Values

Gets an enumerable collection that contains the values in the read-only dictionary.

public IEnumerable<IDictionary<string, ManifestElement>> Values { get; }

Property Value

IEnumerable<IDictionary<string, ManifestElement>>

An enumerable collection that contains the values in the read-only dictionary.

Methods

Add(string)

Returns an existing directory or adds a new directory (and any missing parents) to the manifest.

public SortedDictionary<string, ManifestElement> Add(string key)

Parameters

key string

The Unix path of the directory relative to the implementation root.

Returns

SortedDictionary<string, ManifestElement>

A dictionary of elements inside the directory.

CalculateDigest()

Calculates the digest for the manifest in-memory.

public string CalculateDigest()

Returns

string

The manifest digest.

ContainsKey(string)

Determines whether the read-only dictionary contains an element that has the specified key.

public bool ContainsKey(string key)

Parameters

key string

The key to locate.

Returns

bool

true if the read-only dictionary contains an element that has the specified key; otherwise, false.

Exceptions

ArgumentNullException

key is null.

Load(Stream, ManifestFormat)

Parses a manifest file stream.

public static Manifest Load(Stream stream, ManifestFormat format)

Parameters

stream Stream

The stream to load from.

format ManifestFormat

The format of the file and the format of the created Manifest. Comprises the digest method used and the file's format.

Returns

Manifest

The parsed content of the file.

Exceptions

FormatException

The file specified is not a valid manifest file.

Load(string, ManifestFormat)

Parses a manifest file.

public static Manifest Load(string path, ManifestFormat format)

Parameters

path string

The path of the file to load.

format ManifestFormat

The format of the file and the format of the created Manifest. Comprises the digest method used and the file's format.

Returns

Manifest

The parsed content of the file.

Exceptions

FormatException

The file specified is not a valid manifest file.

IOException

The manifest file could not be read.

UnauthorizedAccessException

Read access to the file is not permitted.

RejectPath(string)

Determines whether a file path may not be used in implementations.

public static bool RejectPath(string path)

Parameters

path string

Returns

bool

Remove(string)

Removes a directory and all its subdirectories from the manifest.

public bool Remove(string key)

Parameters

key string

The Unix path of the directory relative to the implementation root.

Returns

bool

true if the directory is successfully found and removed; false otherwise.

Rename(string, string)

Moves a directory and all its subdirectories to a new path.

public bool Rename(string key, string newKey)

Parameters

key string

The Unix path of the directory relative to the implementation root.

newKey string

The new Unix path of the directory relative to the implementation root.

Returns

bool

true if the directory is successfully found and renamed; false otherwise.

Save(string)

Writes the manifest to a file.

public void Save(string path)

Parameters

path string

The path of the file to write.

Exceptions

IOException

A problem occurred while writing the file.

UnauthorizedAccessException

Write access to the file is not permitted.

ToString()

The directories and ManifestElements comprising the manifest in line format. Safe for parsing.

public override string ToString()

Returns

string

TryGetValue(string, out IDictionary<string, ManifestElement>?)

Gets the value that is associated with the specified key.

public bool TryGetValue(string key, out IDictionary<string, ManifestElement>? value)

Parameters

key string

The key to locate.

value IDictionary<string, ManifestElement>

When this method returns, the value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter. This parameter is passed uninitialized.

Returns

bool

true if the object that implements the IReadOnlyDictionary<TKey, TValue> interface contains an element that has the specified key; otherwise, false.

Exceptions

ArgumentNullException

key is null.

TryLoad(string, ManifestFormat)

Tries to parse a manifest file.

public static Manifest? TryLoad(string path, ManifestFormat format)

Parameters

path string

The path of the file to load.

format ManifestFormat

The format of the file and the format of the created Manifest. Comprises the digest method used and the file's format.

Returns

Manifest

The parsed content of the file; null if the file does not exits or has invalid content.

Exceptions

IOException

The manifest file could not be read.

UnauthorizedAccessException

Read access to the file is not permitted.

WithOffset(TimeSpan)

Creates a copy of the manifest with all timestamps shifted by the specified offset and rounded up to an even number of seconds.

public Manifest WithOffset(TimeSpan offset)

Parameters

offset TimeSpan

Returns

Manifest