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); }
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); }
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); }
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)); }