public List <string> Enumerate() { return(SubFiles.Select(sub => sub.Name).ToList()); }
public byte[] Get() { using (MemoryStream MS = new MemoryStream()) { BinaryWriter writer = Utilities.IO.OpenWriteFile(MS, IsLittleEndian); var RMD = SubFiles.FindAll(x => (int)(x.Tag as object[])[0] == (int)TypeMap.RMD); var BMD = SubFiles.Find(x => (int)(x.Tag as object[])[0] == (int)TypeMap.BMD); var EPL = SubFiles.FindAll(x => (int)(x.Tag as object[])[0] == (int)TypeMap.EPL); MS.Position = 0x20 + 0x10 * (1 + (RMD.Count == 0 ? 0 : 2) + (BMD == null ? 0 : 1) + (EPL.Count == 0 ? 0 : 2) + HidList.GroupBy(x => (int)x.Tag).Count()); List <int[]> table = new List <int[]>(); var filelist = SubFiles.Select(x => x.Name).ToArray(); table.Add(new int[] { (int)TypeMap.FileList, textsize, filelist.Length, (int)MS.Position }); foreach (var file in filelist) { writer.WriteString(file, textsize); } long RMDHeadPos = 0; if (RMD.Count != 0) { table.Add(new int[] { (int)TypeMap.RMDHead, 0x20, RMD.Count, (int)MS.Position }); RMDHeadPos = MS.Position; MS.Position += RMD.Count * 0x20; table.Add(new int[] { (int)TypeMap.RMD, 0, 1, (int)MS.Position }); } if (BMD != null) { byte[] bmd = (BMD.Object as IPersonaFile).Get(); table.Add(new int[] { (int)TypeMap.BMD, bmd.Length + Utilities.Utilities.Alignment(bmd.Length, 0x10), 1, (int)MS.Position }); writer.Write(bmd); writer.Write(new byte[Utilities.Utilities.Alignment(bmd.Length, 0x10)]); } long EPLHeadPos = 0; if (EPL.Count != 0) { table.Add(new int[] { (int)TypeMap.EPLHead, 0x10, EPL.Count, (int)MS.Position }); EPLHeadPos = MS.Position; MS.Position += EPL.Count * 0x10; table.Add(new int[] { (int)TypeMap.EPL, 0, 1, (int)MS.Position }); } foreach (var a in EPL) { byte[] epl = (a.Object as IPersonaFile).Get(); table.Find(x => x[0] == (int)TypeMap.EPL)[1] += epl.Length + Utilities.Utilities.Alignment(epl.Length, 0x10); int[] eplhead = (int[])(a.Tag as object[])[1]; eplhead[1] = (int)MS.Position; writer.Write(epl); MS.Position += Utilities.Utilities.Alignment(epl.Length, 0x10); } foreach (var a in RMD) { byte[] rmd = (a.Object as IPersonaFile).Get(); table.Find(x => x[0] == (int)TypeMap.RMD)[1] += rmd.Length + Utilities.Utilities.Alignment(rmd.Length, 0x10); int[] rmdhead = (int[])(a.Tag as object[])[1]; rmdhead[4] = (int)MS.Position; rmdhead[5] = rmd.Length; writer.Write(rmd); MS.Position += Utilities.Utilities.Alignment(rmd.Length, 0x10); } if (EPLHeadPos != 0) { writer.BaseStream.Position = EPLHeadPos; foreach (var a in EPL) { writer.WriteInt32Array((int[])(a.Tag as object[])[1]); } } if (RMDHeadPos != 0) { writer.BaseStream.Position = RMDHeadPos; foreach (var a in RMD) { writer.WriteInt32Array((int[])(a.Tag as object[])[1]); } } // table.AddRange(Table.Where(x => !table.Exists(y => y[0] == x[0]))); table = table.OrderBy(x => x[0]).ToList(); MS.Position = 0x4; writer.Write((int)MS.Length); writer.Write(Encoding.ASCII.GetBytes("PMD1")); MS.Position = 0x10; writer.Write(table.Count); writer.Write(Unknown); MS.Position = 0x20; foreach (var a in table) { writer.WriteInt32Array(a); } return(MS.ToArray()); } }