// Token: 0x060012BC RID: 4796 RVA: 0x0006D26C File Offset: 0x0006B46C
        private bool CreatePatch(Stream diffStream)
        {
            this.abortProcessingOnShutdown();
            bool result;

            using (DataPatching dataPatching = new DataPatching(Globals.MaxCompressionBlockSize, Globals.MaxCompressionBlockSize, Globals.MaxCompressionBlockSize))
            {
                using (IOCostStream iocostStream = new IOCostStream(new NoCloseStream(this.oldFile.UncompressedFileStream)))
                {
                    using (new FileSystemPerformanceTracker("FinishGeneratingAddressListFiles.GenerateDiffFiles", iocostStream, this.stats))
                    {
                        using (IOCostStream iocostStream2 = new IOCostStream(new NoCloseStream(this.newFile.UncompressedFileStream)))
                        {
                            using (new FileSystemPerformanceTracker("FinishGeneratingAddressListFiles.GenerateDiffFiles", iocostStream2, this.stats))
                            {
                                byte[] array  = new byte[Globals.MaxCompressionBlockSize];
                                byte[] array2 = new byte[Globals.MaxCompressionBlockSize];
                                int    num;
                                uint   oldCRC;
                                DiffFileGenerator.ReadFileHeader(iocostStream, array, out num, out oldCRC);
                                int  num2;
                                uint newCRC;
                                DiffFileGenerator.ReadFileHeader(iocostStream2, array2, out num2, out newCRC);
                                this.WriteDiffFileHeader(diffStream, oldCRC, newCRC);
                                uint   num3   = 0U;
                                uint   num4   = 0U;
                                long   num5   = iocostStream.Length - (long)num;
                                long   num6   = iocostStream2.Length - (long)num2;
                                byte[] array3 = null;
                                byte[] array4 = null;
                                int    num7   = 0;
                                int    num8   = 0;
                                Guid?  guid   = null;
                                Guid?  guid2  = null;
                                byte[] propertyDescriptorsBuffer       = null;
                                byte[] propertyDescriptorsBuffer2      = null;
                                int    headerPropertyDescriptorsCount  = 0;
                                int    headerPropertyDescriptorsCount2 = 0;
                                int    num9  = 0;
                                int    num10 = 0;
                                bool   flag  = false;
                                int    num11 = 0;
                                for (;;)
                                {
                                    this.abortProcessingOnShutdown();
                                    if (num5 != 0L && num11 <= 0 && num7 == 0)
                                    {
                                        DiffFileGenerator.ReadNextRecord(iocostStream, true, ref num3, ref num5, ref array3, ref num7, ref guid, ref propertyDescriptorsBuffer, ref headerPropertyDescriptorsCount, ref num9);
                                    }
                                    if (num6 != 0L && num11 >= 0 && num8 == 0)
                                    {
                                        DiffFileGenerator.ReadNextRecord(iocostStream2, false, ref num4, ref num6, ref array4, ref num8, ref guid2, ref propertyDescriptorsBuffer2, ref headerPropertyDescriptorsCount2, ref num10);
                                    }
                                    bool flag2 = false;
                                    if (guid != null && guid2 != null)
                                    {
                                        num11 = guid.Value.CompareTo(guid2.Value);
                                    }
                                    else if (guid == null && guid2 != null)
                                    {
                                        flag  = true;
                                        num11 = 2;
                                    }
                                    else
                                    {
                                        if (guid == null || guid2 != null)
                                        {
                                            break;
                                        }
                                        flag  = true;
                                        num11 = -2;
                                    }
                                    if (num11 == 0 && num > 0 && num2 > 0 && (num + array3.Length > Globals.MaxCompressionBlockSize || num2 + array4.Length > Globals.MaxCompressionBlockSize))
                                    {
                                        flag2 = true;
                                    }
                                    else
                                    {
                                        if (num11 != 0)
                                        {
                                            flag = true;
                                            if (num11 < 0)
                                            {
                                                this.stats.IncrementRecordsDeletedChurn();
                                            }
                                            else
                                            {
                                                this.stats.IncrementRecordsAddedChurn();
                                            }
                                        }
                                        else if (num3 == 2U && num4 == 2U)
                                        {
                                            string a = (string)DiffFileGenerator.GetHeaderPropertyValue(OABFilePropTags.OabName, array3, propertyDescriptorsBuffer, headerPropertyDescriptorsCount, true);
                                            string b = (string)DiffFileGenerator.GetHeaderPropertyValue(OABFilePropTags.OabName, array4, propertyDescriptorsBuffer2, headerPropertyDescriptorsCount2, false);
                                            flag = (a != b);
                                        }
                                        else if (array3.Length != array4.Length || !array3.SequenceEqual(array4))
                                        {
                                            flag = true;
                                            this.stats.IncrementRecordsModifiedChurn();
                                        }
                                        if (num11 <= 0)
                                        {
                                            if (num + array3.Length <= Globals.MaxCompressionBlockSize || array3.Length > Globals.MaxCompressionBlockSize)
                                            {
                                                DiffFileGenerator.ConsumeRecord(array, ref num, array3, ref num7, ref guid, ref flag2);
                                            }
                                            else
                                            {
                                                flag2 = true;
                                            }
                                        }
                                        if (num11 >= 0)
                                        {
                                            if (num2 + array4.Length <= Globals.MaxCompressionBlockSize || array4.Length > Globals.MaxCompressionBlockSize)
                                            {
                                                DiffFileGenerator.ConsumeRecord(array2, ref num2, array4, ref num8, ref guid2, ref flag2);
                                            }
                                            else
                                            {
                                                flag2 = true;
                                            }
                                        }
                                    }
                                    if (flag2)
                                    {
                                        this.WriteLzxPatch(diffStream, dataPatching, array, num, array2, num2);
                                        num  = 0;
                                        num2 = 0;
                                    }
                                }
                                if (num5 == 0L && num6 != 0L)
                                {
                                }
                                if (num != 0 || num2 != 0)
                                {
                                    this.WriteLzxPatch(diffStream, dataPatching, array, num, array2, num2);
                                }
                                result = flag;
                            }
                        }
                    }
                }
            }
            return(result);
        }