From d405a9b5db595a002b4266eb49442f5f4f13cc46 Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Sat, 3 Aug 2024 16:09:30 +0100 Subject: [PATCH] Add TXLIST reader --- project/code/LGS/Database/Chunks/TxList.cs | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 project/code/LGS/Database/Chunks/TxList.cs diff --git a/project/code/LGS/Database/Chunks/TxList.cs b/project/code/LGS/Database/Chunks/TxList.cs new file mode 100644 index 0000000..1ac2177 --- /dev/null +++ b/project/code/LGS/Database/Chunks/TxList.cs @@ -0,0 +1,54 @@ +using System; +using System.IO; +using System.Text; + +namespace KeepersCompound.LGS.Database.Chunks; + +public class TxList : IChunk +{ + public struct Item + { + public byte[] Tokens { get; set; } + public string Name { get; set; } + + public Item(BinaryReader reader) + { + Tokens = reader.ReadBytes(4); + var tmpName = Encoding.UTF8.GetString(reader.ReadBytes(16)).Replace("\0", string.Empty); + Name = tmpName[..Math.Min(15, tmpName.Length)]; + } + } + + + public ChunkHeader Header { get; set; } + + public int BlockSize { get; set; } + public int ItemCount { get; set; } + public int TokenCount { get; set; } + public string[] Tokens { get; set; } + public Item[] Items { get; set; } + + + public void ReadData(BinaryReader reader, DbFile.TableOfContents.Entry entry) + { + BlockSize = reader.ReadInt32(); + ItemCount = reader.ReadInt32(); + TokenCount = reader.ReadInt32(); + Tokens = new string[TokenCount]; + for (var i = 0; i < TokenCount; i++) + { + var tmpToken = Encoding.UTF8.GetString(reader.ReadBytes(16)).Replace("\0", string.Empty); + Tokens[i] = tmpToken[..Math.Min(16, tmpToken.Length)]; + } + Items = new Item[ItemCount]; + for (var i = 0; i < ItemCount; i++) + { + Items[i] = new Item(reader); + } + } + + public void WriteData(BinaryWriter writer) + { + throw new System.NotImplementedException(); + } +} \ No newline at end of file