Add DbFile TryGetChunk method

This commit is contained in:
Jarrod Doyle 2024-10-05 14:33:53 +01:00
parent b9eae0e437
commit 25e8e50f5e
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
1 changed files with 11 additions and 0 deletions

View File

@ -133,6 +133,17 @@ public class DbFile
writer.Write(tocOffset);
}
public bool TryGetChunk<T>(string name, out T chunk)
{
if (Chunks.TryGetValue(name, out var rawChunk))
{
chunk = (T)rawChunk;
return true;
}
chunk = default;
return false;
}
private static IChunk NewChunk(string entryName)
{
return entryName switch