예제 #1
0
        internal static Stream CreateDecoderStream(Stream inStream, long startPos, long[] packSizes, CFolder folderInfo,
                                                   IPasswordProvider pass)
        {
            if (!folderInfo.CheckStructure())
            {
                throw new NotSupportedException("Unsupported stream binding structure.");
            }

            // We have multiple views into the same stream which will be used by several threads - need to sync those.
            object sync = new object();

            Stream[] inStreams = new Stream[folderInfo.PackStreams.Count];
            for (int j = 0; j < folderInfo.PackStreams.Count; j++)
            {
                inStreams[j] = new SyncStreamView(sync, inStream, startPos, packSizes[j]);
                startPos    += packSizes[j];
            }

            Stream[] outStreams = new Stream[folderInfo.UnpackSizes.Count];

            int primaryCoderIndex, primaryOutStreamIndex;

            FindPrimaryOutStreamIndex(folderInfo, out primaryCoderIndex, out primaryOutStreamIndex);
            return(CreateDecoderStream(inStreams, packSizes, outStreams, folderInfo, primaryCoderIndex, pass));
        }
예제 #2
0
        internal static Stream CreateDecoderStream(Stream inStream, long startPos, long[] packSizes, CFolder folderInfo, IPasswordProvider pass)
        {
            if (!folderInfo.CheckStructure())
                throw new NotSupportedException("Unsupported stream binding structure.");

            // We have multiple views into the same stream which will be used by several threads - need to sync those.
            object sync = new object();
            Stream[] inStreams = new Stream[folderInfo.PackStreams.Count];
            for (int j = 0; j < folderInfo.PackStreams.Count; j++)
            {
                inStreams[j] = new SyncStreamView(sync, inStream, startPos, packSizes[j]);
                startPos += packSizes[j];
            }

            Stream[] outStreams = new Stream[folderInfo.UnpackSizes.Count];

            int primaryCoderIndex, primaryOutStreamIndex;
            FindPrimaryOutStreamIndex(folderInfo, out primaryCoderIndex, out primaryOutStreamIndex);
            return CreateDecoderStream(inStreams, packSizes, outStreams, folderInfo, primaryCoderIndex, pass);
        }