Exemplo n.º 1
0
        private int ReadInternalSync(byte[] buffer, int offset, int count)
        {
            int i;
            int num;

            for (i = 0; i < count; i += num)
            {
                if (currentCommandStream.Position == currentCommandStream.Length)
                {
                    currentCommandStream = new MemoryStream();
                    BinaryWriter binaryWriter = new BinaryWriter(currentCommandStream);
                    while (currentCommandStream.Length < count - i && commandsToOutput.MoveNext())
                    {
                        DeltaCalculator.WriteCommand(binaryWriter, commandsToOutput.Current);
                    }
                    binaryWriter.Flush();
                    currentCommandStream.Seek(0L, SeekOrigin.Begin);
                }
                num = currentCommandStream.Read(buffer, offset + i, count - i);
                if (num <= 0)
                {
                    break;
                }
            }
            return(i);
        }
Exemplo n.º 2
0
        public DeltaStream(Stream signatureStream, Stream inputStream)
        {
            SignatureFile signatures = SignatureHelpers.ParseSignatureFile(signatureStream);
            IEnumerable <OutputCommand> enumerable = DeltaCalculator.ComputeCommands(new BinaryReader(inputStream), signatures);

            commandsToOutput     = enumerable.GetEnumerator();
            currentCommandStream = new MemoryStream();
            BinaryWriter binaryWriter = new BinaryWriter(currentCommandStream);

            StreamHelpers.WriteBigEndian(binaryWriter, 1920139830uL);
            binaryWriter.Flush();
            currentCommandStream.Seek(0L, SeekOrigin.Begin);
        }
Exemplo n.º 3
0
        public DeltaStream(Stream signatureStream, Stream inputStream)
        {
            var signature   = SignatureHelpers.ParseSignatureFile(signatureStream);
            var inputReader = new BinaryReader(inputStream);
            var commands    = DeltaCalculator.ComputeCommands(inputReader, signature);

            this.commandsToOutput = commands.GetEnumerator();

            this.currentCommandStream = new MemoryStream();
            var writer = new BinaryWriter(this.currentCommandStream);

            StreamHelpers.WriteBigEndian(writer, (uint)MagicNumber.Delta);
            writer.Flush();
            this.currentCommandStream.Seek(0, SeekOrigin.Begin);
        }
Exemplo n.º 4
0
        public override async Task <int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
        {
            if (currentCommandStream.Position == currentCommandStream.Length)
            {
                if (!commandsToOutput.MoveNext())
                {
                    return(0);
                }

                this.currentCommandStream = new MemoryStream();
                var writer = new BinaryWriter(this.currentCommandStream);
                DeltaCalculator.WriteCommand(writer, commandsToOutput.Current);
                writer.Flush();
                this.currentCommandStream.Seek(0, SeekOrigin.Begin);
            }

            return(await this.currentCommandStream.ReadAsync(buffer, offset, count));
        }