Exemplo n.º 1
0
        private static bool PackageDiff(string file_a, string file_b)
        {
            var a = new Package();
            var b = new Package();
            if (a.TryOpen(file_a) && b.TryOpen(file_b))
            {
                if (a.header.Count != b.header.Count)
                    return false;

                int count = a.header.Count;
                for (int i = 0; i < count; i++)
                {
                    if (a.header[i].Item1 != b.header[i].Item1 || // file name
                        a.header[i].Item2 != b.header[i].Item2 || // file offset
                        a.header[i].Item3 != b.header[i].Item3)  // file length
                        return false;
                }

                using (var sw = new StreamWriter(file_b + "_patch.txt"))
                {
                    for (int i = 0; i < count; i++)
                    {
                        var ba = a.blocks[i];
                        var bb = b.blocks[i];
                        var dataend = ba.Length - 2; // ignore CRC at end of block

                        CompareBlock(ba, bb, i, dataend, sw);
                    }
                }

                return true;
            }

            return false;
        }