using System.Text; using GsaEditor.Core.Models; namespace GsaEditor.Core.IO; /// /// Writes a .idx NML index file from a . /// The NML format is the engine's own tag syntax (NOT standard XML): /// /// <Version=1.0> /// <Index= /// <Entry= /// <ID="path/in/archive"> /// <CompLen=123> /// <Len=456> /// <Offset=789> /// <Method="Zlib"> /// > /// > /// /// Tab indentation, LF line endings, no BOM. Method is "Zlib" or "Raw". /// The engine parses this file to locate entries, so the format must match exactly. /// public static class GsaIndexWriter { /// /// The engine's bootstrap script is loaded by sequential archive scan and is /// deliberately absent from the shipped index files, so it is skipped here too. /// private const string BootstrapAlias = "bootstrap.txt"; /// /// Writes the index file for the given archive to the specified path. /// Entry offsets must be up to date (i.e. call after ). /// /// The archive whose entries will be indexed. /// The output .idx file path. public static void Write(GsaArchive archive, string filePath) { var sb = new StringBuilder(); sb.Append("\n"); sb.Append("\n"); sb.Append("\t\t\n"); sb.Append("\t\t\n"); sb.Append("\t\t\n"); sb.Append("\t\t\n"); sb.Append("\t>\n"); } sb.Append(">\n"); File.WriteAllText(filePath, sb.ToString(), new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)); } }