Пример #1
0
        public int Run()
        {
            var    engine = new FileVerifier.FVEngine();
            string checksum;

            try
            {
                checksum = engine.GetChecksum(opts.File);
            }
            catch (FileNotFoundException)
            {
                return(SourceNotFound(opts.File));
            }
            catch (WebException)
            {
                return(SourceNotFound(opts.File));
            }
            catch (Exception e)
            {
                MsgLine("Failed to calculate checksum");
                return(ChecksumError(e));
            }
            Console.WriteLine(checksum);
            return(Success());
        }
Пример #2
0
        private int RunSingleFile(string file, string exp_checksum)
        {
            Msg($"'{file}' ... ");
            string rec_checksum;

            try
            {
                rec_checksum = engine.GetChecksum(file);
            }
            catch (Exception e)
            {
                return(ChecksumError(e));
            }
            var match = rec_checksum == exp_checksum;

            if (match)
            {
                MsgLine($"Verified.");
                return(Success());
            }
            else
            {
                MsgLine("Failed");
                MsgLine($"    Expected {exp_checksum}, Got: {rec_checksum}");
                return(Fail());
            }
        }