private bool BuildFileNamesTable(IO.EndianStream blockStream) { Contract.Requires(blockStream.IsWriting); using (var ms = new System.IO.MemoryStream(mFiles.Count * 128)) using (var s = new IO.EndianWriter(ms, blockStream.ByteOrder)) { var smp = new Memory.Strings.StringMemoryPool(kFileNamesTablePoolConfig); for (int x = FileChunksFirstIndex; x < mFiles.Count; x++) { var file = mFiles[x]; file.FileNameOffset = smp.Add(file.FileName).u32; } smp.WriteStrings(s); var filenames_chunk = mFiles[0]; PackFileNames(blockStream, ms, filenames_chunk); return(true); } }
void WriteStringsToBuffer(LocaleStringTableBuffer stringData) { var pool = new Memory.Strings.StringMemoryPool(kStringPoolConfig); foreach (var sref in mStringReferences) { sref.WriteLanguageString(pool); } using (var ms = new System.IO.MemoryStream((int)pool.Size)) using (var ew = new IO.EndianWriter(ms, Shell.EndianFormat.Big)) { pool.WriteStrings(ew); stringData.Buffer = ms.ToArray(); } if (stringData.Buffer.Length > kInfo.BufferMaxSize) { throw new InvalidOperationException("Exceeded string table buffer size by (bytes): " + (stringData.Buffer.Length - kInfo.BufferMaxSize)); } }