Beispiel #1
0
 public CoordinatedStream(StreamCoordinator coordinator, long offset, long length)
 {
     mCoordinator = coordinator;
     mOffset      = offset;
     mCursor      = offset;
     mEnding      = offset + length;
 }
 public CoordinatedStream(StreamCoordinator coordinator, long offset, long length)
 {
     mCoordinator = coordinator;
     mOffset = offset;
     mCursor = offset;
     mEnding = offset + length;
 }
Beispiel #3
0
 public override void Dispose()
 {
     mCoordinator = null;
 }
Beispiel #4
0
        public ArchiveSectionDecoder(Stream stream, ArchiveMetadata metadata, int index, PasswordStorage password)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            if (!stream.CanRead)
            {
                throw new ArgumentException("Stream must be readable.", nameof(stream));
            }

            if (!stream.CanSeek)
            {
                throw new ArgumentException("Stream must be seekable.", nameof(stream));
            }

            if (metadata == null)
            {
                throw new ArgumentNullException(nameof(metadata));
            }

            if (index < 0 || index >= metadata.DecoderSections.Length)
            {
                throw new ArgumentOutOfRangeException(nameof(index));
            }

            var inputCoordinator = new StreamCoordinator(stream);
            var inputStreams     = new ReaderNode[metadata.FileSections.Length];

            for (int i = 0; i < inputStreams.Length; i++)
            {
                inputStreams[i] = new CoordinatedStream(inputCoordinator, metadata.FileSections[i].Offset, metadata.FileSections[i].Length);
            }

            var decoderSection     = metadata.DecoderSections[index];
            var decoderDefinitions = decoderSection.Decoders;
            var decoders           = new DecoderNode[decoderDefinitions.Length];

            for (int i = 0; i < decoders.Length; i++)
            {
                var decoderDefinition = decoderDefinitions[i];
                decoders[i] = decoderDefinition.DecoderType.CreateDecoder(decoderDefinition.Settings, decoderDefinition.OutputStreams, password);
            }

            for (int i = 0; i < decoders.Length; i++)
            {
                var decoder                 = decoders[i];
                var decoderDefinition       = decoderDefinitions[i];
                var decoderInputDefinitions = decoderDefinition.InputStreams;

                for (int j = 0; j < decoderInputDefinitions.Length; j++)
                {
                    ReaderNode inputStream;
                    long       inputLength;
                    SelectStream(metadata, decoderSection, decoderInputDefinitions[j], inputStreams, decoders, out inputStream, out inputLength);
                    decoder.SetInputStream(j, inputStream, inputLength);
                }
            }

            ReaderNode outputStream;
            long       outputLength;

            SelectStream(metadata, decoderSection, decoderSection.DecodedStream, inputStreams, decoders, out outputStream, out outputLength);

            mCoordinator  = inputCoordinator;
            mInputStreams = inputStreams;
            mDecoders     = decoders;
            mOutputStream = outputStream;
        }
 public override void Dispose()
 {
     mCoordinator = null;
 }
        public ArchiveSectionDecoder(Stream stream, ArchiveMetadata metadata, int index, PasswordStorage password)
        {
            if (stream == null)
                throw new ArgumentNullException(nameof(stream));

            if (!stream.CanRead)
                throw new ArgumentException("Stream must be readable.", nameof(stream));

            if (!stream.CanSeek)
                throw new ArgumentException("Stream must be seekable.", nameof(stream));

            if (metadata == null)
                throw new ArgumentNullException(nameof(metadata));

            if (index < 0 || index >= metadata.DecoderSections.Length)
                throw new ArgumentOutOfRangeException(nameof(index));

            var inputCoordinator = new StreamCoordinator(stream);
            var inputStreams = new ReaderNode[metadata.FileSections.Length];
            for (int i = 0; i < inputStreams.Length; i++)
                inputStreams[i] = new CoordinatedStream(inputCoordinator, metadata.FileSections[i].Offset, metadata.FileSections[i].Length);

            var decoderSection = metadata.DecoderSections[index];
            var decoderDefinitions = decoderSection.Decoders;
            var decoders = new DecoderNode[decoderDefinitions.Length];

            for (int i = 0; i < decoders.Length; i++)
            {
                var decoderDefinition = decoderDefinitions[i];
                decoders[i] = decoderDefinition.DecoderType.CreateDecoder(decoderDefinition.Settings, decoderDefinition.OutputStreams, password);
            }

            for (int i = 0; i < decoders.Length; i++)
            {
                var decoder = decoders[i];
                var decoderDefinition = decoderDefinitions[i];
                var decoderInputDefinitions = decoderDefinition.InputStreams;

                for (int j = 0; j < decoderInputDefinitions.Length; j++)
                {
                    ReaderNode inputStream;
                    long inputLength;
                    SelectStream(metadata, decoderSection, decoderInputDefinitions[j], inputStreams, decoders, out inputStream, out inputLength);
                    decoder.SetInputStream(j, inputStream, inputLength);
                }
            }

            ReaderNode outputStream;
            long outputLength;
            SelectStream(metadata, decoderSection, decoderSection.DecodedStream, inputStreams, decoders, out outputStream, out outputLength);

            mCoordinator = inputCoordinator;
            mInputStreams = inputStreams;
            mDecoders = decoders;
            mOutputStream = outputStream;
        }