@@ -160,6 +160,45 @@ private void ProcessRST(string rst)
160160 }
161161 }
162162
163+ private void RebuildRST ( )
164+ {
165+ XmlDocument doc = new XmlDocument ( ) ;
166+ XmlElement root = doc . CreateElement ( "ResourceStringTable" ) ;
167+ doc . AppendChild ( root ) ;
168+
169+ bool hasNamedResources = false ;
170+
171+ foreach ( BundleEntry entry in Entries )
172+ {
173+ string name = entry . DebugInfo . Name ? . Trim ( ) ;
174+ if ( string . IsNullOrEmpty ( name ) )
175+ continue ;
176+
177+ XmlElement resource = doc . CreateElement ( "Resource" ) ;
178+ resource . SetAttribute ( "id" , entry . ID . ToString ( "X8" ) ) ;
179+ resource . SetAttribute ( "name" , name ) ;
180+ resource . SetAttribute (
181+ "type" ,
182+ string . IsNullOrWhiteSpace ( entry . DebugInfo . TypeName )
183+ ? entry . Type . ToString ( )
184+ : entry . DebugInfo . TypeName
185+ ) ;
186+
187+ root . AppendChild ( resource ) ;
188+ hasNamedResources = true ;
189+ }
190+
191+ if ( ! hasNamedResources )
192+ {
193+ ResourceStringTable = null ;
194+ Flags &= ~ Flags . HasResourceStringTable ;
195+ return ;
196+ }
197+
198+ ResourceStringTable = doc . OuterXml ;
199+ Flags |= Flags . HasResourceStringTable ;
200+ }
201+
163202 public static BundleArchive Read ( string path )
164203 {
165204 using ( Stream s = File . OpenRead ( path ) )
@@ -580,6 +619,8 @@ public void Write(string path)
580619
581620 public void Write ( BinaryWriter2 bw )
582621 {
622+ RebuildRST ( ) ;
623+
583624 bw . Write ( BND2Magic ) ;
584625 bw . Write ( Version ) ;
585626 bw . Write ( ( int ) Platform ) ;
0 commit comments