/***************************************************************************
The Disc Image Chef
----------------------------------------------------------------------------
Filename : Verify.cs
Version : 1.0
Author(s) : Natalia Portillo
Component : Verbs.
Revision : $Revision$
Last change by : $Author$
Date : $Date$
--[ Description ] ----------------------------------------------------------
Implements the 'verify' verb.
--[ License ] --------------------------------------------------------------
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
----------------------------------------------------------------------------
Copyright (C) 2011-2014 Claunia.com
****************************************************************************/
//$Id$
using System;
using DiscImageChef.ImagePlugins;
using System.Collections.Generic;
namespace DiscImageChef.Commands
{
public static class Verify
{
public static void doVerify(VerifySubOptions options)
{
if (MainClass.isDebug)
{
Console.WriteLine("--debug={0}", options.Debug);
Console.WriteLine("--verbose={0}", options.Verbose);
Console.WriteLine("--input={0}", options.InputFile);
Console.WriteLine("--verify-disc={0}", options.VerifyDisc);
Console.WriteLine("--verify-sectors={0}", options.VerifySectors);
}
ImagePlugin inputFormat = ImageFormat.Detect(options.InputFile);
if (inputFormat == null)
{
Console.WriteLine("Unable to recognize image format, not verifying");
return;
}
inputFormat.OpenImage(options.InputFile);
if (options.VerifyDisc)
{
DateTime StartCheck = DateTime.UtcNow;
bool? discCheckStatus = inputFormat.VerifyDiskImage();
DateTime EndCheck = DateTime.UtcNow;
TimeSpan CheckTime = EndCheck - StartCheck;
switch (discCheckStatus)
{
case true:
Console.WriteLine("Disc image checksums are correct");
break;
case false:
Console.WriteLine("Disc image checksums are incorrect");
break;
case null:
Console.WriteLine("Disc image does not contain checksums");
break;
}
if (MainClass.isVerbose)
Console.WriteLine("Checking disc image checksums took {0} seconds", CheckTime.TotalSeconds);
}
if (options.VerifySectors)
{
bool formatHasTracks;
try
{
List