private static Stream CreateDecoderStream(Stream[] packStreams, long[] packSizes, Stream[] outStreams, CFolder folderInfo, int coderIndex, IPasswordProvider pass) { int num2; CCoderInfo info = folderInfo.Coders[coderIndex]; if (info.NumOutStreams != 1) { throw new NotSupportedException("Multiple output streams are not supported."); } int inStreamIndex = 0; for (num2 = 0; num2 < coderIndex; num2++) { inStreamIndex += folderInfo.Coders[num2].NumInStreams; } int num3 = 0; for (num2 = 0; num2 < coderIndex; num2++) { num3 += folderInfo.Coders[num2].NumOutStreams; } Stream[] inStreams = new Stream[info.NumInStreams]; num2 = 0; while (num2 < inStreams.Length) { int num4 = folderInfo.FindBindPairForInStream(inStreamIndex); if (num4 >= 0) { int outIndex = folderInfo.BindPairs[num4].OutIndex; if (outStreams[outIndex] != null) { throw new NotSupportedException("Overlapping stream bindings are not supported."); } int num6 = FindCoderIndexForOutStreamIndex(folderInfo, outIndex); inStreams[num2] = CreateDecoderStream(packStreams, packSizes, outStreams, folderInfo, num6, pass); if (outStreams[outIndex] != null) { throw new NotSupportedException("Overlapping stream bindings are not supported."); } outStreams[outIndex] = inStreams[num2]; } else { int index = folderInfo.FindPackStreamArrayIndex(inStreamIndex); if (index < 0) { throw new NotSupportedException("Could not find input stream binding."); } inStreams[num2] = packStreams[index]; } num2++; inStreamIndex++; } long limit = folderInfo.UnpackSizes[num3]; return(DecoderRegistry.CreateDecoderStream(info.MethodId, inStreams, info.Props, pass, limit)); }
private static Stream CreateDecoderStream(Stream[] packStreams, long[] packSizes, Stream[] outStreams, CFolder folderInfo, int coderIndex, IPasswordProvider pass) { var coderInfo = folderInfo.Coders[coderIndex]; if (coderInfo.NumOutStreams != 1) { throw new NotSupportedException("Multiple output streams are not supported."); } int inStreamId = 0; for (int i = 0; i < coderIndex; i++) { inStreamId += folderInfo.Coders[i].NumInStreams; } int outStreamId = 0; for (int i = 0; i < coderIndex; i++) { outStreamId += folderInfo.Coders[i].NumOutStreams; } Stream[] inStreams = new Stream[coderInfo.NumInStreams]; for (int i = 0; i < inStreams.Length; i++, inStreamId++) { int bindPairIndex = folderInfo.FindBindPairForInStream(inStreamId); if (bindPairIndex >= 0) { int pairedOutIndex = folderInfo.BindPairs[bindPairIndex].OutIndex; if (outStreams[pairedOutIndex] != null) { throw new NotSupportedException("Overlapping stream bindings are not supported."); } int otherCoderIndex = FindCoderIndexForOutStreamIndex(folderInfo, pairedOutIndex); inStreams[i] = CreateDecoderStream(packStreams, packSizes, outStreams, folderInfo, otherCoderIndex, pass); //inStreamSizes[i] = folderInfo.UnpackSizes[pairedOutIndex]; if (outStreams[pairedOutIndex] != null) { throw new NotSupportedException("Overlapping stream bindings are not supported."); } outStreams[pairedOutIndex] = inStreams[i]; } else { int index = folderInfo.FindPackStreamArrayIndex(inStreamId); if (index < 0) { throw new NotSupportedException("Could not find input stream binding."); } inStreams[i] = packStreams[index]; //inStreamSizes[i] = packSizes[index]; } } long unpackSize = folderInfo.UnpackSizes[outStreamId]; return(DecoderRegistry.CreateDecoderStream(coderInfo.MethodId, inStreams, coderInfo.Props, pass, unpackSize)); }