private string CompareCHUNK(Bundle.chunktype chunk, Bundle.chunktype chunk2, bool cdiff, out bool diff)
        {
            StringBuilder sb    = new StringBuilder();
            bool          tdiff = false;

            sb.Append("  D:chunk " + Helpers.ByteArrayToHexString(chunk.id) + "\n");
            if (chunk.baseSha1 != null && !Helpers.ByteArrayCompare(chunk.baseSha1, chunk2.baseSha1))
            {
                sb.AppendFormat("  D:-chunk basesha1 is different - ({0}) vs ({1})\n", Helpers.ByteArrayToHexString(chunk.baseSha1), Helpers.ByteArrayToHexString(chunk2.baseSha1));
                tdiff = true;
            }
            if (chunk.deltaSha1 != null && !Helpers.ByteArrayCompare(chunk.deltaSha1, chunk2.deltaSha1))
            {
                sb.AppendFormat("  D:-chunk deltasha1 is different - ({0}) vs ({1})\n", Helpers.ByteArrayToHexString(chunk.deltaSha1), Helpers.ByteArrayToHexString(chunk2.deltaSha1));
                tdiff = true;
            }
            if (chunk.SHA1 != null && !Helpers.ByteArrayCompare(chunk.SHA1, chunk2.SHA1))
            {
                sb.AppendFormat("  D:-chunk sha1 is different - ({0}) vs ({1})\n", Helpers.ByteArrayToHexString(chunk.SHA1), Helpers.ByteArrayToHexString(chunk2.SHA1));
                tdiff = true;
            }
            if (chunk.size != null && !Helpers.ByteArrayCompare(chunk.size, chunk2.size))
            {
                sb.AppendFormat("  D:-chunk size is different - ({0}) vs ({1})\n", BitConverter.ToInt32(chunk.size, 0), BitConverter.ToInt32(chunk2.size, 0));
                tdiff = true;
            }
            if (chunk.casPatchType != chunk2.casPatchType)
            {
                sb.AppendFormat("  D:-chunk caspatchtype is different - ({0}) vs ({1})\n", chunk.casPatchType, chunk2.casPatchType);
                tdiff = true;
            }
            if (tdiff)
            {
                diff = true;
                return(sb.ToString());
            }
            else
            {
                diff = cdiff;
                return("");
            }
        }
        private void CompareSB(string file1, string file2)
        {
            if (!File.Exists(file1) || !File.Exists(file2))
            {
                return;
            }
            SBFile sb1 = new SBFile(file1);
            SBFile sb2 = new SBFile(file2);

            foreach (Bundle b in sb1.bundles)
            {
                Bundle b2 = null;
                foreach (Bundle c in sb2.bundles)
                {
                    if (c.path == b.path)
                    {
                        b2 = c;
                        break;
                    }
                }
                if (b2 == null)
                {
                    continue;
                }
                StringBuilder sb = new StringBuilder();
                sb.Append(" D:bundle " + b.path + "\n");
                bool diff = false;
                foreach (Bundle.ebxtype ebx in b.ebx)
                {
                    Bundle.ebxtype ebx2 = new Bundle.ebxtype();
                    ebx2.name = "";
                    foreach (Bundle.ebxtype compare in b2.ebx)
                    {
                        if (ebx.name == compare.name)
                        {
                            ebx2 = compare;
                            break;
                        }
                    }
                    if (ebx2.name == "")
                    {
                        sb.Append("  E:ebx not found - " + ebx.name + "\n");
                        continue;
                    }
                    sb.Append(CompareEBX(ebx, ebx2, diff, out diff));
                }
                foreach (Bundle.restype res in b.res)
                {
                    Bundle.restype res2 = new Bundle.restype();
                    res2.name = "";
                    foreach (Bundle.restype compare in b2.res)
                    {
                        if (res.name == compare.name)
                        {
                            res2 = compare;
                            break;
                        }
                    }
                    if (res2.name == "")
                    {
                        sb.Append("  E:res not found - " + res.name + "\n");
                        continue;
                    }
                    sb.Append(CompareRES(res, res2, diff, out diff));
                }
                foreach (Bundle.chunktype chunk in b.chunk)
                {
                    Bundle.chunktype chunk2 = new Bundle.chunktype();
                    chunk2.id = new byte[0];
                    foreach (Bundle.chunktype compare in b2.chunk)
                    {
                        if (Helpers.ByteArrayCompare(chunk.id, compare.id))
                        {
                            chunk2 = compare;
                            break;
                        }
                    }
                    if (chunk2.id.Length == 0)
                    {
                        sb.Append("  E:chunk not found - " + Helpers.ByteArrayToHexString(chunk.id) + "\n");
                        continue;
                    }
                    sb.Append(CompareCHUNK(chunk, chunk2, diff, out diff));
                }
                if (diff)
                {
                    P(sb.ToString());
                }
            }
        }