mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
General code cleanup and style refactor.
This commit is contained in:
@@ -34,8 +34,6 @@
|
||||
// ReSharper disable InlineOutVariableDeclaration
|
||||
// ReSharper disable TooWideLocalVariableScope
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -52,6 +50,8 @@ using Aaru.Devices;
|
||||
using Schemas;
|
||||
using TrackType = Aaru.CommonTypes.Enums.TrackType;
|
||||
|
||||
namespace Aaru.Core.Devices.Dumping;
|
||||
|
||||
partial class Dump
|
||||
{
|
||||
/// <summary>Reads all CD user data</summary>
|
||||
@@ -101,7 +101,7 @@ partial class Dump
|
||||
ulong sectorSpeedStart = 0; // Used to calculate correct speed
|
||||
DateTime timeSpeedStart = DateTime.UtcNow; // Time of start for speed calculation
|
||||
uint blocksToRead; // How many sectors to read at once
|
||||
var sense = true; // Sense indicator
|
||||
bool sense = true; // Sense indicator
|
||||
byte[] cmdBuf = null; // Data buffer
|
||||
byte[] senseBuf = null; // Sense buffer
|
||||
double cmdDuration = 0; // Command execution time
|
||||
@@ -111,19 +111,19 @@ partial class Dump
|
||||
var outputFormat = _outputPlugin as IWritableImage;
|
||||
|
||||
supportedPlextorSubchannel = supportedSubchannel switch
|
||||
{
|
||||
MmcSubchannel.None => PlextorSubchannel.None,
|
||||
MmcSubchannel.Raw => PlextorSubchannel.Pack,
|
||||
MmcSubchannel.Q16 => PlextorSubchannel.Q16,
|
||||
_ => PlextorSubchannel.None
|
||||
};
|
||||
{
|
||||
MmcSubchannel.None => PlextorSubchannel.None,
|
||||
MmcSubchannel.Raw => PlextorSubchannel.Pack,
|
||||
MmcSubchannel.Q16 => PlextorSubchannel.Q16,
|
||||
_ => PlextorSubchannel.None
|
||||
};
|
||||
|
||||
InitProgress?.Invoke();
|
||||
|
||||
int currentReadSpeed = _speed;
|
||||
var crossingLeadOut = false;
|
||||
var failedCrossingLeadOut = false;
|
||||
var skippingLead = false;
|
||||
int currentReadSpeed = _speed;
|
||||
bool crossingLeadOut = false;
|
||||
bool failedCrossingLeadOut = false;
|
||||
bool skippingLead = false;
|
||||
|
||||
for(ulong i = _resume.NextBlock; (long)i <= lastSector; i += blocksToRead)
|
||||
{
|
||||
@@ -145,7 +145,7 @@ partial class Dump
|
||||
if((long)i > lastSector)
|
||||
break;
|
||||
|
||||
var firstSectorToRead = (uint)i;
|
||||
uint firstSectorToRead = (uint)i;
|
||||
|
||||
Track track = tracks.OrderBy(t => t.StartSector).LastOrDefault(t => i >= t.StartSector);
|
||||
|
||||
@@ -298,10 +298,10 @@ partial class Dump
|
||||
// Try to workaround firmware
|
||||
if(decSense?.ASC == 0x64)
|
||||
{
|
||||
var goBackTrackTypeChange = false;
|
||||
bool goBackTrackTypeChange = false;
|
||||
|
||||
// Go one for one as the drive does not tell us which one failed
|
||||
for(var bi = 0; bi < blocksToRead; bi++)
|
||||
for(int bi = 0; bi < blocksToRead; bi++)
|
||||
{
|
||||
sense = _dev.ReadCd(out cmdBuf, out senseBuf, (uint)(firstSectorToRead + bi), blockSize,
|
||||
1, MmcSectorTypes.AllTypes, false, false, true,
|
||||
@@ -424,7 +424,7 @@ partial class Dump
|
||||
|
||||
if(_supportsPlextorD8)
|
||||
{
|
||||
var adjustment = 0;
|
||||
int adjustment = 0;
|
||||
|
||||
if(offsetBytes < 0)
|
||||
adjustment = -sectorsForOffset;
|
||||
@@ -438,7 +438,7 @@ partial class Dump
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
var sectorsForFix = (uint)(1 + sectorsForOffset);
|
||||
uint sectorsForFix = (uint)(1 + sectorsForOffset);
|
||||
|
||||
FixOffsetData(offsetBytes, sectorSize, sectorsForOffset, supportedSubchannel,
|
||||
ref sectorsForFix, subSize, ref cmdBuf, blockSize, false);
|
||||
@@ -479,8 +479,8 @@ partial class Dump
|
||||
|
||||
if(supportedSubchannel != MmcSubchannel.None)
|
||||
{
|
||||
var data = new byte[sectorSize];
|
||||
var sub = new byte[subSize];
|
||||
byte[] data = new byte[sectorSize];
|
||||
byte[] sub = new byte[subSize];
|
||||
|
||||
Array.Copy(cmdBuf, 0, data, 0, sectorSize);
|
||||
|
||||
@@ -490,12 +490,12 @@ partial class Dump
|
||||
outputFormat.WriteSectorsLong(data, i + r, 1);
|
||||
else
|
||||
{
|
||||
var cooked = new MemoryStream();
|
||||
var sector = new byte[sectorSize];
|
||||
var cooked = new MemoryStream();
|
||||
byte[] sector = new byte[sectorSize];
|
||||
|
||||
for(var b = 0; b < blocksToRead; b++)
|
||||
for(int b = 0; b < blocksToRead; b++)
|
||||
{
|
||||
Array.Copy(cmdBuf, (int)(0 + b * blockSize), sector, 0, sectorSize);
|
||||
Array.Copy(cmdBuf, (int)(0 + (b * blockSize)), sector, 0, sectorSize);
|
||||
byte[] cookedSector = Sector.GetUserData(sector);
|
||||
cooked.Write(cookedSector, 0, cookedSector.Length);
|
||||
}
|
||||
@@ -537,10 +537,10 @@ partial class Dump
|
||||
outputFormat.WriteSectorsLong(cmdBuf, i + r, 1);
|
||||
else
|
||||
{
|
||||
var cooked = new MemoryStream();
|
||||
var sector = new byte[sectorSize];
|
||||
var cooked = new MemoryStream();
|
||||
byte[] sector = new byte[sectorSize];
|
||||
|
||||
for(var b = 0; b < blocksToRead; b++)
|
||||
for(int b = 0; b < blocksToRead; b++)
|
||||
{
|
||||
Array.Copy(cmdBuf, (int)(b * sectorSize), sector, 0, sectorSize);
|
||||
byte[] cookedSector = Sector.GetUserData(sector);
|
||||
@@ -615,7 +615,7 @@ partial class Dump
|
||||
{
|
||||
if(crossingLeadOut && failedCrossingLeadOut)
|
||||
{
|
||||
var tmp = new byte[cmdBuf.Length + blockSize];
|
||||
byte[] tmp = new byte[cmdBuf.Length + blockSize];
|
||||
Array.Copy(cmdBuf, 0, tmp, 0, cmdBuf.Length);
|
||||
}
|
||||
|
||||
@@ -633,26 +633,26 @@ partial class Dump
|
||||
|
||||
if(supportedSubchannel != MmcSubchannel.None)
|
||||
{
|
||||
var data = new byte[sectorSize * blocksToRead];
|
||||
var sub = new byte[subSize * blocksToRead];
|
||||
byte[] data = new byte[sectorSize * blocksToRead];
|
||||
byte[] sub = new byte[subSize * blocksToRead];
|
||||
|
||||
for(var b = 0; b < blocksToRead; b++)
|
||||
for(int b = 0; b < blocksToRead; b++)
|
||||
{
|
||||
Array.Copy(cmdBuf, (int)(0 + b * blockSize), data, sectorSize * b, sectorSize);
|
||||
Array.Copy(cmdBuf, (int)(0 + (b * blockSize)), data, sectorSize * b, sectorSize);
|
||||
|
||||
Array.Copy(cmdBuf, (int)(sectorSize + b * blockSize), sub, subSize * b, subSize);
|
||||
Array.Copy(cmdBuf, (int)(sectorSize + (b * blockSize)), sub, subSize * b, subSize);
|
||||
}
|
||||
|
||||
if(supportsLongSectors)
|
||||
outputFormat.WriteSectorsLong(data, i, blocksToRead);
|
||||
else
|
||||
{
|
||||
var cooked = new MemoryStream();
|
||||
var sector = new byte[sectorSize];
|
||||
var cooked = new MemoryStream();
|
||||
byte[] sector = new byte[sectorSize];
|
||||
|
||||
for(var b = 0; b < blocksToRead; b++)
|
||||
for(int b = 0; b < blocksToRead; b++)
|
||||
{
|
||||
Array.Copy(cmdBuf, (int)(0 + b * blockSize), sector, 0, sectorSize);
|
||||
Array.Copy(cmdBuf, (int)(0 + (b * blockSize)), sector, 0, sectorSize);
|
||||
byte[] cookedSector = Sector.GetUserData(sector);
|
||||
cooked.Write(cookedSector, 0, cookedSector.Length);
|
||||
}
|
||||
@@ -661,10 +661,10 @@ partial class Dump
|
||||
}
|
||||
|
||||
bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel,
|
||||
desiredSubchannel, sub, i, blocksToRead, subLog, isrcs, (byte)track.Sequence, ref mcn,
|
||||
tracks, subchannelExtents, _fixSubchannelPosition, outputFormat as IWritableOpticalImage,
|
||||
_fixSubchannel, _fixSubchannelCrc, _dumpLog, UpdateStatus, smallestPregapLbaPerTrack, true,
|
||||
out List<ulong> newPregapSectors);
|
||||
desiredSubchannel, sub, i, blocksToRead, subLog, isrcs, (byte)track.Sequence, ref mcn,
|
||||
tracks, subchannelExtents, _fixSubchannelPosition, outputFormat as IWritableOpticalImage,
|
||||
_fixSubchannel, _fixSubchannelCrc, _dumpLog, UpdateStatus, smallestPregapLbaPerTrack, true,
|
||||
out List<ulong> newPregapSectors);
|
||||
|
||||
// Set tracks and go back
|
||||
if(indexesChanged)
|
||||
@@ -694,10 +694,10 @@ partial class Dump
|
||||
outputFormat.WriteSectorsLong(cmdBuf, i, blocksToRead);
|
||||
else
|
||||
{
|
||||
var cooked = new MemoryStream();
|
||||
var sector = new byte[sectorSize];
|
||||
var cooked = new MemoryStream();
|
||||
byte[] sector = new byte[sectorSize];
|
||||
|
||||
for(var b = 0; b < blocksToRead; b++)
|
||||
for(int b = 0; b < blocksToRead; b++)
|
||||
{
|
||||
Array.Copy(cmdBuf, (int)(b * sectorSize), sector, 0, sectorSize);
|
||||
byte[] cookedSector = Sector.GetUserData(sector);
|
||||
|
||||
Reference in New Issue
Block a user