private static IvffResult CheckBlockNext( Stream stream, ref IvCommonCheckWork checkWork, ref IvCommonBlockHeader common) { int val2 = Math.Min(checkWork.DivideSize, checkWork.RemainSize); checkWork.RemainSize -= val2; ++checkWork.NowCount; int size; for (; 0 < val2; val2 -= size) { size = Math.Min(16777216, val2); byte[] bytes = new byte[size]; int readSize; if (Ivff.IsResultError(Ivff.ReadNext(stream, bytes, size, out readSize)) || size != readSize) { return(IvffResult.READ_ERROR); } checkWork.CurSum = IvaUtils.CalcSum32(checkWork.CurSum, bytes, size); } if (0 < checkWork.RemainSize) { return(IvffResult.CONTINUE); } return((int)common.BlockDataSum == (int)checkWork.CurSum ? IvffResult.OK : IvffResult.INVALID); }
private static IvffResult LoadBlockHeader <T>(Stream stream, ref T structure) where T : struct { int length = Marshal.SizeOf(typeof(T)); int num1 = Marshal.SizeOf(typeof(IvCommonBlockHeader)); byte[] bytes1 = new byte[length]; int readSize; if (Ivff.IsResultError(Ivff.ReadNext(stream, bytes1, num1, out readSize)) || num1 != readSize) { return(IvffResult.READ_ERROR); } IvCommonBlockHeader commonBlockHeader = new IvCommonBlockHeader(); IvaUtils.BytesToStructure <IvCommonBlockHeader>(ref commonBlockHeader, bytes1); IvffResult result = Ivff.CheckIvCommonBlockHeader(ref commonBlockHeader); if (Ivff.IsResultError(result)) { return(result); } if ((int)commonBlockHeader.BlockHeaderSize > num1) { ushort num2 = Math.Min((ushort)((uint)commonBlockHeader.BlockHeaderSize - (uint)num1), (ushort)(length - num1)); if ((ushort)0 < num2) { byte[] bytes2 = new byte[(int)num2]; if (Ivff.IsResultError(Ivff.ReadNext(stream, bytes2, (int)num2, out readSize)) || (int)num2 != readSize) { return(IvffResult.READ_ERROR); } bytes2.CopyTo((Array)bytes1, num1); } } IvaUtils.BytesToStructure <T>(ref structure, bytes1); return(IvffResult.OK); }