Пример #1
0
        public static LosableSectionInfo Parse(byte[] data, Encoding encoding)
        {
            var losableSectionInfo = new LosableSectionInfo();

            using (var reader = new BinaryReader(new MemoryStream(data, false), encoding))
            {
                losableSectionInfo.OutFile                        = reader.ReadStringWithLengthPrefix(encoding);
                losableSectionInfo.RemovedDefinedItem             = RemovedDefinedItemInfo.ReadRemovedDefinedItems(reader, encoding);
                losableSectionInfo.UnknownAfterRemovedDefinedItem = reader.ReadBytes((int)(reader.BaseStream.Length - reader.BaseStream.Position));
            }
            return(losableSectionInfo);
        }
Пример #2
0
        public static RemovedDefinedItemInfo[] ReadRemovedDefinedItems(BinaryReader reader, Encoding encoding)
        {
            var count           = reader.ReadInt32();
            var size            = reader.ReadInt32();
            var endPosition     = reader.BaseStream.Position + size;
            var result          = new RemovedDefinedItemInfo[count];
            var ids             = reader.ReadInt32sWithFixedLength(count);
            var unknownAfterIds = reader.ReadInt32sWithFixedLength(count);
            var offsets         = reader.ReadInt32sWithFixedLength(count);
            var startPosition   = reader.BaseStream.Position;

            for (int i = 0; i < count; i++)
            {
                reader.BaseStream.Position = startPosition + offsets[i];
                result[i] = new RemovedDefinedItemInfo(ids[i])
                {
                    Name           = reader.ReadCStyleString(encoding),
                    UnknownAfterId = unknownAfterIds[i]
                };
            }
            reader.BaseStream.Position = endPosition;
            return(result);
        }
Пример #3
0
 private void WriteTo(BinaryWriter writer, Encoding encoding)
 {
     writer.WriteStringWithLengthPrefix(encoding, OutFile);
     RemovedDefinedItemInfo.WriteRemovedDefinedItems(writer, encoding, RemovedDefinedItem);
     writer.Write(UnknownAfterRemovedDefinedItem);
 }