CookBookArchive¶
Namespace Nfty.Core.Formats in assembly Nfty.Core.
Reads and writes .cbk archives — a manifest plus one nested .rcp per recipe.
Methods¶
HashOf(string)¶
What a Set records for this archive: the SHA-256 of its bytes, lowercase hex.
Parameters
path(string) - Archive path.
Returns. The hash, lowercase hex.
Remarks
The same value LoadedCookBook.SourceSha256 carries and set.json stores as cookbookSha256 - without decoding the book. Answering "is this the book that Set was cooked from?" by reading it would pull every variant PNG in the collection into memory to compare one string, which is the argument ArchivePeek already makes about manifests.
HashOfAsync(string, CancellationToken)¶
The awaiting twin of CookBookArchive.HashOf().
Parameters
path(string) - Archive path.ct(CancellationToken) - Cancels the hash.
Returns. The hash, lowercase hex.
Read(string, Parallelism?)¶
Reads a CookBook, eagerly decoding every variant image inside it.
Parameters
path(string) - Archive path.parallelism(Parallelism?) - How wide decoding may run; null meansParallelism.Default.
Returns. The loaded book. The caller owns it and must dispose it — that frees every decoded image in the tree. Its manifest's PartialAlpha is recomputed from its loaded recipes rather than trusting the stored value.
Exceptions
InvalidDataException- The archive or a manifest inside it is unreadable.UnsupportedSchemaVersionException- It declares a newer schema than this build reads.
ReadAsync(string, CancellationToken, Parallelism?)¶
public static Task<LoadedCookBook> ReadAsync(string path, CancellationToken ct = default, Parallelism? parallelism = null);
Reads a CookBook, eagerly decoding every variant image inside it.
Parameters
path(string) - Archive path.ct(CancellationToken) - Cancels the read. Anything already decoded is disposed before the cancellation propagates.parallelism(Parallelism?) - How wide decoding may run; null meansParallelism.Default.
Returns. The loaded book; the caller owns it. Its manifest's PartialAlpha is recomputed from its loaded recipes rather than trusting the stored value.
Exceptions
InvalidDataException- The archive, or a manifest or image inside it, is missing or unreadable.UnsupportedSchemaVersionException- A manifest declares a schema this build does not read: newer thanSchema.Current, or older thanSchema.Oldest.OperationCanceledException-ctwas canceled.
Write(string, CookBookManifest, IReadOnlyList<LoadedRecipe>, Parallelism?)¶
public static void Write(string path, CookBookManifest manifest, IReadOnlyList<LoadedRecipe> recipes, Parallelism? parallelism = null);
Writes a CookBook.
Parameters
path(string) - Destination path.manifest(CookBookManifest) - The book's manifest. ItsPartialAlphais ignored — the written value is recomputed fromrecipes' images.recipes(IReadOnlyList<LoadedRecipe>) - Recipes to nest inside it.parallelism(Parallelism?) - How wide image encoding or decoding may run; null meansParallelism.Default. Never changes the bytes.
WriteAsync(string, CookBookManifest, IReadOnlyList<LoadedRecipe>, CancellationToken, Parallelism?)¶
public static Task WriteAsync(string path, CookBookManifest manifest, IReadOnlyList<LoadedRecipe> recipes, CancellationToken ct = default, Parallelism? parallelism = null);
Writes a CookBook.
Parameters
path(string) - Destination path.manifest(CookBookManifest) - The book's manifest. ItsPartialAlphais ignored — the written value is recomputed fromrecipes' images.recipes(IReadOnlyList<LoadedRecipe>) - Recipes to nest inside it.ct(CancellationToken) - Cancels the write.parallelism(Parallelism?) - How wide image encoding or decoding may run; null meansParallelism.Default. Never changes the bytes.
Returns. A task that completes when the archive is written.