Example #1
0
 private void WriteEntry(IDXEntry entry, uint count = 0)
 {
     using (var bw = new BinaryStream(file.BaseStream, leaveOpen: true))
     {
         bw.Write(entry.Hash);
         bw.Write(entry.HashAlt);
         bw.Write(entry.Compression);
         bw.Write(entry.DataLBA);
         bw.Write(entry.DataLength);
         if (count != 0)
         {
             bw.BaseStream.Position = 0;
             bw.Write(count);
         }
     }
 }
Example #2
0
        /// <summary>Relink hash to target</summary>
        /// <param name="hash"></param>
        /// <param name="target"></param>
        public void RelinkEntry(uint hash, uint target)
        {
            FindEntryByHash(target);
            file.BaseStream.Position += 4;
            var entry = new IDXEntry
            {
                Hash        = hash,
                HashAlt     = file.ReadUInt16(),
                Compression = file.ReadUInt16(),
                DataLBA     = file.ReadUInt32(),
                DataLength  = file.ReadUInt32()
            };

            FindEntryByHash(hash);
            WriteEntry(entry);
        }
Example #3
0
        public IDXEntry ReadEntry(long index = -1)
        {
            if (index >= 0)
            {
                Position = (uint)index;
            }
            if (Position >= Count)
            {
                return(new IDXEntry {
                    Hash = 0
                });
            }
            file.BaseStream.Position = 4 + 16 * Position++;
            var entry = new IDXEntry
            {
                Hash        = file.ReadUInt32(),
                HashAlt     = file.ReadUInt16(),
                Compression = file.ReadUInt16(),
                DataLBA     = file.ReadUInt32(),
                DataLength  = file.ReadUInt32()
            };

            return(entry);
        }
Example #4
0
 public void AddEntry(IDXEntry entry)
 {
     file.BaseStream.Position = 4 + 16 * Count;
     WriteEntry(entry, ++Count);
 }
Example #5
0
 public void ModifyEntry(IDXEntry entry)
 {
     FindEntryByHash(entry.Hash);
     WriteEntry(entry);
 }