Implements verification on all currently supported disk

images.
	Implements DC42 CRC calculation.
	Calculates TeleDisk CRC for disk sectors.
	Resolves #2 and bumps version to 2.1.
This commit is contained in:
2014-08-25 05:00:25 +01:00
parent fd60149c37
commit 3a03e3121e
13 changed files with 721 additions and 107 deletions

View File

@@ -2010,7 +2010,7 @@ namespace DiscImageChef.ImagePlugins
}
break;
}
// TODO
// TODO
case DAOMode.DataM2RawSub:
throw new FeatureSupportedButNotImplementedImageException("Feature not yet implemented");
case DAOMode.DataRawSub:
@@ -2291,6 +2291,85 @@ namespace DiscImageChef.ImagePlugins
return imageSessions;
}
public override bool? VerifySector(UInt64 sectorAddress)
{
byte[] buffer = ReadSectorLong(sectorAddress);
return Checksums.CDChecksums.CheckCDSector(buffer);
}
public override bool? VerifySector(UInt64 sectorAddress, UInt32 track)
{
byte[] buffer = ReadSectorLong(sectorAddress, track);
return Checksums.CDChecksums.CheckCDSector(buffer);
}
public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, out List<UInt64> FailingLBAs, out List<UInt64> UnknownLBAs)
{
byte[] buffer = ReadSectorsLong(sectorAddress, length);
int bps = (int)(buffer.Length / length);
byte[] sector = new byte[bps];
FailingLBAs = new List<UInt64>();
UnknownLBAs = new List<UInt64>();
for (int i = 0; i < length; i++)
{
Array.Copy(buffer, i * bps, sector, 0, bps);
bool? sectorStatus = Checksums.CDChecksums.CheckCDSector(sector);
switch (sectorStatus)
{
case null:
UnknownLBAs.Add((ulong)i + sectorAddress);
break;
case false:
FailingLBAs.Add((ulong)i + sectorAddress);
break;
}
}
if (UnknownLBAs.Count > 0)
return null;
if (FailingLBAs.Count > 0)
return false;
return true;
}
public override bool? VerifySectors(UInt64 sectorAddress, UInt32 length, UInt32 track, out List<UInt64> FailingLBAs, out List<UInt64> UnknownLBAs)
{
byte[] buffer = ReadSectorsLong(sectorAddress, length, track);
int bps = (int)(buffer.Length / length);
byte[] sector = new byte[bps];
FailingLBAs = new List<UInt64>();
UnknownLBAs = new List<UInt64>();
for (int i = 0; i < length; i++)
{
Array.Copy(buffer, i * bps, sector, 0, bps);
bool? sectorStatus = Checksums.CDChecksums.CheckCDSector(sector);
switch (sectorStatus)
{
case null:
UnknownLBAs.Add((ulong)i + sectorAddress);
break;
case false:
FailingLBAs.Add((ulong)i + sectorAddress);
break;
}
}
if (UnknownLBAs.Count > 0)
return null;
if (FailingLBAs.Count > 0)
return false;
return true;
}
public override bool? VerifyDiskImage()
{
return null;
}
#endregion
#region Private methods