public HyoutaArchiveContainer(DuplicatableStream stream) { ulong totalChunkLengths; var firstChunk = new HyoutaArchiveChunk(stream, out totalChunkLengths); Chunks = new List <HyoutaArchiveChunk>(); Chunks.Add(firstChunk); while (totalChunkLengths < (ulong)stream.Length) { ulong tmp; Chunks.Add(new HyoutaArchiveChunk(new PartialStream(stream, (long)totalChunkLengths, (long)((ulong)stream.Length - totalChunkLengths)), out tmp)); totalChunkLengths += tmp; } Chunks.TrimExcess(); FileCountOffsets = new long[Chunks.Count + 1]; FileCountOffsets[0] = 0; for (int i = 0; i < Chunks.Count; ++i) { FileCountOffsets[i + 1] = FileCountOffsets[i] + Chunks[i].Filecount; } }
public static HyoutaArchiveBpsPatchInfo?Deserialize(DuplicatableStream stream, long maxBytes, EndianUtils.Endianness endian, ulong currentFileIndex, HyoutaArchiveChunk referencedChunk) { if (maxBytes < 16) { stream.DiscardBytes(maxBytes); return(null); } else { ulong fileIndexToPatch = stream.ReadUInt64(endian); ulong targetFilesize = stream.ReadUInt64(endian); stream.DiscardBytes(maxBytes - 16); if (fileIndexToPatch == currentFileIndex) { // this is how you set a file to be unpatched in an archive that has patches return(null); } else { return(new HyoutaArchiveBpsPatchInfo(fileIndexToPatch, targetFilesize, referencedChunk)); } } }