mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Do not fix offset in CD dumping if sector has not been read correctly.
This commit is contained in:
@@ -229,73 +229,77 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
_dev.Timeout, out cmdDuration);
|
||||
}
|
||||
|
||||
// Because one block has been partially used to fix the offset
|
||||
if(_fixOffset &&
|
||||
!inData &&
|
||||
offsetBytes != 0)
|
||||
{
|
||||
int offsetFix = offsetBytes < 0 ? (int)(sectorSize - (offsetBytes * -1)) : offsetBytes;
|
||||
|
||||
if(supportedSubchannel != MmcSubchannel.None)
|
||||
{
|
||||
// De-interleave subchannel
|
||||
byte[] data = new byte[sectorSize * blocksToRead];
|
||||
byte[] sub = new byte[subSize * blocksToRead];
|
||||
|
||||
for(int b = 0; b < blocksToRead; b++)
|
||||
{
|
||||
Array.Copy(cmdBuf, (int)(0 + (b * blockSize)), data, sectorSize * b, sectorSize);
|
||||
Array.Copy(cmdBuf, (int)(sectorSize + (b * blockSize)), sub, subSize * b, subSize);
|
||||
}
|
||||
|
||||
if(failedCrossingLeadOut)
|
||||
{
|
||||
blocksToRead += (uint)sectorsForOffset;
|
||||
|
||||
tmpBuf = new byte[sectorSize * blocksToRead];
|
||||
Array.Copy(data, 0, tmpBuf, 0, data.Length);
|
||||
data = tmpBuf;
|
||||
tmpBuf = new byte[subSize * blocksToRead];
|
||||
Array.Copy(sub, 0, tmpBuf, 0, sub.Length);
|
||||
sub = tmpBuf;
|
||||
}
|
||||
|
||||
tmpBuf = new byte[sectorSize * (blocksToRead - sectorsForOffset)];
|
||||
Array.Copy(data, offsetFix, tmpBuf, 0, tmpBuf.Length);
|
||||
data = tmpBuf;
|
||||
|
||||
blocksToRead -= (uint)sectorsForOffset;
|
||||
|
||||
// Re-interleave subchannel
|
||||
cmdBuf = new byte[blockSize * blocksToRead];
|
||||
|
||||
for(int b = 0; b < blocksToRead; b++)
|
||||
{
|
||||
Array.Copy(data, sectorSize * b, cmdBuf, (int)(0 + (b * blockSize)), sectorSize);
|
||||
Array.Copy(sub, subSize * b, cmdBuf, (int)(sectorSize + (b * blockSize)), subSize);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(failedCrossingLeadOut)
|
||||
{
|
||||
blocksToRead += (uint)sectorsForOffset;
|
||||
|
||||
tmpBuf = new byte[blockSize * blocksToRead];
|
||||
Array.Copy(cmdBuf, 0, tmpBuf, 0, cmdBuf.Length);
|
||||
cmdBuf = tmpBuf;
|
||||
}
|
||||
|
||||
tmpBuf = new byte[blockSize * (blocksToRead - sectorsForOffset)];
|
||||
Array.Copy(cmdBuf, offsetFix, tmpBuf, 0, tmpBuf.Length);
|
||||
cmdBuf = tmpBuf;
|
||||
blocksToRead -= (uint)sectorsForOffset;
|
||||
}
|
||||
}
|
||||
|
||||
if(!sense &&
|
||||
!_dev.Error)
|
||||
{
|
||||
// Because one block has been partially used to fix the offset
|
||||
if(_fixOffset &&
|
||||
!inData &&
|
||||
offsetBytes != 0)
|
||||
{
|
||||
int offsetFix = offsetBytes < 0 ? (int)(sectorSize - (offsetBytes * -1)) : offsetBytes;
|
||||
|
||||
if(supportedSubchannel != MmcSubchannel.None)
|
||||
{
|
||||
// De-interleave subchannel
|
||||
byte[] data = new byte[sectorSize * blocksToRead];
|
||||
byte[] sub = new byte[subSize * blocksToRead];
|
||||
|
||||
for(int b = 0; b < blocksToRead; b++)
|
||||
{
|
||||
Array.Copy(cmdBuf, (int)(0 + (b * blockSize)), data, sectorSize * b,
|
||||
sectorSize);
|
||||
|
||||
Array.Copy(cmdBuf, (int)(sectorSize + (b * blockSize)), sub, subSize * b, subSize);
|
||||
}
|
||||
|
||||
if(failedCrossingLeadOut)
|
||||
{
|
||||
blocksToRead += (uint)sectorsForOffset;
|
||||
|
||||
tmpBuf = new byte[sectorSize * blocksToRead];
|
||||
Array.Copy(data, 0, tmpBuf, 0, data.Length);
|
||||
data = tmpBuf;
|
||||
tmpBuf = new byte[subSize * blocksToRead];
|
||||
Array.Copy(sub, 0, tmpBuf, 0, sub.Length);
|
||||
sub = tmpBuf;
|
||||
}
|
||||
|
||||
tmpBuf = new byte[sectorSize * (blocksToRead - sectorsForOffset)];
|
||||
Array.Copy(data, offsetFix, tmpBuf, 0, tmpBuf.Length);
|
||||
data = tmpBuf;
|
||||
|
||||
blocksToRead -= (uint)sectorsForOffset;
|
||||
|
||||
// Re-interleave subchannel
|
||||
cmdBuf = new byte[blockSize * blocksToRead];
|
||||
|
||||
for(int b = 0; b < blocksToRead; b++)
|
||||
{
|
||||
Array.Copy(data, sectorSize * b, cmdBuf, (int)(0 + (b * blockSize)),
|
||||
sectorSize);
|
||||
|
||||
Array.Copy(sub, subSize * b, cmdBuf, (int)(sectorSize + (b * blockSize)), subSize);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(failedCrossingLeadOut)
|
||||
{
|
||||
blocksToRead += (uint)sectorsForOffset;
|
||||
|
||||
tmpBuf = new byte[blockSize * blocksToRead];
|
||||
Array.Copy(cmdBuf, 0, tmpBuf, 0, cmdBuf.Length);
|
||||
cmdBuf = tmpBuf;
|
||||
}
|
||||
|
||||
tmpBuf = new byte[blockSize * (blocksToRead - sectorsForOffset)];
|
||||
Array.Copy(cmdBuf, offsetFix, tmpBuf, 0, tmpBuf.Length);
|
||||
cmdBuf = tmpBuf;
|
||||
blocksToRead -= (uint)sectorsForOffset;
|
||||
}
|
||||
}
|
||||
|
||||
mhddLog.Write(i, cmdDuration);
|
||||
ibgLog.Write(i, currentSpeed * 1024);
|
||||
extents.Add(i, blocksToRead, true);
|
||||
|
||||
Reference in New Issue
Block a user