From 25e8e50f5e2b704ead0d368c4fa0270011c24631 Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Sat, 5 Oct 2024 14:33:53 +0100 Subject: [PATCH] Add DbFile TryGetChunk method --- KeepersCompound.LGS/Database/File.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/KeepersCompound.LGS/Database/File.cs b/KeepersCompound.LGS/Database/File.cs index b52b11b..70e2fd1 100644 --- a/KeepersCompound.LGS/Database/File.cs +++ b/KeepersCompound.LGS/Database/File.cs @@ -133,6 +133,17 @@ public class DbFile writer.Write(tocOffset); } + public bool TryGetChunk(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