/// <summary> /// Compares bytes in '<paramref name="entry"/>' with <paramref name="sourceBuffer"/>. /// </summary> private async Task <ArchiveEntryCompare> Diff(byte[] sourceBuffer, ArchiveEntry entry) { return(await Task.Run(() => { if (this.Entry == entry) { return new ArchiveEntryCompare(entry, false, CompareProperties(this.Entry, entry)); } bool diff = false; using (var compareMS = entry.GetRawDataStream()) { byte[] compareBuffer; int chunk = 0; while ((compareBuffer = compareMS.ReadBytes(BufferSize)).Length > 0) { for (int i = 0; i < compareBuffer.Length; i++) { if (sourceBuffer[i + (BufferSize * chunk)] != compareBuffer[i]) { diff = true; break; } } if (diff) { break; // break again if diff } chunk++; } } return new ArchiveEntryCompare(entry, diff, CompareProperties(this.Entry, entry)); })); }