Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 4
0
        internal void WriteSubEntries(MarkedBinaryWriter writer)
        {
            if (IsDirectory)
            {
                writer.WriteMark("cIdx_" + Name, (uint)writer.WriteIdx | 0x80000000);
            }

            var subEntriesSorted = m_subEntries.OrderBy(e => e.Name);

            foreach (var entry in subEntriesSorted)
            {
                entry.Write(writer);
            }

            foreach (var entry in subEntriesSorted)
            {
                entry.WriteSubEntries(writer);
            }
        }
Exemplo n.º 5
0
        internal void WriteSubEntries(MarkedBinaryWriter writer)
        {
            if (IsDirectory)
            {
                writer.WriteMark("cIdx_" + Name, (uint)writer.WriteIdx | 0x80000000);
            }

            var subEntriesSorted = m_subEntries.OrderBy(e => e.Name);

            foreach (var entry in subEntriesSorted)
            {
                entry.Write(writer);
            }

            foreach (var entry in subEntriesSorted)
            {
                entry.WriteSubEntries(writer);
            }
        }
Exemplo n.º 6
0
        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);
            }
        }
Exemplo n.º 7
0
        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);
            }
        }