public void Write(string path) { var stream = File.Open(path, FileMode.Create); var writer = new MarkedBinaryWriter(stream); writer.Write(0x32465052); // RPF2 writer.Mark("tocSize"); writer.Write(0); writer.Mark("numEntries"); writer.Write(0); writer.Write(0); writer.Write(0); // not encrypted; for now writer.Align(2048); // write a TOC for the file RootEntry.Write(writer); RootEntry.WriteSubEntries(writer); RootEntry.WriteNames(writer); writer.WriteMark("numEntries", (uint)writer.WriteIdx); writer.Align(2048); // this has to be aligned or it will be cut off by 16 byte align writer.WriteMark("tocSize", (uint)stream.Position - 2048); RootEntry.WriteFiles(writer); writer.Close(); }
internal void WriteNames(MarkedBinaryWriter writer) { if (Name != "") { writer.WriteMark("nOff_" + Name, (uint)writer.BaseStream.Position - (uint)writer.BaseNamePosition); writer.Write(Encoding.ASCII.GetBytes(System.IO.Path.GetFileName(Name))); writer.Write((byte)0); } else { writer.BaseNamePosition = (int)writer.BaseStream.Position; writer.WriteMark("nOff_", 0); writer.Write(new byte[] { (byte)'/', 0 }); } foreach (var entry in m_subEntries.OrderBy(e => e.Name)) { entry.WriteNames(writer); } }
internal void WriteFiles(MarkedBinaryWriter writer) { if (!IsDirectory) { writer.WriteMark("fOff_" + Name, ((uint)writer.BaseStream.Position & 0xffffff00) | ResourceVersion); writer.Write(FileData); writer.Align(2048); } foreach (var entry in m_subEntries) { entry.WriteFiles(writer); } }
internal void Write(MarkedBinaryWriter writer) { // write our entry //if (Name != "") { writer.Mark("nOff_" + Name); writer.Write(0); if (!IsDirectory) { writer.Write(FileData.Length); writer.Mark("fOff_" + Name); // also should contain the resource type writer.Write(0); if (!IsResource) { writer.Write(FileData.Length); // no flags, but apparently size? } else { writer.Write(ResourceFlags); } } else { writer.Write(m_subEntries.Count); writer.Mark("cIdx_" + Name); writer.Write(0); writer.Write(m_subEntries.Count); } writer.WriteIdx++; } }