public TrophyTrp(HyoutaPluginBase.DuplicatableStream stream, EndianUtils.Endianness endian = EndianUtils.Endianness.BigEndian) { Stream = stream.Duplicate(); Endian = endian; try { Stream.ReStart(); Magic = Stream.ReadUInt32().FromEndian(EndianUtils.Endianness.LittleEndian); if (Magic != 0x004DA2DC) { throw new Exception("invalid magic"); } Unknown2 = Stream.ReadUInt32().FromEndian(endian); Unknown3 = Stream.ReadUInt32().FromEndian(endian); Filesize = Stream.ReadUInt32().FromEndian(endian); Filecount = Stream.ReadUInt32().FromEndian(endian); Unknown6 = Stream.ReadUInt32().FromEndian(endian); Unknown7 = Stream.ReadUInt32().FromEndian(endian); Unknown8 = Stream.ReadUInt32().FromEndian(endian); Unknown9 = Stream.ReadUInt32().FromEndian(endian); Unknown10 = Stream.ReadUInt32().FromEndian(endian); Unknown11 = Stream.ReadUInt32().FromEndian(endian); Unknown12 = Stream.ReadUInt32().FromEndian(endian); Unknown13 = Stream.ReadUInt32().FromEndian(endian); Unknown14 = Stream.ReadUInt32().FromEndian(endian); Unknown15 = Stream.ReadUInt32().FromEndian(endian); Unknown16 = Stream.ReadUInt32().FromEndian(endian); } finally { Stream.End(); } }
public static DuplicatableStream CreateConcatenatedStream(List <DuplicatableStream> streams) { if (streams.Count == 0) { return(EmptyStream.Instance); } var Streams = new List <DuplicatableStream>(streams.Count); var Offsets = new List <long>(Streams.Count); var InternalCanRead = true; var InternalCanSeek = true; var InternalCanWrite = true; long sum = 0; for (int i = 0; i < streams.Count; ++i) { DuplicatableStream s = streams[i].Duplicate(); s.ReStart(); long l = s.Length; if (l <= 0) { s.End(); s.Dispose(); continue; } sum += l; InternalCanRead = InternalCanRead && s.CanRead; InternalCanSeek = InternalCanSeek && s.CanSeek; InternalCanWrite = InternalCanWrite && s.CanWrite; s.End(); Streams.Add(s); Offsets.Add(sum); } if (Streams.Count == 0) { return(EmptyStream.Instance); } if (Streams.Count == 1) { return(Streams[0]); } return(new ConcatenatedStream(Streams, Offsets, InternalCanRead, InternalCanSeek, InternalCanWrite)); }