Ejemplo n.º 1
0
        private void DisplayResults(ValidationResults results)
        {
            Console.WriteLine("ROM file {0}", results.ROMFilePath);

            if (results.HasChanged)
            {
                Console.WriteLine("Checksum updated from 0x{0:X4} to 0x{1:X4}", results.ActualChecksum, results.CalculatedChecksum);
            }
            else
            {
                Console.WriteLine("Checksum is correct (0x{0:X4}), no changes made", results.ActualChecksum);
            }
        }
Ejemplo n.º 2
0
        public async Task<ValidationResults> ValidateChecksum(string filePath)
        {
            ValidationResults results = new ValidationResults() { ROMFilePath = filePath };

            // Load ROM content
            ROM rom = new ROM(new BinROMLoader(filePath, new BinROMValidator()));
            await rom.LoadAsync();

            // Get the checksum from the ROM. Also run a checksum calculation and compare the results. If not the same,
            // update the ROM and save it
            results.ActualChecksum = rom.Checksum;
            results.CalculatedChecksum = rom.CalculateChecksum();
            results.HasChanged = results.ActualChecksum != results.CalculatedChecksum;

            if (results.ActualChecksum != results.CalculatedChecksum)
            {
                rom.Checksum = results.CalculatedChecksum;
                await rom.SaveAsync();
            }

            return results;
        }