mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Checksum tape images.
This commit is contained in:
@@ -182,7 +182,9 @@ namespace DiscImageChef.Commands
|
||||
|
||||
Checksum mediaChecksum = null;
|
||||
|
||||
if(inputFormat is IOpticalMediaImage opticalInput)
|
||||
switch(inputFormat)
|
||||
{
|
||||
case IOpticalMediaImage opticalInput when opticalInput.Tracks != null:
|
||||
try
|
||||
{
|
||||
Checksum trackChecksum = null;
|
||||
@@ -246,8 +248,8 @@ namespace DiscImageChef.Commands
|
||||
if(separatedTracks)
|
||||
if(trackChecksum != null)
|
||||
foreach(ChecksumType chk in trackChecksum.End())
|
||||
DicConsole.WriteLine("Track {0}'s {1}: {2}", currentTrack.TrackSequence, chk.type,
|
||||
chk.Value);
|
||||
DicConsole.WriteLine("Track {0}'s {1}: {2}", currentTrack.TrackSequence,
|
||||
chk.type, chk.Value);
|
||||
|
||||
previousTrackEnd = currentTrack.TrackEndSector;
|
||||
}
|
||||
@@ -271,7 +273,91 @@ namespace DiscImageChef.Commands
|
||||
if(MainClass.Debug) DicConsole.DebugWriteLine("Could not get tracks because {0}", ex.Message);
|
||||
else DicConsole.WriteLine("Unable to get separate tracks, not checksumming them");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case ITapeImage tapeImage when tapeImage.IsTape && tapeImage.Files?.Count > 0:
|
||||
{
|
||||
Checksum trackChecksum = null;
|
||||
|
||||
if(wholeDisc) mediaChecksum = new Checksum(enabledChecksums);
|
||||
|
||||
ulong previousTrackEnd = 0;
|
||||
|
||||
foreach(TapeFile currentFile in tapeImage.Files)
|
||||
{
|
||||
if(currentFile.FirstBlock - previousTrackEnd != 0 && wholeDisc)
|
||||
for(ulong i = previousTrackEnd + 1; i < currentFile.FirstBlock; i++)
|
||||
{
|
||||
DicConsole.Write("\rHashing track-less sector {0}", i);
|
||||
|
||||
byte[] hiddenSector = inputFormat.ReadSector(i);
|
||||
|
||||
mediaChecksum?.Update(hiddenSector);
|
||||
}
|
||||
|
||||
DicConsole.DebugWriteLine("Checksum command",
|
||||
"Track {0} starts at sector {1} and ends at sector {2}",
|
||||
currentFile.File, currentFile.FirstBlock, currentFile.LastBlock);
|
||||
|
||||
if(separatedTracks) trackChecksum = new Checksum(enabledChecksums);
|
||||
|
||||
ulong sectors = currentFile.LastBlock - currentFile.FirstBlock + 1;
|
||||
ulong doneSectors = 0;
|
||||
DicConsole.WriteLine("File {0} has {1} sectors", currentFile.File, sectors);
|
||||
|
||||
while(doneSectors < sectors)
|
||||
{
|
||||
byte[] sector;
|
||||
|
||||
if(sectors - doneSectors >= SECTORS_TO_READ)
|
||||
{
|
||||
sector = tapeImage.ReadSectors(doneSectors + currentFile.FirstBlock, SECTORS_TO_READ);
|
||||
DicConsole.Write("\rHashings sectors {0} to {2} of file {1}", doneSectors,
|
||||
currentFile.File, doneSectors + SECTORS_TO_READ);
|
||||
doneSectors += SECTORS_TO_READ;
|
||||
}
|
||||
else
|
||||
{
|
||||
sector = tapeImage.ReadSectors(doneSectors + currentFile.FirstBlock,
|
||||
(uint)(sectors - doneSectors));
|
||||
DicConsole.Write("\rHashings sectors {0} to {2} of file {1}", doneSectors,
|
||||
currentFile.File, doneSectors + (sectors - doneSectors));
|
||||
doneSectors += sectors - doneSectors;
|
||||
}
|
||||
|
||||
if(wholeDisc) mediaChecksum?.Update(sector);
|
||||
|
||||
if(separatedTracks) trackChecksum?.Update(sector);
|
||||
}
|
||||
|
||||
DicConsole.WriteLine();
|
||||
|
||||
if(separatedTracks)
|
||||
if(trackChecksum != null)
|
||||
foreach(ChecksumType chk in trackChecksum.End())
|
||||
DicConsole.WriteLine("File {0}'s {1}: {2}", currentFile.File, chk.type, chk.Value);
|
||||
|
||||
previousTrackEnd = currentFile.LastBlock;
|
||||
}
|
||||
|
||||
if(tapeImage.Info.Sectors - previousTrackEnd != 0 && wholeDisc)
|
||||
for(ulong i = previousTrackEnd + 1; i < tapeImage.Info.Sectors; i++)
|
||||
{
|
||||
DicConsole.Write("\rHashing file-less sector {0}", i);
|
||||
|
||||
byte[] hiddenSector = inputFormat.ReadSector(i);
|
||||
mediaChecksum?.Update(hiddenSector);
|
||||
}
|
||||
|
||||
if(wholeDisc)
|
||||
if(mediaChecksum != null)
|
||||
foreach(ChecksumType chk in mediaChecksum.End())
|
||||
DicConsole.WriteLine("Tape's {0}: {1}", chk.type, chk.Value);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
mediaChecksum = new Checksum(enabledChecksums);
|
||||
|
||||
@@ -286,7 +372,8 @@ namespace DiscImageChef.Commands
|
||||
if(sectors - doneSectors >= SECTORS_TO_READ)
|
||||
{
|
||||
sector = inputFormat.ReadSectors(doneSectors, SECTORS_TO_READ);
|
||||
DicConsole.Write("\rHashings sectors {0} to {1}", doneSectors, doneSectors + SECTORS_TO_READ);
|
||||
DicConsole.Write("\rHashings sectors {0} to {1}", doneSectors,
|
||||
doneSectors + SECTORS_TO_READ);
|
||||
doneSectors += SECTORS_TO_READ;
|
||||
}
|
||||
else
|
||||
@@ -304,6 +391,8 @@ namespace DiscImageChef.Commands
|
||||
|
||||
foreach(ChecksumType chk in mediaChecksum.End())
|
||||
DicConsole.WriteLine("Disk's {0}: {1}", chk.type, chk.Value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (int)ErrorNumber.NoError;
|
||||
|
||||
Reference in New Issue
Block a user