Esempio n. 1
0
        public RCH2Compare(ref RCH2Container file1, ref RCH2Container file2, bool doCompare)
        {
            SourceContainer1 = file1;
            SourceContainer2 = file2;

            if (doCompare)
            {
                Compare();
            }
        }
        public static long FindContainer(ref BinaryReader br)
        {
            // Try the known offsets first.
            foreach (long offset in RCH2_OFFSETS)
            {
                br.BaseStream.Position = offset;
                if (RCH2Container.CheckMagicNumber(ref br))
                {
                    br.BaseStream.Position = offset;
                    return(offset);
                }
            }

            // If we didn't find the right magic number yet, go through the
            // entire file. This is kinda tedious.
            br.BaseStream.Position = 0;

            string extended_magic = RCH2Container.MAGIC_NUMBER + RCH2File.MAGIC_NUMBER;

            byte[] buffer = new byte[0];
            int    j      = 0;
            int    i      = 0;

            while (i < extended_magic.Length)
            {
                // If we ran out of buffer, get some more from the file.
                if (j >= buffer.Length)
                {
                    if (br.BaseStream.Position >= br.BaseStream.Length)
                    {
                        return(-1); // Failed to locate.
                    }
                    buffer = br.ReadBytes(SEARCH_BUFFER_LENGTH);
                    j      = 0;
                }

                i = (buffer[j++] == extended_magic[i]) ? i + 1 : 0;
            }

            return(br.BaseStream.Position - buffer.Length + j - i);
        }
Esempio n. 3
0
 /*** Constructor ***/
 public RCH2Compare(ref RCH2Container file1, ref RCH2Container file2) : this(ref file1, ref file2, true)
 {
 }
Esempio n. 4
0
 public CompareFile(ref RCH2Container rch2)
 {
     Container      = rch2;
     DifferentFiles = new List <RCH2File>();
     UniqueFiles    = new List <RCH2File>();
 }