Redo Reformat and cleanup.

Rider EAP was having a bug interpreting .editorconfig that didn't generate the code style as we wanted.
This is now done with Rider-stable.
This commit is contained in:
2023-10-04 17:34:40 +01:00
parent bc8bf7a2dc
commit 7363a5d9c5
453 changed files with 7241 additions and 7126 deletions

View File

@@ -182,8 +182,7 @@ public partial class Dump
_dev.PlatformId, ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision,
_private, _force);
if(currentTry == null ||
extents == null)
if(currentTry == null || extents == null)
{
StoppingErrorMessage?.Invoke(Localization.Core.Could_not_process_resume_file_not_continuing);
@@ -249,7 +248,8 @@ public partial class Dump
_dumpLog.WriteLine(outputFormat.ErrorMessage);
StoppingErrorMessage?.Invoke(Localization.Core.Error_creating_output_image_not_continuing +
Environment.NewLine + outputFormat.ErrorMessage);
Environment.NewLine +
outputFormat.ErrorMessage);
return;
}
@@ -316,19 +316,15 @@ public partial class Dump
if(blocks - i < blocksToRead)
blocksToRead = (byte)(blocks - i);
if(currentSpeed > maxSpeed &&
currentSpeed > 0)
if(currentSpeed > maxSpeed && currentSpeed > 0)
maxSpeed = currentSpeed;
if(currentSpeed < minSpeed &&
currentSpeed > 0)
if(currentSpeed < minSpeed && currentSpeed > 0)
minSpeed = currentSpeed;
UpdateProgress?.
Invoke(
string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks,
ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i, (long)blocks);
Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i, (long)blocks);
bool error = ataReader.ReadBlocks(out cmdBuf, i, blocksToRead, out duration, out _, out _);
@@ -401,19 +397,18 @@ public partial class Dump
_dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
_dumpLog.WriteLine(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalDuration.Milliseconds()).
ByteSize.FromBytes(blockSize * (blocks + 1)).
Per(totalDuration.Milliseconds()).
Humanize());
_dumpLog.WriteLine(string.Format(Localization.Core.Average_write_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).
Per(imageWriteDuration.Seconds()).Humanize()));
Per(imageWriteDuration.Seconds()).
Humanize()));
#region Trimming
if(_resume.BadBlocks.Count > 0 &&
!_aborted &&
_trim &&
newTrim)
if(_resume.BadBlocks.Count > 0 && !_aborted && _trim && newTrim)
{
_trimStopwatch.Restart();
UpdateStatus?.Invoke(Localization.Core.Trimming_skipped_sectors);
@@ -463,9 +458,7 @@ public partial class Dump
#region Error handling
if(_resume.BadBlocks.Count > 0 &&
!_aborted &&
_retryPasses > 0)
if(_resume.BadBlocks.Count > 0 && !_aborted && _retryPasses > 0)
{
var pass = 1;
var forward = true;
@@ -489,10 +482,8 @@ public partial class Dump
{
PulseProgress?.Invoke(_persistent
? string.
Format(
Localization.Core.
Retrying_sector_0_pass_1_recovering_partial_data_forward,
badSector, pass)
Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_forward,
badSector, pass)
: string.
Format(Localization.Core.Retrying_sector_0_pass_1_forward,
badSector, pass));
@@ -501,10 +492,8 @@ public partial class Dump
{
PulseProgress?.Invoke(_persistent
? string.
Format(
Localization.Core.
Retrying_sector_0_pass_1_recovering_partial_data_reverse,
badSector, pass)
Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_reverse,
badSector, pass)
: string.
Format(Localization.Core.Retrying_sector_0_pass_1_reverse,
badSector, pass));
@@ -533,9 +522,7 @@ public partial class Dump
outputFormat.WriteSector(cmdBuf, badSector);
}
if(pass < _retryPasses &&
!_aborted &&
_resume.BadBlocks.Count > 0)
if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0)
{
pass++;
forward = !forward;
@@ -601,18 +588,17 @@ public partial class Dump
break;
}
if(currentSpeed > maxSpeed &&
currentSpeed > 0)
if(currentSpeed > maxSpeed && currentSpeed > 0)
maxSpeed = currentSpeed;
if(currentSpeed < minSpeed &&
currentSpeed > 0)
if(currentSpeed < minSpeed && currentSpeed > 0)
minSpeed = currentSpeed;
PulseProgress?.
Invoke(string.Format(Localization.Core.Reading_cylinder_0_head_1_sector_2_3, cy, hd,
sc,
ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).
ByteSize.FromMegabytes(currentSpeed).
Per(_oneSecond).
Humanize()));
bool error =
@@ -627,8 +613,7 @@ public partial class Dump
mhddLog.Write(currentBlock, duration);
ibgLog.Write(currentBlock, currentSpeed * 1024);
outputFormat.WriteSector(cmdBuf,
(ulong)((cy * heads + hd) * sectors + (sc - 1)));
outputFormat.WriteSector(cmdBuf, (ulong)((cy * heads + hd) * sectors + (sc - 1)));
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
extents.Add(currentBlock);
@@ -692,11 +677,13 @@ public partial class Dump
_dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
_dumpLog.WriteLine(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalDuration.Milliseconds()).
ByteSize.FromBytes(blockSize * (blocks + 1)).
Per(totalDuration.Milliseconds()).
Humanize());
_dumpLog.WriteLine(Localization.Core.Average_write_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).Per(imageWriteDuration.Seconds()).
ByteSize.FromBytes(blockSize * (blocks + 1)).
Per(imageWriteDuration.Seconds()).
Humanize());
}
@@ -714,7 +701,8 @@ public partial class Dump
if(!outputFormat.SetImageInfo(metadata))
{
ErrorMessage?.Invoke(Localization.Core.Error_0_setting_metadata + Environment.NewLine +
ErrorMessage?.Invoke(Localization.Core.Error_0_setting_metadata +
Environment.NewLine +
outputFormat.ErrorMessage);
}
@@ -745,12 +733,10 @@ public partial class Dump
outputFormat.WriteMediaTag(ataIdentify, MediaTagType.ATA_IDENTIFY);
if(_dev.IsUsb &&
_dev.UsbDescriptors != null)
if(_dev.IsUsb && _dev.UsbDescriptors != null)
outputFormat.WriteMediaTag(_dev.UsbDescriptors, MediaTagType.USB_Descriptors);
if(_dev.IsPcmcia &&
_dev.Cis != null)
if(_dev.IsPcmcia && _dev.Cis != null)
outputFormat.WriteMediaTag(_dev.Cis, MediaTagType.PCMCIA_CIS);
if(_metadata)
@@ -791,8 +777,7 @@ public partial class Dump
sidecar = _preSidecar;
}
if(_dev.IsUsb &&
_dev.UsbDescriptors != null)
if(_dev.IsUsb && _dev.UsbDescriptors != null)
{
_dumpLog.WriteLine(Localization.Core.Reading_USB_descriptors);
UpdateStatus?.Invoke(Localization.Core.Reading_USB_descriptors);
@@ -810,8 +795,7 @@ public partial class Dump
};
}
if(_dev.IsPcmcia &&
_dev.Cis != null)
if(_dev.IsPcmcia && _dev.Cis != null)
{
_dumpLog.WriteLine(Localization.Core.Reading_PCMCIA_CIS);
UpdateStatus?.Invoke(Localization.Core.Reading_PCMCIA_CIS);
@@ -900,7 +884,8 @@ public partial class Dump
_dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).
Per(totalChkDuration.Milliseconds()).Humanize());
Per(totalChkDuration.Milliseconds()).
Humanize());
List<(ulong start, string type)> filesystems = new();
@@ -915,10 +900,11 @@ public partial class Dump
if(filesystems.Count > 0)
{
foreach(var filesystem in filesystems.Select(o => new
{
o.start,
o.type
}).Distinct())
{
o.start,
o.type
}).
Distinct())
{
UpdateStatus?.Invoke(string.Format(Localization.Core.Found_filesystem_0_at_sector_1,
filesystem.type, filesystem.start));
@@ -944,9 +930,7 @@ public partial class Dump
sidecar.BlockMedias[0].Size = blocks * blockSize;
if(cylinders > 0 &&
heads > 0 &&
sectors > 0)
if(cylinders > 0 && heads > 0 && sectors > 0)
{
sidecar.BlockMedias[0].Cylinders = cylinders;
sidecar.BlockMedias[0].Heads = heads;
@@ -969,18 +953,17 @@ public partial class Dump
UpdateStatus?.Invoke("");
UpdateStatus?.
Invoke(string.Format(
Localization.Core.
Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing,
_dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second),
totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second),
_imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing,
_dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second),
totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second),
_imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).
Per(totalDuration.Milliseconds()).Humanize()));
Per(totalDuration.Milliseconds()).
Humanize()));
if(maxSpeed > 0)
{

View File

@@ -59,7 +59,10 @@ partial class Dump
if(sector?.Length != 2352)
return false;
byte[] syncMark = { 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00 };
byte[] syncMark =
{
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00
};
var testMark = new byte[12];
Array.Copy(sector, 0, testMark, 0, 12);
@@ -79,7 +82,10 @@ partial class Dump
if(sector?.Length != 2352)
return false;
byte[] syncMark = { 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00 };
byte[] syncMark =
{
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00
};
var testMark = new byte[12];
@@ -202,19 +208,15 @@ partial class Dump
}
}
if(currentSpeed > maxSpeed &&
currentSpeed > 0)
if(currentSpeed > maxSpeed && currentSpeed > 0)
maxSpeed = currentSpeed;
if(currentSpeed < minSpeed &&
currentSpeed > 0)
if(currentSpeed < minSpeed && currentSpeed > 0)
minSpeed = currentSpeed;
UpdateProgress?.
Invoke(
string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks,
ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i, (long)blocks);
Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i, (long)blocks);
sense = _dev.ReadCd(out cmdBuf, out senseBuf, firstSectorToRead, blockSize, blocksToRead,
MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, true,
@@ -230,10 +232,8 @@ partial class Dump
for(uint r = 0; r < _maximumReadable; r++)
{
UpdateProgress?.
Invoke(
string.Format(Localization.Core.Reading_sector_0_of_1_2, i + r, blocks,
ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i + r, (long)blocks);
Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i + r, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i + r, (long)blocks);
sense = _dev.ReadCd(out cmdBuf, out senseBuf, (uint)(i + r), blockSize, (uint)sectorsForOffset + 1,
MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true,
@@ -241,8 +241,7 @@ partial class Dump
totalDuration += cmdDuration;
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
mhddLog.Write(i + r, cmdDuration);
ibgLog.Write(i + r, currentSpeed * 1024);
@@ -325,8 +324,7 @@ partial class Dump
_speedStopwatch.Restart();
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
if(cdiReadyReadAsAudio)
{

View File

@@ -159,12 +159,10 @@ partial class Dump
{
if(j > (ulong)lastSector)
{
if(!failedCrossingLeadOut &&
!inData)
if(!failedCrossingLeadOut && !inData)
blocksToRead += (uint)sectorsForOffset;
if(sectorsForOffset > 0 &&
!inData)
if(sectorsForOffset > 0 && !inData)
crossingLeadOut = true;
break;
@@ -194,12 +192,10 @@ partial class Dump
}
}
if(track.Sequence != 0 &&
i + blocksToRead - (ulong)sectorsForOffset > track.EndSector + 1)
if(track.Sequence != 0 && i + blocksToRead - (ulong)sectorsForOffset > track.EndSector + 1)
blocksToRead = (uint)(track.EndSector + 1 - i + (ulong)sectorsForOffset);
if(blocksToRead == 1 &&
!inData)
if(blocksToRead == 1 && !inData)
blocksToRead += (uint)sectorsForOffset;
if(blocksToRead == 0)
@@ -269,23 +265,17 @@ partial class Dump
crossingLeadOut = false;
}
if(currentSpeed > maxSpeed &&
currentSpeed > 0)
if(currentSpeed > maxSpeed && currentSpeed > 0)
maxSpeed = currentSpeed;
if(currentSpeed < minSpeed &&
currentSpeed > 0)
if(currentSpeed < minSpeed && currentSpeed > 0)
minSpeed = currentSpeed;
UpdateProgress?.
Invoke(
string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks,
ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i, (long)blocks);
Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i, (long)blocks);
if(crossingLeadOut &&
failedCrossingLeadOut &&
blocksToRead > 1)
if(crossingLeadOut && failedCrossingLeadOut && blocksToRead > 1)
blocksToRead--;
if(_supportsPlextorD8 && !inData)
@@ -396,8 +386,7 @@ partial class Dump
DecodedSense? decSense = Sense.Decode(senseBuf);
// Try to workaround firmware
if(decSense is { ASC: 0x11, ASCQ: 0x05 } ||
decSense?.ASC == 0x64)
if(decSense is { ASC: 0x11, ASCQ: 0x05 } || decSense?.ASC == 0x64)
{
sense = _dev.ReadCd(out cmdBuf, out _, firstSectorToRead, blockSize, blocksToRead,
MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders,
@@ -435,19 +424,15 @@ partial class Dump
double elapsed;
// Overcome the track mode change drive error
if(inData &&
!nextData &&
sense)
if(inData && !nextData && sense)
{
_speedStopwatch.Restart();
for(uint r = 0; r < blocksToRead; r++)
{
UpdateProgress?.
Invoke(
string.Format(Localization.Core.Reading_sector_0_of_1_2, i + r, blocks,
ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i + r, (long)blocks);
Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i + r, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i + r, (long)blocks);
if(_supportsPlextorD8)
{
@@ -504,8 +489,7 @@ partial class Dump
out cmdDuration);
}
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
mhddLog.Write(i + r, cmdDuration);
ibgLog.Write(i + r, currentSpeed * 1024);
@@ -655,8 +639,7 @@ partial class Dump
continue;
}
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
if(crossingLeadOut && failedCrossingLeadOut)
{
@@ -665,9 +648,7 @@ partial class Dump
}
// Because one block has been partially used to fix the offset
if(_fixOffset &&
!inData &&
offsetBytes != 0)
if(_fixOffset && !inData && offsetBytes != 0)
{
FixOffsetData(offsetBytes, sectorSize, sectorsForOffset, supportedSubchannel, ref blocksToRead,
subSize, ref cmdBuf, blockSize, failedCrossingLeadOut);

View File

@@ -362,9 +362,9 @@ sealed partial class Dump
// Check if subchannel is BCD
if(supportedSubchannel != MmcSubchannel.None)
{
sense = _dev.ReadCd(out cmdBuf, out _, (firstLba / 75 + 1) * 75 + 35, blockSize, 1,
MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, true,
MmcErrorField.None, supportedSubchannel, _dev.Timeout, out _);
sense = _dev.ReadCd(out cmdBuf, out _, (firstLba / 75 + 1) * 75 + 35, blockSize, 1, MmcSectorTypes.AllTypes,
false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
supportedSubchannel, _dev.Timeout, out _);
if(!sense)
{
@@ -471,8 +471,7 @@ sealed partial class Dump
ResumeSupport.Process(true, true, blocks, _dev.Manufacturer, _dev.Model, _dev.Serial, _dev.PlatformId,
ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision, _private, _force);
if(currentTry == null ||
extents == null)
if(currentTry == null || extents == null)
{
StoppingErrorMessage?.Invoke(Localization.Core.Could_not_process_resume_file_not_continuing);
@@ -482,8 +481,7 @@ sealed partial class Dump
// Read media tags
ReadCdTags(ref dskType, mediaTags, out sessions, out firstTrackLastSession);
if(!outputOptical.OpticalCapabilities.HasFlag(OpticalImageCapabilities.CanStoreSessions) &&
sessions > 1)
if(!outputOptical.OpticalCapabilities.HasFlag(OpticalImageCapabilities.CanStoreSessions) && sessions > 1)
{
// TODO: Disabled until 6.0
/*if(!_force)
@@ -578,8 +576,7 @@ sealed partial class Dump
tracks = trkList.ToArray();
}
if(tracks.Any(t => t.Type == TrackType.Audio) &&
desiredSubchannel != MmcSubchannel.Raw)
if(tracks.Any(t => t.Type == TrackType.Audio) && desiredSubchannel != MmcSubchannel.Raw)
{
_dumpLog.WriteLine(Localization.Core.WARNING_If_disc_says_CDG_CDEG_CDMIDI_dump_will_be_incorrect);
@@ -789,8 +786,7 @@ sealed partial class Dump
_maximumReadable /= 2;
}
if(!_dev.Error ||
_maximumReadable == 1)
if(!_dev.Error || _maximumReadable == 1)
break;
}
@@ -805,8 +801,7 @@ sealed partial class Dump
var cdiWithHiddenTrack1 = false;
if(dskType is MediaType.CDIREADY &&
tracks.Min(t => t.Sequence) == 1)
if(dskType is MediaType.CDIREADY && tracks.Min(t => t.Sequence) == 1)
{
cdiWithHiddenTrack1 = true;
dskType = MediaType.CDI;
@@ -843,7 +838,8 @@ sealed partial class Dump
_dumpLog.WriteLine(outputOptical.ErrorMessage);
StoppingErrorMessage?.Invoke(Localization.Core.Error_creating_output_image_not_continuing +
Environment.NewLine + outputOptical.ErrorMessage);
Environment.NewLine +
outputOptical.ErrorMessage);
return;
}
@@ -879,14 +875,14 @@ sealed partial class Dump
// Send track list to output plugin. This may fail if subchannel is set but unsupported.
ret = outputOptical.SetTracks(tracks.ToList());
if(!ret &&
desiredSubchannel == MmcSubchannel.None)
if(!ret && desiredSubchannel == MmcSubchannel.None)
{
_dumpLog.WriteLine(Localization.Core.Error_sending_tracks_to_output_image_not_continuing);
_dumpLog.WriteLine(outputOptical.ErrorMessage);
StoppingErrorMessage?.Invoke(Localization.Core.Error_sending_tracks_to_output_image_not_continuing +
Environment.NewLine + outputOptical.ErrorMessage);
Environment.NewLine +
outputOptical.ErrorMessage);
return;
}
@@ -930,7 +926,10 @@ sealed partial class Dump
_dumpLog.WriteLine(Localization.Core.Setting_flags_for_track_0, track.Sequence);
UpdateStatus?.Invoke(string.Format(Localization.Core.Setting_flags_for_track_0, track.Sequence));
outputOptical.WriteSectorTag(new[] { kvp.Value }, kvp.Key, SectorTagType.CdTrackFlags);
outputOptical.WriteSectorTag(new[]
{
kvp.Value
}, kvp.Key, SectorTagType.CdTrackFlags);
}
// Set MCN
@@ -938,9 +937,7 @@ sealed partial class Dump
{
sense = _dev.ReadMcn(out mcn, out _, out _, _dev.Timeout, out _);
if(!sense &&
mcn != null &&
mcn != "0000000000000")
if(!sense && mcn != null && mcn != "0000000000000")
{
UpdateStatus?.Invoke(string.Format(Localization.Core.Found_Media_Catalogue_Number_0, mcn));
_dumpLog.WriteLine(Localization.Core.Found_Media_Catalogue_Number_0, mcn);
@@ -966,8 +963,7 @@ sealed partial class Dump
}
}
if(supportedSubchannel != MmcSubchannel.None &&
desiredSubchannel != MmcSubchannel.None)
if(supportedSubchannel != MmcSubchannel.None && desiredSubchannel != MmcSubchannel.None)
{
subchannelExtents = new HashSet<int>();
@@ -1123,8 +1119,7 @@ sealed partial class Dump
}
}
if(!_fixOffset ||
tracks.All(t => t.Type != TrackType.Audio))
if(!_fixOffset || tracks.All(t => t.Type != TrackType.Audio))
{
offsetBytes = 0;
sectorsForOffset = 0;
@@ -1335,9 +1330,7 @@ sealed partial class Dump
ref totalDuration, subLog, desiredSubchannel, tracks, isrcs, ref mcn, subchannelExtents,
smallestPregapLbaPerTrack);
if(dskType is MediaType.CDR or MediaType.CDRW &&
_resume.BadBlocks.Count > 0 &&
_ignoreCdrRunOuts > 0)
if(dskType is MediaType.CDR or MediaType.CDRW && _resume.BadBlocks.Count > 0 && _ignoreCdrRunOuts > 0)
{
HandleCdrRunOutSectors(blocks, desiredSubchannel, extents, subchannelExtents, subLog, supportsLongSectors,
trackFlags, tracks);
@@ -1353,9 +1346,7 @@ sealed partial class Dump
subchannelExtents.Remove((int)e);
}
if(subchannelExtents.Count > 0 &&
_retryPasses > 0 &&
_retrySubchannel)
if(subchannelExtents.Count > 0 && _retryPasses > 0 && _retrySubchannel)
{
RetrySubchannel(readcd, subSize, supportedSubchannel, ref totalDuration, subLog, desiredSubchannel, tracks,
isrcs, ref mcn, subchannelExtents, smallestPregapLbaPerTrack);
@@ -1414,7 +1405,8 @@ sealed partial class Dump
if(!outputOptical.SetImageInfo(metadata))
{
ErrorMessage?.Invoke(Localization.Core.Error_0_setting_metadata + Environment.NewLine +
ErrorMessage?.Invoke(Localization.Core.Error_0_setting_metadata +
Environment.NewLine +
outputOptical.ErrorMessage);
}
@@ -1433,8 +1425,7 @@ sealed partial class Dump
_dumpLog.WriteLine(Localization.Core.Setting_ISRC_for_track_0_to_1, isrc.Key, isrc.Value);
}
if(mcn != null &&
outputOptical.WriteMediaTag(Encoding.ASCII.GetBytes(mcn), MediaTagType.CD_MCN))
if(mcn != null && outputOptical.WriteMediaTag(Encoding.ASCII.GetBytes(mcn), MediaTagType.CD_MCN))
{
UpdateStatus?.Invoke(string.Format(Localization.Core.Setting_disc_Media_Catalogue_Number_to_0, mcn));
_dumpLog.WriteLine(Localization.Core.Setting_disc_Media_Catalogue_Number_to_0, mcn);
@@ -1454,9 +1445,7 @@ sealed partial class Dump
continue;
}
if(trk.Indexes.TryGetValue(0, out int idx0) &&
trk.Indexes.TryGetValue(1, out int idx1) &&
idx0 == idx1)
if(trk.Indexes.TryGetValue(0, out int idx0) && trk.Indexes.TryGetValue(1, out int idx1) && idx0 == idx1)
trk.Indexes.Remove(0);
}
@@ -1492,17 +1481,17 @@ sealed partial class Dump
UpdateStatus?.Invoke("");
UpdateStatus?.
Invoke(string.Format(
Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing,
_dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second),
totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second),
_imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing,
_dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second),
totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second),
_imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).
Per(totalDuration.Milliseconds()).Humanize()));
Per(totalDuration.Milliseconds()).
Humanize()));
if(maxSpeed > 0)
{

View File

@@ -95,9 +95,7 @@ partial class Dump
_ => PlextorSubchannel.None
};
if(_resume.BadBlocks.Count <= 0 ||
_aborted ||
_retryPasses <= 0)
if(_resume.BadBlocks.Count <= 0 || _aborted || _retryPasses <= 0)
return;
var pass = 1;
@@ -127,7 +125,7 @@ partial class Dump
if(dcMode10?.Pages != null)
{
foreach(Modes.ModePage modePage in dcMode10.Value.Pages.Where(modePage =>
modePage is { Page: 0x01, Subpage: 0x00 }))
modePage is { Page: 0x01, Subpage: 0x00 }))
currentModePage = modePage;
}
}
@@ -138,8 +136,10 @@ partial class Dump
if(dcMode6?.Pages != null)
{
foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage =>
modePage is { Page: 0x01, Subpage: 0x00 }))
foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage => modePage is
{
Page: 0x01, Subpage: 0x00
}))
currentModePage = modePage;
}
}
@@ -227,10 +227,8 @@ partial class Dump
{
PulseProgress?.Invoke(runningPersistent
? string.
Format(
Localization.Core.
Retrying_sector_0_pass_1_recovering_partial_data_forward,
badSector, pass)
Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_forward,
badSector, pass)
: string.Format(Localization.Core.Retrying_sector_0_pass_1_forward, badSector,
pass));
}
@@ -238,10 +236,8 @@ partial class Dump
{
PulseProgress?.Invoke(runningPersistent
? string.
Format(
Localization.Core.
Retrying_sector_0_pass_1_recovering_partial_data_reverse,
badSector, pass)
Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_reverse,
badSector, pass)
: string.Format(Localization.Core.Retrying_sector_0_pass_1_reverse, badSector,
pass));
}
@@ -251,9 +247,7 @@ partial class Dump
byte sectorsToReRead = 1;
var badSectorToReRead = (uint)badSector;
if(_fixOffset &&
audioExtents.Contains(badSector) &&
offsetBytes != 0)
if(_fixOffset && audioExtents.Contains(badSector) && offsetBytes != 0)
{
if(offsetBytes < 0)
{
@@ -286,8 +280,7 @@ partial class Dump
DecodedSense? decSense = Sense.Decode(senseBuf);
// Try to workaround firmware
if(decSense is { ASC: 0x11, ASCQ: 0x05 } ||
decSense?.ASC == 0x64)
if(decSense is { ASC: 0x11, ASCQ: 0x05 } || decSense?.ASC == 0x64)
{
sense = _dev.ReadCd(out cmdBuf, out _, badSectorToReRead, blockSize, sectorsToReRead,
MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders,
@@ -309,8 +302,7 @@ partial class Dump
DecodedSense? decSense = Sense.Decode(senseBuf);
// Try to workaround firmware
if(decSense is { ASC: 0x11, ASCQ: 0x05 } ||
decSense?.ASC == 0x64)
if(decSense is { ASC: 0x11, ASCQ: 0x05 } || decSense?.ASC == 0x64)
{
sense = _dev.ReadCd(out cmdBuf, out _, badSectorToReRead, blockSize, sectorsToReRead,
MmcSectorTypes.Cdda, false, false, false, MmcHeaderCodes.None, true,
@@ -343,9 +335,7 @@ partial class Dump
}
// Because one block has been partially used to fix the offset
if(_fixOffset &&
audioExtents.Contains(badSector) &&
offsetBytes != 0)
if(_fixOffset && audioExtents.Contains(badSector) && offsetBytes != 0)
{
uint blocksToRead = sectorsToReRead;
@@ -353,8 +343,7 @@ partial class Dump
ref cmdBuf, blockSize, false);
}
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
_resume.BadBlocks.Remove(badSector);
extents.Add(badSector);
@@ -406,9 +395,7 @@ partial class Dump
}
}
if(pass < _retryPasses &&
!_aborted &&
_resume.BadBlocks.Count > 0)
if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0)
{
pass++;
forward = !forward;
@@ -546,7 +533,10 @@ partial class Dump
var md = new Modes.DecodedMode
{
Header = new Modes.ModeHeader(),
Pages = new[] { currentModePage.Value }
Pages = new[]
{
currentModePage.Value
}
};
md6 = Modes.EncodeMode6(md, _dev.ScsiType);
@@ -586,8 +576,7 @@ partial class Dump
PlextorSubchannel supportedPlextorSubchannel;
var outputOptical = _outputPlugin as IWritableOpticalImage;
if(supportedSubchannel == MmcSubchannel.None ||
desiredSubchannel == MmcSubchannel.None)
if(supportedSubchannel == MmcSubchannel.None || desiredSubchannel == MmcSubchannel.None)
return;
supportedPlextorSubchannel = supportedSubchannel switch
@@ -677,9 +666,7 @@ partial class Dump
_dumpLog.WriteLine(Localization.Core.Correctly_retried_sector_0_subchannel_in_pass_1, badSector, pass);
}
if(pass < _retryPasses &&
!_aborted &&
subchannelExtents.Count > 0)
if(pass < _retryPasses && !_aborted && subchannelExtents.Count > 0)
{
pass++;
forward = !forward;

View File

@@ -114,12 +114,10 @@ partial class Dump
double cmdDuration = 0;
if(currentSpeed > maxSpeed &&
currentSpeed > 0)
if(currentSpeed > maxSpeed && currentSpeed > 0)
maxSpeed = currentSpeed;
if(currentSpeed < minSpeed &&
currentSpeed > 0)
if(currentSpeed < minSpeed && currentSpeed > 0)
minSpeed = currentSpeed;
PulseProgress?.Invoke(string.Format(Localization.Core.Reading_sector_0_at_lead_out_1, i,
@@ -151,8 +149,7 @@ partial class Dump
else if(read6)
sense = _dev.Read6(out cmdBuf, out senseBuf, (uint)i, blockSize, 1, _dev.Timeout, out cmdDuration);
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
mhddLog.Write(i, cmdDuration);
ibgLog.Write(i, currentSpeed * 1024);
@@ -295,12 +292,10 @@ partial class Dump
double cmdDuration = 0;
if(currentSpeed > maxSpeed &&
currentSpeed > 0)
if(currentSpeed > maxSpeed && currentSpeed > 0)
maxSpeed = currentSpeed;
if(currentSpeed < minSpeed &&
currentSpeed > 0)
if(currentSpeed < minSpeed && currentSpeed > 0)
minSpeed = currentSpeed;
PulseProgress?.Invoke(string.Format(Localization.Core.Reading_sector_0_at_lead_out_1, i,
@@ -332,8 +327,7 @@ partial class Dump
else if(read6)
sense = _dev.Read6(out cmdBuf, out senseBuf, (uint)i, blockSize, 1, _dev.Timeout, out cmdDuration);
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
mhddLog.Write(i, cmdDuration, _maximumReadable);
ibgLog.Write(i, currentSpeed * 1024);

View File

@@ -98,8 +98,7 @@ partial class Dump
// ReSharper restore IntVariableOverflowInUncheckedContext
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
firstTrackPregapMs.Write(cmdBuf, 0, (int)blockSize);
gotFirstTrackPregap = true;
@@ -163,8 +162,7 @@ partial class Dump
Dictionary<uint, int> pregaps = new();
inexactPositioning = false;
if(!supportsPqSubchannel &&
!supportsRwSubchannel)
if(!supportsPqSubchannel && !supportsRwSubchannel)
return;
// Check if subchannel is BCD
@@ -220,9 +218,7 @@ partial class Dump
continue;
}
if(t > 0 &&
tracks[t - 1].Type == tracks[t].Type &&
dumping)
if(t > 0 && tracks[t - 1].Type == tracks[t].Type && dumping)
{
AaruConsole.DebugWriteLine(PREGAP_MODULE_NAME, Localization.Core.Skipping_track_0, track.Sequence);
@@ -331,9 +327,7 @@ partial class Dump
posQ = subBuf[7] * 60 * 75 + subBuf[8] * 75 + subBuf[9] - 150;
if(subBuf[1] != track.Sequence - 1 ||
subBuf[2] == 0 ||
posQ != lba)
if(subBuf[1] != track.Sequence - 1 || subBuf[2] == 0 || posQ != lba)
break;
pregaps[track.Sequence] = 0;
@@ -347,8 +341,7 @@ partial class Dump
// Calculate pregap
lba = (int)track.StartSector - 150;
while(lba > (int)previousTrack.StartSector &&
lba <= (int)track.StartSector)
while(lba > (int)previousTrack.StartSector && lba <= (int)track.StartSector)
{
// Some drives crash if you try to read just before the previous read, so seek away first
if(!forward)
@@ -463,17 +456,13 @@ partial class Dump
{
dumpLog?.
WriteLine(string.
Format(
Localization.Core.
Could_not_read_subchannel_for_this_track_supposing_0_sectors,
pregaps[track.Sequence]));
Format(Localization.Core.Could_not_read_subchannel_for_this_track_supposing_0_sectors,
pregaps[track.Sequence]));
updateStatus?.
Invoke(string.
Format(
Localization.Core.
Could_not_read_subchannel_for_this_track_supposing_0_sectors,
pregaps[track.Sequence]));
Format(Localization.Core.Could_not_read_subchannel_for_this_track_supposing_0_sectors,
pregaps[track.Sequence]));
}
break;
@@ -547,8 +536,7 @@ partial class Dump
}
// Same track, but not pregap
if(subBuf[1] == track.Sequence &&
subBuf[2] > 0)
if(subBuf[1] == track.Sequence && subBuf[2] > 0)
{
lba--;
forward = false;
@@ -568,8 +556,8 @@ partial class Dump
if(diff != 0)
{
AaruConsole.DebugWriteLine(PREGAP_MODULE_NAME,
Localization.Core.Invalid_Q_position_for_LBA_0_got_1, lba, posQ);
AaruConsole.DebugWriteLine(PREGAP_MODULE_NAME, Localization.Core.Invalid_Q_position_for_LBA_0_got_1,
lba, posQ);
inexactPositioning = true;
}
@@ -626,8 +614,7 @@ partial class Dump
// Minus five, to ensure dumping will fix if there is a pregap LBA 0
var red = 5;
while(trk.Pregap > 0 &&
red > 0)
while(trk.Pregap > 0 && red > 0)
{
trk.Pregap--;
red--;

View File

@@ -100,8 +100,7 @@ partial class Dump
continue;
}
if(track.Type != TrackType.Audio &&
track.Type != TrackType.Data)
if(track.Type != TrackType.Audio && track.Type != TrackType.Data)
{
SectorBuilder sb = new();
sb.ReconstructPrefix(ref sector, track.Type, (long)s);

View File

@@ -91,8 +91,7 @@ partial class Dump
{
DiscInformation.StandardDiscInformation? discInfo = DiscInformation.Decode000b(cmdBuf);
if(discInfo.HasValue &&
mediaType == MediaType.CD)
if(discInfo.HasValue && mediaType == MediaType.CD)
{
mediaType = discInfo.Value.DiscType switch
{
@@ -107,8 +106,7 @@ partial class Dump
UpdateStatus?.Invoke(Localization.Core.Reading_PMA);
sense = _dev.ReadPma(out cmdBuf, out _, _dev.Timeout, out _);
if(!sense &&
PMA.Decode(cmdBuf).HasValue)
if(!sense && PMA.Decode(cmdBuf).HasValue)
{
tmpBuf = new byte[cmdBuf.Length - 4];
Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);

View File

@@ -114,8 +114,7 @@ partial class Dump
? TrackType.Data
: TrackType.Audio,
StartSector =
(ulong)(trk.PHOUR * 3600 * 75 + trk.PMIN * 60 * 75 + trk.PSEC * 75 + trk.PFRAME -
150),
(ulong)(trk.PHOUR * 3600 * 75 + trk.PMIN * 60 * 75 + trk.PSEC * 75 + trk.PFRAME - 150),
BytesPerSector = (int)sectorSize,
RawBytesPerSector = (int)sectorSize
});
@@ -185,8 +184,7 @@ partial class Dump
TOC.CDTOC? oldToc = TOC.Decode(cmdBuf);
if((sense || !oldToc.HasValue) &&
!force)
if((sense || !oldToc.HasValue) && !force)
{
dumpLog?.WriteLine(Localization.Core.
Could_not_read_TOC_if_you_want_to_continue_use_force_and_will_try_from_LBA_0_to_360000);

View File

@@ -99,10 +99,7 @@ partial class Dump
_ => PlextorSubchannel.None
};
if(_resume.BadBlocks.Count <= 0 ||
_aborted ||
!_trim ||
!newTrim)
if(_resume.BadBlocks.Count <= 0 || _aborted || !_trim || !newTrim)
return;
UpdateStatus?.Invoke(Localization.Core.Trimming_skipped_sectors);
@@ -133,9 +130,7 @@ partial class Dump
byte sectorsToTrim = 1;
var badSectorToRead = (uint)badSector;
if(_fixOffset &&
audioExtents.Contains(badSector) &&
offsetBytes != 0)
if(_fixOffset && audioExtents.Contains(badSector) && offsetBytes != 0)
{
if(offsetBytes < 0)
{
@@ -166,8 +161,7 @@ partial class Dump
DecodedSense? decSense = Sense.Decode(senseBuf);
// Try to workaround firmware
if(decSense is { ASC: 0x11, ASCQ: 0x05 } ||
decSense?.ASC == 0x64)
if(decSense is { ASC: 0x11, ASCQ: 0x05 } || decSense?.ASC == 0x64)
{
sense = _dev.ReadCd(out cmdBuf, out _, badSectorToRead, blockSize, sectorsToTrim,
MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders,
@@ -233,8 +227,7 @@ partial class Dump
continue;
}
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
_resume.BadBlocks.Remove(badSector);
extents.Add(badSector);
@@ -242,9 +235,7 @@ partial class Dump
}
// Because one block has been partially used to fix the offset
if(_fixOffset &&
audioExtents.Contains(badSector) &&
offsetBytes != 0)
if(_fixOffset && audioExtents.Contains(badSector) && offsetBytes != 0)
{
uint blocksToRead = sectorsToTrim;
@@ -281,8 +272,7 @@ partial class Dump
outputOptical.SetTracks(tracks.ToList());
if(track.StartSector != trkStartBefore &&
!_resume.BadBlocks.Contains(track.StartSector))
if(track.StartSector != trkStartBefore && !_resume.BadBlocks.Contains(track.StartSector))
{
_resume.BadBlocks.Add(track.StartSector);

View File

@@ -230,7 +230,8 @@ public partial class Dump
_ctx = AaruContext.Create(Settings.Settings.MainDbPath);
// Search for device in main database
_dbDev = _ctx.Devices.FirstOrDefault(d => d.Manufacturer == _dev.Manufacturer && d.Model == _dev.Model &&
_dbDev = _ctx.Devices.FirstOrDefault(d => d.Manufacturer == _dev.Manufacturer &&
d.Model == _dev.Model &&
d.Revision == _dev.FirmwareRevision);
if(_dbDev is null)
@@ -293,8 +294,7 @@ public partial class Dump
_errorLog.Close();
_dumpLog.Close();
if(_resume == null ||
!_doResume)
if(_resume == null || !_doResume)
return;
_resume.LastWriteDate = DateTime.UtcNow;

View File

@@ -163,10 +163,7 @@ public partial class Dump
break;
}
if(!sfcFound &&
!genesisFound &&
!smsFound &&
!n64Found)
if(!sfcFound && !genesisFound && !smsFound && !n64Found)
{
StoppingErrorMessage?.Invoke(Localization.Core.No_cartridge_found_not_dumping);
_dumpLog.WriteLine(Localization.Core.No_cartridge_found_not_dumping);
@@ -177,17 +174,11 @@ public partial class Dump
var cluster = BitConverter.ToUInt16(buffer, romPos + 0x1A);
var romSize = BitConverter.ToUInt32(buffer, romPos + 0x1C);
MediaType mediaType = gbaFound
? MediaType.GameBoyAdvanceGamePak
: gbFound || gbcFound
? MediaType.GameBoyGamePak
: n64Found
? MediaType.N64GamePak
: smsFound
? MediaType.MasterSystemCartridge
: genesisFound
? MediaType.MegaDriveCartridge
: MediaType.SNESGamePak;
MediaType mediaType = gbaFound ? MediaType.GameBoyAdvanceGamePak :
gbFound || gbcFound ? MediaType.GameBoyGamePak :
n64Found ? MediaType.N64GamePak :
smsFound ? MediaType.MasterSystemCartridge :
genesisFound ? MediaType.MegaDriveCartridge : MediaType.SNESGamePak;
uint blocksToRead = 64;
double totalDuration = 0;
@@ -196,8 +187,7 @@ public partial class Dump
double minSpeed = double.MaxValue;
byte[] senseBuf;
if(_outputPlugin is not IByteAddressableImage outputBai ||
!outputBai.SupportedMediaTypes.Contains(mediaType))
if(_outputPlugin is not IByteAddressableImage outputBai || !outputBai.SupportedMediaTypes.Contains(mediaType))
{
_dumpLog.WriteLine(Localization.Core.The_specified_format_does_not_support_the_inserted_cartridge);
@@ -257,7 +247,8 @@ public partial class Dump
_dumpLog.WriteLine(outputBai.ErrorMessage);
StoppingErrorMessage?.Invoke(Localization.Core.Error_creating_output_image_not_continuing +
Environment.NewLine + outputBai.ErrorMessage);
Environment.NewLine +
outputBai.ErrorMessage);
return;
}
@@ -285,19 +276,15 @@ public partial class Dump
if(romSectors - i < blocksToRead)
blocksToRead = (uint)(romSectors - i);
if(currentSpeed > maxSpeed &&
currentSpeed > 0)
if(currentSpeed > maxSpeed && currentSpeed > 0)
maxSpeed = currentSpeed;
if(currentSpeed < minSpeed &&
currentSpeed > 0)
if(currentSpeed < minSpeed && currentSpeed > 0)
minSpeed = currentSpeed;
UpdateProgress?.
Invoke(
string.Format(Localization.Core.Reading_byte_0_of_1_2, i * 512, romSize,
ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i * 512, romSize);
Invoke(string.Format(Localization.Core.Reading_byte_0_of_1_2, i * 512, romSize, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i * 512, romSize);
sense = _dev.Read10(out readBuffer, out senseBuf, 0, false, true, false, false, (uint)(startSector + i),
512, 0, (ushort)blocksToRead, _dev.Timeout, out double cmdDuration);
@@ -306,8 +293,7 @@ public partial class Dump
_writeStopwatch.Restart();
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
outputBai.WriteBytes(readBuffer, 0, readBuffer.Length, out _);
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
@@ -341,30 +327,24 @@ public partial class Dump
_speedStopwatch.Stop();
if(romRemaining > 0 &&
!_aborted)
if(romRemaining > 0 && !_aborted)
{
if(currentSpeed > maxSpeed &&
currentSpeed > 0)
if(currentSpeed > maxSpeed && currentSpeed > 0)
maxSpeed = currentSpeed;
if(currentSpeed < minSpeed &&
currentSpeed > 0)
if(currentSpeed < minSpeed && currentSpeed > 0)
minSpeed = currentSpeed;
UpdateProgress?.
Invoke(
string.Format(Localization.Core.Reading_byte_0_of_1_2, romSectors * 512, romSize,
ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)romSectors * 512, romSize);
Invoke(string.Format(Localization.Core.Reading_byte_0_of_1_2, romSectors * 512, romSize, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)romSectors * 512, romSize);
sense = _dev.Read10(out readBuffer, out senseBuf, 0, false, true, false, false, romSectors, 512, 0, 1,
_dev.Timeout, out double cmdDuration);
totalDuration += cmdDuration;
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
_writeStopwatch.Restart();
outputBai.WriteBytes(readBuffer, 0, (int)romRemaining, out _);
@@ -401,11 +381,13 @@ public partial class Dump
_dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
_dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(512 * (romSectors + 1)).Per(totalDuration.Milliseconds()).
ByteSize.FromBytes(512 * (romSectors + 1)).
Per(totalDuration.Milliseconds()).
Humanize()));
_dumpLog.WriteLine(string.Format(Localization.Core.Average_write_speed_0,
ByteSize.FromBytes(512 * (romSectors + 1)).Per(imageWriteDuration.Seconds()).
ByteSize.FromBytes(512 * (romSectors + 1)).
Per(imageWriteDuration.Seconds()).
Humanize()));
var metadata = new CommonTypes.Structs.ImageInfo
@@ -416,7 +398,8 @@ public partial class Dump
if(!outputBai.SetImageInfo(metadata))
{
ErrorMessage?.Invoke(Localization.Core.Error_0_setting_metadata + Environment.NewLine +
ErrorMessage?.Invoke(Localization.Core.Error_0_setting_metadata +
Environment.NewLine +
outputBai.ErrorMessage);
}
@@ -452,16 +435,16 @@ public partial class Dump
UpdateStatus?.Invoke("");
UpdateStatus?.
Invoke(string.Format(
Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing,
_dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second),
totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second),
_imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing,
_dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second),
totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second),
_imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0,
ByteSize.FromBytes(512 * (romSectors + 1)).Per(totalDuration.Milliseconds()).
ByteSize.FromBytes(512 * (romSectors + 1)).
Per(totalDuration.Milliseconds()).
Humanize()));
if(maxSpeed > 0)

View File

@@ -212,8 +212,7 @@ partial class Dump
sense = _dev.ModeSense6(out cmdBuf, out _, false, ScsiModeSensePageControl.Current, 0x00, _dev.Timeout,
out _);
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
decMode = Modes.DecodeMode6(cmdBuf, PeripheralDeviceTypes.MultiMediaDevice);
}
else
@@ -239,8 +238,7 @@ partial class Dump
sense = _dev.ModeSense10(out cmdBuf, out _, false, false, ScsiModeSensePageControl.Current,
0x00, 0x00, _dev.Timeout, out _);
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
decMode = Modes.DecodeMode10(cmdBuf, PeripheralDeviceTypes.MultiMediaDevice);
}
else
@@ -387,8 +385,7 @@ partial class Dump
if(!sense)
{
if(DMI.IsXbox(cmdBuf) ||
DMI.IsXbox360(cmdBuf))
if(DMI.IsXbox(cmdBuf) || DMI.IsXbox360(cmdBuf))
{
if(DMI.IsXbox(cmdBuf))
dskType = MediaType.XGD;
@@ -558,11 +555,9 @@ partial class Dump
{
UpdateStatus?.
Invoke(string.
Format(
Localization.Core.
Drive_reports_0_copy_protection_not_yet_supported_dump_incorrect,
(CSS_CPRM.DecodeLeadInCopyright(cmdBuf)?.CopyrightType ??
CopyrightType.NoProtection).ToString()));
Format(Localization.Core.Drive_reports_0_copy_protection_not_yet_supported_dump_incorrect,
(CSS_CPRM.DecodeLeadInCopyright(cmdBuf)?.CopyrightType ??
CopyrightType.NoProtection).ToString()));
}
}
}
@@ -889,8 +884,7 @@ partial class Dump
CSS_CPRM.LeadInCopyright? cpy = CSS_CPRM.DecodeLeadInCopyright(tmp);
if(cpy.HasValue &&
cpy.Value.CopyrightType != CopyrightType.NoProtection)
if(cpy.HasValue && cpy.Value.CopyrightType != CopyrightType.NoProtection)
sidecar.OpticalDiscs[0].CopyProtection = cpy.Value.CopyrightType.ToString();
break;

View File

@@ -103,7 +103,8 @@ partial class Dump
_sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second));
_dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalChkDuration.Milliseconds()).
ByteSize.FromBytes(blockSize * (blocks + 1)).
Per(totalChkDuration.Milliseconds()).
Humanize());
if(_preSidecar != null)
@@ -127,10 +128,11 @@ partial class Dump
if(filesystems.Count > 0)
{
foreach(var filesystem in filesystems.Select(o => new
{
o.start,
o.type
}).Distinct())
{
o.start,
o.type
}).
Distinct())
_dumpLog.WriteLine(Localization.Core.Found_filesystem_0_at_sector_1, filesystem.type, filesystem.start);
}

View File

@@ -89,9 +89,7 @@ partial class Dump
sense = _dev.ModeSense6(out byte[] cmdBuf, out _, true, ScsiModeSensePageControl.Current, 0x3F, 5, out _);
if(!sense &&
!_dev.Error &&
Modes.DecodeMode6(cmdBuf, _dev.ScsiType).HasValue)
if(!sense && !_dev.Error && Modes.DecodeMode6(cmdBuf, _dev.ScsiType).HasValue)
decMode = Modes.DecodeMode6(cmdBuf, _dev.ScsiType);
if(decMode.HasValue)
@@ -171,20 +169,17 @@ partial class Dump
sense = _dev.MiniDiscGetType(out cmdBuf, out _, _dev.Timeout, out _);
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
mediaTags.Add(MediaTagType.MiniDiscType, cmdBuf);
sense = _dev.MiniDiscD5(out cmdBuf, out _, _dev.Timeout, out _);
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
mediaTags.Add(MediaTagType.MiniDiscD5, cmdBuf);
sense = _dev.MiniDiscReadDataTOC(out cmdBuf, out _, _dev.Timeout, out _);
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
mediaTags.Add(MediaTagType.MiniDiscDTOC, cmdBuf);
var utocMs = new MemoryStream();
@@ -243,7 +238,8 @@ partial class Dump
_dumpLog.WriteLine(outputFormat.ErrorMessage);
StoppingErrorMessage?.Invoke(Localization.Core.Error_creating_output_image_not_continuing +
Environment.NewLine + outputFormat.ErrorMessage);
Environment.NewLine +
outputFormat.ErrorMessage);
return;
}
@@ -273,11 +269,9 @@ partial class Dump
UpdateStatus?.
Invoke(string.
Format(
Localization.Core.
Setting_geometry_to_0_cylinders_1_heads_2_sectors_per_track,
rigidPage.Value.Cylinders, rigidPage.Value.Heads,
(uint)(blocks / (rigidPage.Value.Cylinders * rigidPage.Value.Heads))));
Format(Localization.Core.Setting_geometry_to_0_cylinders_1_heads_2_sectors_per_track,
rigidPage.Value.Cylinders, rigidPage.Value.Heads,
(uint)(blocks / (rigidPage.Value.Cylinders * rigidPage.Value.Heads))));
outputFormat.SetGeometry(rigidPage.Value.Cylinders, rigidPage.Value.Heads,
(uint)(blocks / (rigidPage.Value.Cylinders * rigidPage.Value.Heads)));
@@ -300,11 +294,9 @@ partial class Dump
UpdateStatus?.
Invoke(string.
Format(
Localization.Core.
Setting_geometry_to_0_cylinders_1_heads_2_sectors_per_track,
flexiblePage.Value.Cylinders, flexiblePage.Value.Heads,
flexiblePage.Value.SectorsPerTrack));
Format(Localization.Core.Setting_geometry_to_0_cylinders_1_heads_2_sectors_per_track,
flexiblePage.Value.Cylinders, flexiblePage.Value.Heads,
flexiblePage.Value.SectorsPerTrack));
outputFormat.SetGeometry(flexiblePage.Value.Cylinders, flexiblePage.Value.Heads,
flexiblePage.Value.SectorsPerTrack);
@@ -324,8 +316,7 @@ partial class Dump
_dev.PlatformId, ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision,
_private, _force);
if(currentTry == null ||
extents == null)
if(currentTry == null || extents == null)
{
StoppingErrorMessage?.Invoke(Localization.Core.Could_not_process_resume_file_not_continuing);
@@ -375,27 +366,22 @@ partial class Dump
if(blocks - i < blocksToRead)
blocksToRead = (uint)(blocks - i);
if(currentSpeed > maxSpeed &&
currentSpeed > 0)
if(currentSpeed > maxSpeed && currentSpeed > 0)
maxSpeed = currentSpeed;
if(currentSpeed < minSpeed &&
currentSpeed > 0)
if(currentSpeed < minSpeed && currentSpeed > 0)
minSpeed = currentSpeed;
UpdateProgress?.
Invoke(
string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks,
ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i, (long)blocks);
Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i, (long)blocks);
sense = _dev.Read6(out readBuffer, out _, (uint)i, blockSize, (byte)blocksToRead, _dev.Timeout,
out double cmdDuration);
totalDuration += cmdDuration;
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
mhddLog.Write(i, cmdDuration, blocksToRead);
ibgLog.Write(i, currentSpeed * 1024);
@@ -478,10 +464,7 @@ partial class Dump
#region Trimming
if(_resume.BadBlocks.Count > 0 &&
!_aborted &&
_trim &&
newTrim)
if(_resume.BadBlocks.Count > 0 && !_aborted && _trim && newTrim)
{
_trimStopwatch.Restart();
UpdateStatus?.Invoke(Localization.Core.Trimming_skipped_sectors);
@@ -528,9 +511,7 @@ partial class Dump
#region Error handling
if(_resume.BadBlocks.Count > 0 &&
!_aborted &&
_retryPasses > 0)
if(_resume.BadBlocks.Count > 0 && !_aborted && _retryPasses > 0)
{
var pass = 1;
var forward = true;
@@ -553,7 +534,7 @@ partial class Dump
if(dcMode6?.Pages != null)
{
foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage =>
modePage is { Page: 0x01, Subpage: 0x00 }))
modePage is { Page: 0x01, Subpage: 0x00 }))
currentModePage = modePage;
}
}
@@ -649,10 +630,8 @@ partial class Dump
{
PulseProgress?.Invoke(runningPersistent
? string.
Format(
Localization.Core.
Retrying_sector_0_pass_1_recovering_partial_data_forward,
badSector, pass)
Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_forward,
badSector, pass)
: string.Format(Localization.Core.Retrying_sector_0_pass_1_forward,
badSector, pass));
}
@@ -660,10 +639,8 @@ partial class Dump
{
PulseProgress?.Invoke(runningPersistent
? string.
Format(
Localization.Core.
Retrying_sector_0_pass_1_recovering_partial_data_reverse,
badSector, pass)
Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_reverse,
badSector, pass)
: string.Format(Localization.Core.Retrying_sector_0_pass_1_reverse,
badSector, pass));
}
@@ -673,8 +650,7 @@ partial class Dump
totalDuration += cmdDuration;
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
_resume.BadBlocks.Remove(badSector);
extents.Add(badSector);
@@ -690,9 +666,7 @@ partial class Dump
outputFormat.WriteSector(readBuffer, badSector);
}
if(pass < _retryPasses &&
!_aborted &&
_resume.BadBlocks.Count > 0)
if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0)
{
pass++;
forward = !forward;
@@ -709,7 +683,10 @@ partial class Dump
var md = new Modes.DecodedMode
{
Header = new Modes.ModeHeader(),
Pages = new[] { currentModePage.Value }
Pages = new[]
{
currentModePage.Value
}
};
md6 = Modes.EncodeMode6(md, _dev.ScsiType);
@@ -741,7 +718,8 @@ partial class Dump
if(!outputFormat.SetImageInfo(metadata))
{
ErrorMessage?.Invoke(Localization.Core.Error_0_setting_metadata + Environment.NewLine +
ErrorMessage?.Invoke(Localization.Core.Error_0_setting_metadata +
Environment.NewLine +
outputFormat.ErrorMessage);
}
@@ -813,7 +791,8 @@ partial class Dump
_sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second));
_dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalChkDuration.Milliseconds()).
ByteSize.FromBytes(blockSize * (blocks + 1)).
Per(totalChkDuration.Milliseconds()).
Humanize());
if(_preSidecar != null)
@@ -835,10 +814,11 @@ partial class Dump
if(filesystems.Count > 0)
{
foreach(var filesystem in filesystems.Select(o => new
{
o.start,
o.type
}).Distinct())
{
o.start,
o.type
}).
Distinct())
{
UpdateStatus?.Invoke(string.Format(Localization.Core.Found_filesystem_0_at_sector_1,
filesystem.type, filesystem.start));
@@ -853,8 +833,7 @@ partial class Dump
sidecar.BlockMedias[0].MediaType = xmlType.type;
sidecar.BlockMedias[0].MediaSubType = xmlType.subType;
if(!_dev.IsRemovable ||
_dev.IsUsb)
if(!_dev.IsRemovable || _dev.IsUsb)
{
if(_dev.Type == DeviceType.ATAPI)
sidecar.BlockMedias[0].Interface = "ATAPI";
@@ -896,17 +875,17 @@ partial class Dump
UpdateStatus?.Invoke("");
UpdateStatus?.
Invoke(string.Format(
Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing,
_dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second),
totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second),
_imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing,
_dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second),
totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second),
_imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).
Per(totalDuration.Milliseconds()).Humanize()));
Per(totalDuration.Milliseconds()).
Humanize()));
if(maxSpeed > 0)
{

View File

@@ -138,7 +138,8 @@ public partial class Dump
_dumpLog.WriteLine(outputFormat.ErrorMessage);
StoppingErrorMessage?.Invoke(Localization.Core.Error_creating_output_image_not_continuing +
Environment.NewLine + outputFormat.ErrorMessage);
Environment.NewLine +
outputFormat.ErrorMessage);
return;
}
@@ -153,8 +154,7 @@ public partial class Dump
_dev.PlatformId, ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision,
_private, _force);
if(currentTry == null ||
extents == null)
if(currentTry == null || extents == null)
{
StoppingErrorMessage?.Invoke(Localization.Core.Could_not_process_resume_file_not_continuing);
@@ -202,27 +202,22 @@ public partial class Dump
if(blocks - i < blocksToRead)
blocksToRead = (uint)(blocks - i);
if(currentSpeed > maxSpeed &&
currentSpeed > 0)
if(currentSpeed > maxSpeed && currentSpeed > 0)
maxSpeed = currentSpeed;
if(currentSpeed < minSpeed &&
currentSpeed > 0)
if(currentSpeed < minSpeed && currentSpeed > 0)
minSpeed = currentSpeed;
UpdateProgress?.
Invoke(
string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks,
ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i, blocks);
Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i, blocks);
sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false, (uint)i, blockSize, 0,
blocksToRead, false, _dev.Timeout, out double cmdDuration);
totalDuration += cmdDuration;
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
mhddLog.Write(i, cmdDuration, blocksToRead);
ibgLog.Write(i, currentSpeed * 1024);
@@ -307,10 +302,7 @@ public partial class Dump
#region Trimming
if(_resume.BadBlocks.Count > 0 &&
!_aborted &&
_trim &&
newTrim)
if(_resume.BadBlocks.Count > 0 && !_aborted && _trim && newTrim)
{
_trimStopwatch.Restart();
UpdateStatus?.Invoke(Localization.Core.Trimming_skipped_sectors);
@@ -359,9 +351,7 @@ public partial class Dump
#region Error handling
if(_resume.BadBlocks.Count > 0 &&
!_aborted &&
_retryPasses > 0)
if(_resume.BadBlocks.Count > 0 && !_aborted && _retryPasses > 0)
{
var pass = 1;
var forward = true;
@@ -389,7 +379,7 @@ public partial class Dump
if(dcMode10.HasValue)
{
foreach(Modes.ModePage modePage in dcMode10.Value.Pages.Where(modePage =>
modePage is { Page: 0x01, Subpage: 0x00 }))
modePage is { Page: 0x01, Subpage: 0x00 }))
currentModePage = modePage;
}
}
@@ -401,7 +391,7 @@ public partial class Dump
if(dcMode6.HasValue)
{
foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage =>
modePage is { Page: 0x01, Subpage: 0x00 }))
modePage is { Page: 0x01, Subpage: 0x00 }))
currentModePage = modePage;
}
}
@@ -496,10 +486,8 @@ public partial class Dump
{
PulseProgress?.Invoke(runningPersistent
? string.
Format(
Localization.Core.
Retrying_sector_0_pass_1_recovering_partial_data_forward,
badSector, pass)
Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_forward,
badSector, pass)
: string.Format(Localization.Core.Retrying_sector_0_pass_1_forward,
badSector, pass));
}
@@ -507,10 +495,8 @@ public partial class Dump
{
PulseProgress?.Invoke(runningPersistent
? string.
Format(
Localization.Core.
Retrying_sector_0_pass_1_recovering_partial_data_reverse,
badSector, pass)
Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_reverse,
badSector, pass)
: string.Format(Localization.Core.Retrying_sector_0_pass_1_reverse,
badSector, pass));
}
@@ -523,8 +509,7 @@ public partial class Dump
if(sense || _dev.Error)
_errorLog?.WriteLine(badSector, _dev.Error, _dev.LastError, senseBuf);
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
_resume.BadBlocks.Remove(badSector);
extents.Add(badSector);
@@ -540,9 +525,7 @@ public partial class Dump
outputFormat.WriteSector(readBuffer, badSector);
}
if(pass < _retryPasses &&
!_aborted &&
_resume.BadBlocks.Count > 0)
if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0)
{
pass++;
forward = !forward;
@@ -559,7 +542,10 @@ public partial class Dump
var md = new Modes.DecodedMode
{
Header = new Modes.ModeHeader(),
Pages = new[] { currentModePage.Value }
Pages = new[]
{
currentModePage.Value
}
};
md6 = Modes.EncodeMode6(md, _dev.ScsiType);
@@ -589,7 +575,8 @@ public partial class Dump
if(!outputFormat.SetImageInfo(metadata))
{
ErrorMessage?.Invoke(Localization.Core.Error_0_setting_metadata + Environment.NewLine +
ErrorMessage?.Invoke(Localization.Core.Error_0_setting_metadata +
Environment.NewLine +
outputFormat.ErrorMessage);
}
@@ -663,7 +650,8 @@ public partial class Dump
_sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second));
_dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalChkDuration.Milliseconds()).
ByteSize.FromBytes(blockSize * (blocks + 1)).
Per(totalChkDuration.Milliseconds()).
Humanize());
if(_preSidecar != null)
@@ -685,10 +673,11 @@ public partial class Dump
if(filesystems.Count > 0)
{
foreach(var filesystem in filesystems.Select(o => new
{
o.start,
o.type
}).Distinct())
{
o.start,
o.type
}).
Distinct())
{
UpdateStatus?.Invoke(string.Format(Localization.Core.Found_filesystem_0_at_sector_1,
filesystem.type, filesystem.start));
@@ -733,17 +722,17 @@ public partial class Dump
UpdateStatus?.Invoke("");
UpdateStatus?.
Invoke(string.Format(
Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing,
_dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second),
totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second),
_imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing,
_dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second),
totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second),
_imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).
Per(totalDuration.Milliseconds()).Humanize()));
Per(totalDuration.Milliseconds()).
Humanize()));
if(maxSpeed > 0)
{

View File

@@ -146,7 +146,8 @@ public partial class Dump
_dumpLog.WriteLine(outputOptical.ErrorMessage);
StoppingErrorMessage?.Invoke(Localization.Core.Error_creating_output_image_not_continuing +
Environment.NewLine + outputOptical.ErrorMessage);
Environment.NewLine +
outputOptical.ErrorMessage);
return;
}
@@ -175,8 +176,7 @@ public partial class Dump
_dev.PlatformId, ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision,
_private, _force);
if(currentTry == null ||
extents == null)
if(currentTry == null || extents == null)
{
StoppingErrorMessage?.Invoke(Localization.Core.Could_not_process_resume_file_not_continuing);
@@ -224,19 +224,15 @@ public partial class Dump
if(blocks - i < blocksToRead)
blocksToRead = (uint)(blocks - i);
if(currentSpeed > maxSpeed &&
currentSpeed > 0)
if(currentSpeed > maxSpeed && currentSpeed > 0)
maxSpeed = currentSpeed;
if(currentSpeed < minSpeed &&
currentSpeed > 0)
if(currentSpeed < minSpeed && currentSpeed > 0)
minSpeed = currentSpeed;
UpdateProgress?.
Invoke(
string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks,
ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i, (long)blocks);
Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i, (long)blocks);
sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false, (uint)(umdStart + i * 4),
512, 0, blocksToRead * 4, false, _dev.Timeout, out double cmdDuration);
@@ -245,8 +241,7 @@ public partial class Dump
_writeStopwatch.Restart();
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
mhddLog.Write(i, cmdDuration, blocksToRead);
ibgLog.Write(i, currentSpeed * 1024);
@@ -328,10 +323,7 @@ public partial class Dump
#region Trimming
if(_resume.BadBlocks.Count > 0 &&
!_aborted &&
_trim &&
newTrim)
if(_resume.BadBlocks.Count > 0 && !_aborted && _trim && newTrim)
{
_trimStopwatch.Restart();
_dumpLog.WriteLine(Localization.Core.Trimming_skipped_sectors);
@@ -378,9 +370,7 @@ public partial class Dump
#region Error handling
if(_resume.BadBlocks.Count > 0 &&
!_aborted &&
_retryPasses > 0)
if(_resume.BadBlocks.Count > 0 && !_aborted && _retryPasses > 0)
{
var pass = 1;
var forward = true;
@@ -403,7 +393,7 @@ public partial class Dump
if(dcMode6.HasValue)
{
foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage =>
modePage is { Page: 0x01, Subpage: 0x00 }))
modePage is { Page: 0x01, Subpage: 0x00 }))
currentModePage = modePage;
}
}
@@ -497,10 +487,8 @@ public partial class Dump
{
PulseProgress?.Invoke(runningPersistent
? string.
Format(
Localization.Core.
Retrying_sector_0_pass_1_recovering_partial_data_forward,
badSector, pass)
Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_forward,
badSector, pass)
: string.Format(Localization.Core.Retrying_sector_0_pass_1_forward,
badSector, pass));
}
@@ -508,10 +496,8 @@ public partial class Dump
{
PulseProgress?.Invoke(runningPersistent
? string.
Format(
Localization.Core.
Retrying_sector_0_pass_1_recovering_partial_data_reverse,
badSector, pass)
Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_reverse,
badSector, pass)
: string.Format(Localization.Core.Retrying_sector_0_pass_1_reverse,
badSector, pass));
}
@@ -525,8 +511,7 @@ public partial class Dump
if(sense || _dev.Error)
_errorLog?.WriteLine(badSector, _dev.Error, _dev.LastError, senseBuf);
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
_resume.BadBlocks.Remove(badSector);
extents.Add(badSector);
@@ -542,9 +527,7 @@ public partial class Dump
outputOptical.WriteSector(readBuffer, badSector);
}
if(pass < _retryPasses &&
!_aborted &&
_resume.BadBlocks.Count > 0)
if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0)
{
pass++;
forward = !forward;
@@ -561,7 +544,10 @@ public partial class Dump
var md = new Modes.DecodedMode
{
Header = new Modes.ModeHeader(),
Pages = new[] { currentModePage.Value }
Pages = new[]
{
currentModePage.Value
}
};
md6 = Modes.EncodeMode6(md, _dev.ScsiType);
@@ -592,7 +578,8 @@ public partial class Dump
if(!outputOptical.SetImageInfo(metadata))
{
ErrorMessage?.Invoke(Localization.Core.Error_0_setting_metadata + Environment.NewLine +
ErrorMessage?.Invoke(Localization.Core.Error_0_setting_metadata +
Environment.NewLine +
outputOptical.ErrorMessage);
}
@@ -626,17 +613,17 @@ public partial class Dump
UpdateStatus?.Invoke("");
UpdateStatus?.
Invoke(string.Format(
Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing,
_dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second),
totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second),
_imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing,
_dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second),
totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second),
_imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).
Per(totalDuration.Milliseconds()).Humanize()));
Per(totalDuration.Milliseconds()).
Humanize()));
if(maxSpeed > 0)
{

View File

@@ -84,8 +84,7 @@ static class ResumeSupport
throw new InvalidOperationException(Localization.Core.Resume_specifies_not_tape_but_device_is_tape);
}
if(resume.Removable != removable &&
!force)
if(resume.Removable != removable && !force)
{
if(resume.Removable)
{
@@ -97,60 +96,47 @@ static class ResumeSupport
Resume_specifies_non_removable_but_device_is_removable);
}
if(!isTape &&
resume.LastBlock != blocks - 1 &&
!force)
if(!isTape && resume.LastBlock != blocks - 1 && !force)
{
throw new
InvalidOperationException(string.Format(
Localization.Core.
Resume_file_different_number_of_blocks_not_continuing,
resume.LastBlock + 1, blocks));
InvalidOperationException(string.Format(Localization.Core.Resume_file_different_number_of_blocks_not_continuing,
resume.LastBlock + 1, blocks));
}
foreach(DumpHardware oldTry in resume.Tries)
{
if(!removable &&
!force)
if(!removable && !force)
{
if(oldTry.Manufacturer != manufacturer)
{
throw new
InvalidOperationException(string.
Format(
Localization.Core.
Resume_file_different_manufacturer_not_continuing,
oldTry.Manufacturer, manufacturer));
Format(Localization.Core.Resume_file_different_manufacturer_not_continuing,
oldTry.Manufacturer, manufacturer));
}
if(oldTry.Model != model)
{
throw new
InvalidOperationException(string.
Format(
Localization.Core.
Resume_file_different_model_not_continuing,
oldTry.Model, model));
Format(Localization.Core.Resume_file_different_model_not_continuing,
oldTry.Model, model));
}
if(oldTry.Serial != serial)
{
throw new
InvalidOperationException(string.
Format(
Localization.Core.
Resume_file_different_serial_number_not_continuing,
oldTry.Serial, serial));
Format(Localization.Core.Resume_file_different_serial_number_not_continuing,
oldTry.Serial, serial));
}
if(oldTry.Firmware != firmware)
{
throw new
InvalidOperationException(string.
Format(
Localization.Core.
Resume_file_different_firmware_revision_not_continuing,
oldTry.Firmware, firmware));
Format(Localization.Core.Resume_file_different_firmware_revision_not_continuing,
oldTry.Firmware, firmware));
}
}
@@ -162,8 +148,11 @@ static class ResumeSupport
oldTry.Software.Version != Version.GetVersion())
continue;
if(removable && (oldTry.Manufacturer != manufacturer || oldTry.Model != model ||
oldTry.Serial != serial || oldTry.Firmware != firmware))
if(removable &&
(oldTry.Manufacturer != manufacturer ||
oldTry.Model != model ||
oldTry.Serial != serial ||
oldTry.Firmware != firmware))
continue;
currentTry = oldTry;

View File

@@ -78,14 +78,14 @@ partial class Dump
InitProgress?.Invoke();
if(decSense.HasValue &&
decSense.Value.SenseKey != SenseKeys.NoSense)
if(decSense.HasValue && decSense.Value.SenseKey != SenseKeys.NoSense)
{
_dumpLog.WriteLine(Localization.Core.Device_not_ready_Sense, decSense.Value.SenseKey, decSense.Value.ASC,
decSense.Value.ASCQ);
StoppingErrorMessage?.Invoke(Localization.Core.Drive_has_status_error_please_correct_Sense_follows +
Environment.NewLine + decSense.Value.Description);
Environment.NewLine +
decSense.Value.Description);
return;
}
@@ -120,7 +120,8 @@ partial class Dump
decSense.Value.ASC != 0x00))
{
StoppingErrorMessage?.Invoke(Localization.Core.Drive_could_not_rewind_please_correct_Sense_follows +
Environment.NewLine + decSense.Value.Description);
Environment.NewLine +
decSense.Value.Description);
_dumpLog.WriteLine(Localization.Core.Drive_could_not_rewind_please_correct_Sense_follows);
@@ -141,12 +142,12 @@ partial class Dump
decSense = Sense.Decode(senseBuf);
if(decSense.HasValue &&
(decSense.Value.ASC == 0x20 && decSense.Value.ASCQ != 0x00 || decSense.Value.ASC != 0x20 &&
decSense.Value.SenseKey !=
SenseKeys.IllegalRequest))
(decSense.Value.ASC == 0x20 && decSense.Value.ASCQ != 0x00 ||
decSense.Value.ASC != 0x20 && decSense.Value.SenseKey != SenseKeys.IllegalRequest))
{
StoppingErrorMessage?.Invoke(Localization.Core.Could_not_get_position_Sense_follows +
Environment.NewLine + decSense.Value.Description);
Environment.NewLine +
decSense.Value.Description);
_dumpLog.WriteLine(Localization.Core.Could_not_get_position_Sense_follows);
@@ -170,7 +171,8 @@ partial class Dump
if(sense)
{
StoppingErrorMessage?.Invoke(Localization.Core.Drive_could_not_rewind_please_correct_Sense_follows +
Environment.NewLine + decSense?.Description);
Environment.NewLine +
decSense?.Description);
_dumpLog.WriteLine(Localization.Core.Drive_could_not_rewind_please_correct_Sense_follows);
@@ -196,7 +198,8 @@ partial class Dump
decSense.Value.ASC != 0x00))
{
StoppingErrorMessage?.Invoke(Localization.Core.Drive_could_not_rewind_please_correct_Sense_follows +
Environment.NewLine + decSense.Value.Description);
Environment.NewLine +
decSense.Value.Description);
_dumpLog.WriteLine(Localization.Core.Drive_could_not_rewind_please_correct_Sense_follows);
@@ -213,7 +216,8 @@ partial class Dump
decSense = Sense.Decode(senseBuf);
StoppingErrorMessage?.Invoke(Localization.Core.Drive_could_not_rewind_please_correct_Sense_follows +
Environment.NewLine + decSense?.Description);
Environment.NewLine +
decSense?.Description);
_dumpLog.WriteLine(Localization.Core.Drive_could_not_rewind_please_correct_Sense_follows);
@@ -248,8 +252,7 @@ partial class Dump
sense = _dev.ModeSense10(out cmdBuf, out senseBuf, false, true, ScsiModeSensePageControl.Current, 0x3F, 0xFF, 5,
out duration);
if(!sense ||
_dev.Error)
if(!sense || _dev.Error)
{
sense = _dev.ModeSense10(out cmdBuf, out senseBuf, false, true, ScsiModeSensePageControl.Current, 0x3F,
0x00, 5, out duration);
@@ -257,8 +260,7 @@ partial class Dump
Modes.DecodedMode? decMode = null;
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
if(Modes.DecodeMode10(cmdBuf, _dev.ScsiType).HasValue)
decMode = Modes.DecodeMode10(cmdBuf, _dev.ScsiType);
@@ -278,8 +280,7 @@ partial class Dump
if(sense || _dev.Error)
sense = _dev.ModeSense(out cmdBuf, out senseBuf, 5, out duration);
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
if(Modes.DecodeMode6(cmdBuf, _dev.ScsiType).HasValue)
decMode = Modes.DecodeMode6(cmdBuf, _dev.ScsiType);
@@ -365,9 +366,10 @@ partial class Dump
if(!eom)
{
StoppingErrorMessage?.Invoke(
Localization.Core.Drive_could_not_return_back_Sense_follows +
Environment.NewLine + decSense.Value.Description);
StoppingErrorMessage?.Invoke(Localization.Core.
Drive_could_not_return_back_Sense_follows +
Environment.NewLine +
decSense.Value.Description);
_dumpLog.WriteLine(Localization.Core.Drive_could_not_return_back_Sense_follows);
@@ -382,15 +384,15 @@ partial class Dump
transferLen = 1;
sense = _dev.Read6(out cmdBuf, out senseBuf, false, fixedLen, transferLen, blockSize,
_dev.Timeout,
out duration);
_dev.Timeout, out duration);
if(sense)
{
decSense = Sense.Decode(senseBuf);
StoppingErrorMessage?.Invoke(Localization.Core.Drive_could_not_read_Sense_follows +
Environment.NewLine + decSense.Value.Description);
Environment.NewLine +
decSense.Value.Description);
_dumpLog.WriteLine(Localization.Core.Drive_could_not_read_Sense_follows);
@@ -426,8 +428,8 @@ partial class Dump
transferLen = blockSize;
UpdateStatus?.Invoke(string.Format(
Localization.Core.Blocksize_changed_to_0_bytes_at_block_1,
UpdateStatus?.
Invoke(string.Format(Localization.Core.Blocksize_changed_to_0_bytes_at_block_1,
blockSize, currentBlock));
_dumpLog.WriteLine(Localization.Core.Blocksize_changed_to_0_bytes_at_block_1, blockSize,
@@ -444,7 +446,8 @@ partial class Dump
StoppingErrorMessage?.Invoke(Localization.Core.
Drive_could_not_go_back_one_block_Sense_follows +
Environment.NewLine + decSense.Value.Description);
Environment.NewLine +
decSense.Value.Description);
_dumpLog.WriteLine(Localization.Core.Drive_could_not_go_back_one_block_Sense_follows);
@@ -458,7 +461,8 @@ partial class Dump
}
StoppingErrorMessage?.Invoke(Localization.Core.Drive_could_not_read_Sense_follows +
Environment.NewLine + decSense.Value.Description);
Environment.NewLine +
decSense.Value.Description);
_dumpLog.WriteLine(Localization.Core.Drive_could_not_read_Sense_follows);
@@ -469,7 +473,8 @@ partial class Dump
}
default:
StoppingErrorMessage?.Invoke(Localization.Core.Drive_could_not_read_Sense_follows +
Environment.NewLine + decSense.Value.Description);
Environment.NewLine +
decSense.Value.Description);
_dumpLog.WriteLine(Localization.Core.Drive_could_not_read_Sense_follows);
@@ -503,7 +508,8 @@ partial class Dump
if(!eom)
{
StoppingErrorMessage?.Invoke(Localization.Core.Drive_could_not_return_back_Sense_follows +
Environment.NewLine + decSense.Value.Description);
Environment.NewLine +
decSense.Value.Description);
_dumpLog.WriteLine(Localization.Core.Drive_could_not_return_back_Sense_follows);
@@ -521,8 +527,7 @@ partial class Dump
_dev.PlatformId, ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision,
_private, _force, true);
if(currentTry == null ||
extents == null)
if(currentTry == null || extents == null)
{
StoppingErrorMessage?.Invoke(Localization.Core.Could_not_process_resume_file_not_continuing);
@@ -772,7 +777,8 @@ partial class Dump
decSense.Value.ASC != 0x00))
{
StoppingErrorMessage?.Invoke(Localization.Core.Drive_could_not_rewind_please_correct_Sense_follows +
Environment.NewLine + decSense.Value.Description);
Environment.NewLine +
decSense.Value.Description);
_dumpLog.WriteLine(Localization.Core.Drive_could_not_rewind_please_correct_Sense_follows);
@@ -792,7 +798,8 @@ partial class Dump
_dumpLog.WriteLine(outputTape.ErrorMessage);
StoppingErrorMessage?.Invoke(Localization.Core.Error_setting_output_image_in_tape_mode_not_continuing +
Environment.NewLine + outputTape.ErrorMessage);
Environment.NewLine +
outputTape.ErrorMessage);
return;
}
@@ -806,7 +813,8 @@ partial class Dump
_dumpLog.WriteLine(outputTape.ErrorMessage);
StoppingErrorMessage?.Invoke(Localization.Core.Error_creating_output_image_not_continuing +
Environment.NewLine + outputTape.ErrorMessage);
Environment.NewLine +
outputTape.ErrorMessage);
return;
}
@@ -828,8 +836,7 @@ partial class Dump
FirstBlock = currentBlock
};
if((canLocate || canLocateLong) &&
_resume.NextBlock > 0)
if((canLocate || canLocateLong) && _resume.NextBlock > 0)
{
currentBlock = _resume.NextBlock;
@@ -905,12 +912,10 @@ partial class Dump
continue;
}
if(currentSpeed > maxSpeed &&
currentSpeed > 0)
if(currentSpeed > maxSpeed && currentSpeed > 0)
maxSpeed = currentSpeed;
if(currentSpeed < minSpeed &&
currentSpeed > 0)
if(currentSpeed < minSpeed && currentSpeed > 0)
minSpeed = currentSpeed;
PulseProgress?.Invoke(string.Format(Localization.Core.Reading_block_0_1, currentBlock,
@@ -921,9 +926,7 @@ partial class Dump
totalDuration += duration;
if(sense &&
senseBuf?.Length != 0 &&
!ArrayHelpers.ArrayIsNullOrEmpty(senseBuf))
if(sense && senseBuf?.Length != 0 && !ArrayHelpers.ArrayIsNullOrEmpty(senseBuf))
{
decSense = Sense.Decode(senseBuf);
@@ -945,9 +948,7 @@ partial class Dump
Sense.DecodeDescriptor04(desc04, out filemark, out eom, out ili);
}
if(decSense.Value is { ASC: 0x00, ASCQ: 0x00 } &&
ili &&
valid)
if(decSense.Value is { ASC: 0x00, ASCQ: 0x00 } && ili && valid)
{
blockSize = (uint)((int)blockSize - BitConverter.ToInt32(BitConverter.GetBytes(information), 0));
@@ -969,7 +970,8 @@ partial class Dump
decSense = Sense.Decode(senseBuf);
StoppingErrorMessage?.Invoke(Localization.Core.Drive_could_not_go_back_one_block_Sense_follows +
Environment.NewLine + decSense.Value.Description);
Environment.NewLine +
decSense.Value.Description);
outputTape.Close();
_dumpLog.WriteLine(Localization.Core.Drive_could_not_go_back_one_block_Sense_follows);
@@ -1042,10 +1044,8 @@ partial class Dump
if(decSense is null)
{
StoppingErrorMessage?.
Invoke(string.Format(
Localization.Core.
Drive_could_not_read_block_0_Sense_cannot_be_decoded_look_at_log_for_dump,
currentBlock));
Invoke(string.Format(Localization.Core.Drive_could_not_read_block_0_Sense_cannot_be_decoded_look_at_log_for_dump,
currentBlock));
_dumpLog.WriteLine(string.Format(Localization.Core.Drive_could_not_read_block_0_Sense_bytes_follow,
currentBlock));
@@ -1148,10 +1148,7 @@ partial class Dump
#region Error handling
if(_resume.BadBlocks.Count > 0 &&
!_aborted &&
_retryPasses > 0 &&
(canLocate || canLocateLong))
if(_resume.BadBlocks.Count > 0 && !_aborted && _retryPasses > 0 && (canLocate || canLocateLong))
{
var pass = 1;
var forward = false;
@@ -1183,10 +1180,8 @@ partial class Dump
{
PulseProgress?.Invoke(runningPersistent
? string.
Format(
Localization.Core.
Retrying_sector_0_pass_1_recovering_partial_data_forward,
badBlock, pass)
Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_forward,
badBlock, pass)
: string.Format(Localization.Core.Retrying_sector_0_pass_1_forward,
badBlock, pass));
}
@@ -1194,10 +1189,8 @@ partial class Dump
{
PulseProgress?.Invoke(runningPersistent
? string.
Format(
Localization.Core.
Retrying_sector_0_pass_1_recovering_partial_data_reverse,
badBlock, pass)
Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_reverse,
badBlock, pass)
: string.Format(Localization.Core.Retrying_sector_0_pass_1_reverse,
badBlock, pass));
}
@@ -1287,8 +1280,7 @@ partial class Dump
totalDuration += duration;
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
_resume.BadBlocks.Remove(badBlock);
extents.Add(badBlock);
@@ -1303,9 +1295,7 @@ partial class Dump
outputTape.WriteSector(cmdBuf, badBlock);
}
if(pass < _retryPasses &&
!_aborted &&
_resume.BadBlocks.Count > 0)
if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0)
{
pass++;
forward = !forward;
@@ -1345,7 +1335,8 @@ partial class Dump
if(!outputTape.SetImageInfo(metadata))
{
ErrorMessage?.Invoke(Localization.Core.Error_0_setting_metadata + Environment.NewLine +
ErrorMessage?.Invoke(Localization.Core.Error_0_setting_metadata +
Environment.NewLine +
outputTape.ErrorMessage);
}
@@ -1425,7 +1416,8 @@ partial class Dump
_sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second));
_dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalChkDuration.Milliseconds()).
ByteSize.FromBytes(blockSize * (blocks + 1)).
Per(totalChkDuration.Milliseconds()).
Humanize());
if(_preSidecar != null)
@@ -1447,10 +1439,11 @@ partial class Dump
if(filesystems.Count > 0)
{
foreach(var filesystem in filesystems.Select(o => new
{
o.start,
o.type
}).Distinct())
{
o.start,
o.type
}).
Distinct())
{
UpdateStatus?.Invoke(string.Format(Localization.Core.Found_filesystem_0_at_sector_1,
filesystem.type, filesystem.start));
@@ -1468,8 +1461,7 @@ partial class Dump
sidecar.BlockMedias[0].MediaSubType = xmlType.subType;
// TODO: Implement device firmware revision
if(!_dev.IsRemovable ||
_dev.IsUsb)
if(!_dev.IsRemovable || _dev.IsUsb)
{
if(_dev.Type == DeviceType.ATAPI)
sidecar.BlockMedias[0].Interface = "ATAPI";
@@ -1509,17 +1501,17 @@ partial class Dump
UpdateStatus?.Invoke("");
UpdateStatus?.
Invoke(string.Format(
Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing,
_sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second),
totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second),
_imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing,
_sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second),
totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second),
_imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).
Per(totalDuration.Milliseconds()).Humanize()));
Per(totalDuration.Milliseconds()).
Humanize()));
if(maxSpeed > 0)
{

View File

@@ -91,29 +91,22 @@ partial class Dump
if(blocks - i < blocksToRead)
blocksToRead = (uint)(blocks - i);
if(currentSpeed > maxSpeed &&
currentSpeed > 0)
if(currentSpeed > maxSpeed && currentSpeed > 0)
maxSpeed = currentSpeed;
if(currentSpeed < minSpeed &&
currentSpeed > 0)
if(currentSpeed < minSpeed && currentSpeed > 0)
minSpeed = currentSpeed;
UpdateProgress?.
Invoke(
string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks,
ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i, (long)blocks);
Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i, (long)blocks);
sense = scsiReader.ReadBlocks(out buffer, i, blocksToRead, out double cmdDuration, out _, out _);
totalDuration += cmdDuration;
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
if(Settings.Settings.Current.EnableDecryption &&
discKey != null &&
_titleKeys)
if(Settings.Settings.Current.EnableDecryption && discKey != null && _titleKeys)
{
for(ulong j = 0; j < blocksToRead; j++)
{
@@ -137,8 +130,10 @@ partial class Dump
if(titleKey.HasValue)
{
outputFormat.WriteSectorTag(new[] { titleKey.Value.CMI }, i + j,
SectorTagType.DvdSectorCmi);
outputFormat.WriteSectorTag(new[]
{
titleKey.Value.CMI
}, i + j, SectorTagType.DvdSectorCmi);
}
else
continue;
@@ -147,11 +142,15 @@ partial class Dump
if((titleKey.Value.CMI & 0x80) >> 7 == 0)
{
// The CMI indicates this sector is not encrypted.
outputFormat.WriteSectorTag(new byte[] { 0, 0, 0, 0, 0 }, i + j,
SectorTagType.DvdSectorTitleKey);
outputFormat.WriteSectorTag(new byte[]
{
0, 0, 0, 0, 0
}, i + j, SectorTagType.DvdSectorTitleKey);
outputFormat.WriteSectorTag(new byte[] { 0, 0, 0, 0, 0 }, i + j,
SectorTagType.DvdTitleKeyDecrypted);
outputFormat.WriteSectorTag(new byte[]
{
0, 0, 0, 0, 0
}, i + j, SectorTagType.DvdTitleKeyDecrypted);
_resume.MissingTitleKeys.Remove(i + j);
@@ -162,11 +161,15 @@ partial class Dump
// not encrypted even if the CMI says it is.
if(titleKey.Value.Key.All(k => k == 0))
{
outputFormat.WriteSectorTag(new byte[] { 0, 0, 0, 0, 0 }, i + j,
SectorTagType.DvdSectorTitleKey);
outputFormat.WriteSectorTag(new byte[]
{
0, 0, 0, 0, 0
}, i + j, SectorTagType.DvdSectorTitleKey);
outputFormat.WriteSectorTag(new byte[] { 0, 0, 0, 0, 0 }, i + j,
SectorTagType.DvdTitleKeyDecrypted);
outputFormat.WriteSectorTag(new byte[]
{
0, 0, 0, 0, 0
}, i + j, SectorTagType.DvdTitleKeyDecrypted);
_resume.MissingTitleKeys.Remove(i + j);

View File

@@ -111,15 +111,13 @@ partial class Dump
{
mediaTags = new Dictionary<MediaTagType, byte[]>();
if(_dev.IsUsb &&
_dev.UsbDescriptors != null)
if(_dev.IsUsb && _dev.UsbDescriptors != null)
mediaTags.Add(MediaTagType.USB_Descriptors, null);
if(_dev.Type == DeviceType.ATAPI)
mediaTags.Add(MediaTagType.ATAPI_IDENTIFY, null);
if(_dev.IsPcmcia &&
_dev.Cis != null)
if(_dev.IsPcmcia && _dev.Cis != null)
mediaTags.Add(MediaTagType.PCMCIA_CIS, null);
sense = _dev.ScsiInquiry(out byte[] cmdBuf, out _);
@@ -137,15 +135,13 @@ partial class Dump
sense = _dev.ModeSense10(out cmdBuf, out _, false, true, ScsiModeSensePageControl.Current, 0x3F, 0xFF,
5, out _);
if(!sense ||
_dev.Error)
if(!sense || _dev.Error)
{
sense = _dev.ModeSense10(out cmdBuf, out _, false, true, ScsiModeSensePageControl.Current, 0x3F,
0x00, 5, out _);
}
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
if(Modes.DecodeMode10(cmdBuf, _dev.ScsiType).HasValue)
{
@@ -169,8 +165,7 @@ partial class Dump
if(sense || _dev.Error)
sense = _dev.ModeSense(out cmdBuf, out _, 5, out _);
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
if(Modes.DecodeMode6(cmdBuf, _dev.ScsiType).HasValue)
{
@@ -189,7 +184,8 @@ partial class Dump
// TODO: Fix this
containsFloppyPage = decMode.Value.Pages?.Aggregate(containsFloppyPage,
(current, modePage) =>
current | modePage.Page == 0x05) == true;
current | modePage.Page == 0x05) ==
true;
}
}
}
@@ -231,8 +227,7 @@ partial class Dump
return;
}
if(blocks != 0 &&
blockSize != 0)
if(blocks != 0 && blockSize != 0)
{
blocks++;
@@ -367,7 +362,8 @@ partial class Dump
_dumpLog.WriteLine(outputFormat.ErrorMessage);
StoppingErrorMessage?.Invoke(Localization.Core.Error_creating_output_image_not_continuing +
Environment.NewLine + outputFormat.ErrorMessage);
Environment.NewLine +
outputFormat.ErrorMessage);
return;
}
@@ -402,8 +398,7 @@ partial class Dump
{
writeSingleOpticalTrack = false;
if(discInformation?.Sessions > 1 &&
!canStoreNotCdSessions)
if(discInformation?.Sessions > 1 && !canStoreNotCdSessions)
{
if(_force)
{
@@ -525,7 +520,8 @@ partial class Dump
_dumpLog.WriteLine(outputFormat.ErrorMessage);
StoppingErrorMessage?.Invoke(Localization.Core.Error_creating_output_image_not_continuing +
Environment.NewLine + outputFormat.ErrorMessage);
Environment.NewLine +
outputFormat.ErrorMessage);
return;
}
@@ -554,7 +550,8 @@ partial class Dump
StoppingErrorMessage?.Invoke(Localization.Core.
Error_sending_tracks_to_output_image_not_continuing +
Environment.NewLine + opticalPlugin.ErrorMessage);
Environment.NewLine +
opticalPlugin.ErrorMessage);
return;
}
@@ -610,11 +607,9 @@ partial class Dump
UpdateStatus?.
Invoke(string.
Format(
Localization.Core.
Setting_geometry_to_0_cylinders_1_heads_2_sectors_per_track,
rigidPage.Value.Cylinders, rigidPage.Value.Heads,
(uint)(blocks / (rigidPage.Value.Cylinders * rigidPage.Value.Heads))));
Format(Localization.Core.Setting_geometry_to_0_cylinders_1_heads_2_sectors_per_track,
rigidPage.Value.Cylinders, rigidPage.Value.Heads,
(uint)(blocks / (rigidPage.Value.Cylinders * rigidPage.Value.Heads))));
outputFormat.SetGeometry(rigidPage.Value.Cylinders, rigidPage.Value.Heads,
(uint)(blocks / (rigidPage.Value.Cylinders * rigidPage.Value.Heads)));
@@ -637,11 +632,9 @@ partial class Dump
UpdateStatus?.
Invoke(string.
Format(
Localization.Core.
Setting_geometry_to_0_cylinders_1_heads_2_sectors_per_track,
flexiblePage.Value.Cylinders, flexiblePage.Value.Heads,
flexiblePage.Value.SectorsPerTrack));
Format(Localization.Core.Setting_geometry_to_0_cylinders_1_heads_2_sectors_per_track,
flexiblePage.Value.Cylinders, flexiblePage.Value.Heads,
flexiblePage.Value.SectorsPerTrack));
outputFormat.SetGeometry(flexiblePage.Value.Cylinders, flexiblePage.Value.Heads,
flexiblePage.Value.SectorsPerTrack);
@@ -665,7 +658,8 @@ partial class Dump
_dumpLog.WriteLine(outputFormat.ErrorMessage);
StoppingErrorMessage?.Invoke(Localization.Core.Error_creating_output_image_not_continuing +
Environment.NewLine + outputFormat.ErrorMessage);
Environment.NewLine +
outputFormat.ErrorMessage);
return;
}
@@ -705,8 +699,8 @@ partial class Dump
bool discIs80Mm =
mediaTags?.TryGetValue(MediaTagType.DVD_PFI, out byte[] pfiBytes) == true &&
PFI.Decode(pfiBytes, dskType)?.DiscSize == DVDSize.Eighty ||
mediaTags?.TryGetValue(MediaTagType.BD_DI, out byte[] diBytes) == true && DI.
Decode(diBytes)?.Units?.Any(s => s.DiscSize == DI.BluSize.Eighty) == true;
mediaTags?.TryGetValue(MediaTagType.BD_DI, out byte[] diBytes) == true &&
DI.Decode(diBytes)?.Units?.Any(s => s.DiscSize == DI.BluSize.Eighty) == true;
Spiral.DiscParameters discSpiralParameters = Spiral.DiscParametersFromMediaType(dskType, discIs80Mm);
@@ -724,8 +718,7 @@ partial class Dump
_mediaGraph?.PaintSectorsBad(_resume.BadBlocks);
}
if(currentTry == null ||
extents == null)
if(currentTry == null || extents == null)
{
StoppingErrorMessage?.Invoke(Localization.Core.Could_not_process_resume_file_not_continuing);
@@ -786,9 +779,7 @@ partial class Dump
ReadSbcData(blocks, blocksToRead, blockSize, currentTry, extents, ref currentSpeed, ref minSpeed,
ref maxSpeed, ref totalDuration, scsiReader, mhddLog, ibgLog, ref imageWriteDuration,
ref newTrim, ref dvdDecrypt,
mediaTags.TryGetValue(MediaTagType.DVD_DiscKey_Decrypted, out byte[] tag)
? tag
: null);
mediaTags.TryGetValue(MediaTagType.DVD_DiscKey_Decrypted, out byte[] tag) ? tag : null);
}
_dumpStopwatch.Stop();
@@ -821,10 +812,7 @@ partial class Dump
#region Trimming
if(_resume.BadBlocks.Count > 0 &&
!_aborted &&
_trim &&
newTrim)
if(_resume.BadBlocks.Count > 0 && !_aborted && _trim && newTrim)
{
_trimStopwatch.Restart();
UpdateStatus?.Invoke(Localization.Core.Trimming_skipped_sectors);
@@ -850,9 +838,7 @@ partial class Dump
#region Error handling
if(_resume.BadBlocks.Count > 0 &&
!_aborted &&
_retryPasses > 0)
if(_resume.BadBlocks.Count > 0 && !_aborted && _retryPasses > 0)
RetrySbcData(scsiReader, currentTry, extents, ref totalDuration, blankExtents);
if(_resume.MissingTitleKeys?.Count > 0 &&
@@ -884,7 +870,8 @@ partial class Dump
// Cannot write tag to image
StoppingErrorMessage?.Invoke(string.Format(Localization.Core.Cannot_write_tag_0, tag.Key));
_dumpLog.WriteLine(string.Format(Localization.Core.Cannot_write_tag_0, tag.Key) + Environment.NewLine +
_dumpLog.WriteLine(string.Format(Localization.Core.Cannot_write_tag_0, tag.Key) +
Environment.NewLine +
outputFormat.ErrorMessage);
return;
@@ -892,23 +879,21 @@ partial class Dump
}
else
{
if(!_dev.IsRemovable ||
_dev.IsUsb)
if(!_dev.IsRemovable || _dev.IsUsb)
{
if(_dev.IsUsb &&
_dev.UsbDescriptors != null)
if(_dev.IsUsb && _dev.UsbDescriptors != null)
{
UpdateStatus?.Invoke(Localization.Core.Reading_USB_descriptors);
_dumpLog.WriteLine(Localization.Core.Reading_USB_descriptors);
ret = outputFormat.WriteMediaTag(_dev.UsbDescriptors, MediaTagType.USB_Descriptors);
if(!ret &&
!_force)
if(!ret && !_force)
{
_dumpLog.WriteLine(Localization.Core.Cannot_write_USB_descriptors);
StoppingErrorMessage?.Invoke(Localization.Core.Cannot_write_USB_descriptors +
Environment.NewLine + outputFormat.ErrorMessage);
Environment.NewLine +
outputFormat.ErrorMessage);
return;
}
@@ -929,13 +914,13 @@ partial class Dump
ret = outputFormat.WriteMediaTag(cmdBuf, MediaTagType.ATAPI_IDENTIFY);
if(!ret &&
!_force)
if(!ret && !_force)
{
_dumpLog.WriteLine(Localization.Core.Cannot_write_ATAPI_IDENTIFY_PACKET_DEVICE);
StoppingErrorMessage?.Invoke(Localization.Core.Cannot_write_ATAPI_IDENTIFY_PACKET_DEVICE +
Environment.NewLine + outputFormat.ErrorMessage);
Environment.NewLine +
outputFormat.ErrorMessage);
return;
}
@@ -950,12 +935,12 @@ partial class Dump
_dumpLog.WriteLine(Localization.Core.Requesting_SCSI_INQUIRY);
ret = outputFormat.WriteMediaTag(cmdBuf, MediaTagType.SCSI_INQUIRY);
if(!ret &&
!_force)
if(!ret && !_force)
{
StoppingErrorMessage?.Invoke(Localization.Core.Cannot_write_SCSI_INQUIRY);
_dumpLog.WriteLine(Localization.Core.Cannot_write_SCSI_INQUIRY + Environment.NewLine +
_dumpLog.WriteLine(Localization.Core.Cannot_write_SCSI_INQUIRY +
Environment.NewLine +
outputFormat.ErrorMessage);
return;
@@ -967,27 +952,25 @@ partial class Dump
sense = _dev.ModeSense10(out cmdBuf, out _, false, true, ScsiModeSensePageControl.Current, 0x3F,
0xFF, 5, out _);
if(!sense ||
_dev.Error)
if(!sense || _dev.Error)
{
sense = _dev.ModeSense10(out cmdBuf, out _, false, true, ScsiModeSensePageControl.Current, 0x3F,
0x00, 5, out _);
}
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
if(Modes.DecodeMode10(cmdBuf, _dev.ScsiType).HasValue)
{
ret = outputFormat.WriteMediaTag(cmdBuf, MediaTagType.SCSI_MODESENSE_10);
if(!ret &&
!_force)
if(!ret && !_force)
{
_dumpLog.WriteLine(Localization.Core.Cannot_write_SCSI_MODE_SENSE_10);
StoppingErrorMessage?.Invoke(Localization.Core.Cannot_write_SCSI_MODE_SENSE_10 +
Environment.NewLine + outputFormat.ErrorMessage);
Environment.NewLine +
outputFormat.ErrorMessage);
return;
}
@@ -1009,20 +992,19 @@ partial class Dump
if(sense || _dev.Error)
sense = _dev.ModeSense(out cmdBuf, out _, 5, out _);
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
if(Modes.DecodeMode6(cmdBuf, _dev.ScsiType).HasValue)
{
ret = outputFormat.WriteMediaTag(cmdBuf, MediaTagType.SCSI_MODESENSE_6);
if(!ret &&
!_force)
if(!ret && !_force)
{
_dumpLog.WriteLine(Localization.Core.Cannot_write_SCSI_MODE_SENSE_6);
StoppingErrorMessage?.Invoke(Localization.Core.Cannot_write_SCSI_MODE_SENSE_6 +
Environment.NewLine + outputFormat.ErrorMessage);
Environment.NewLine +
outputFormat.ErrorMessage);
return;
}
@@ -1051,7 +1033,8 @@ partial class Dump
if(!outputFormat.SetImageInfo(metadata))
{
ErrorMessage?.Invoke(Localization.Core.Error_0_setting_metadata + Environment.NewLine +
ErrorMessage?.Invoke(Localization.Core.Error_0_setting_metadata +
Environment.NewLine +
outputFormat.ErrorMessage);
}
@@ -1139,11 +1122,9 @@ partial class Dump
}
// All USB flash drives report as removable, even if the media is not removable
if(!_dev.IsRemovable ||
_dev.IsUsb)
if(!_dev.IsRemovable || _dev.IsUsb)
{
if(_dev.IsUsb &&
_dev.UsbDescriptors != null)
if(_dev.IsUsb && _dev.UsbDescriptors != null)
{
if(outputFormat.SupportedMediaTags.Contains(MediaTagType.USB_Descriptors))
{
@@ -1241,15 +1222,13 @@ partial class Dump
sense = _dev.ModeSense10(out cmdBuf, out _, false, true, ScsiModeSensePageControl.Current,
0x3F, 0xFF, 5, out _);
if(!sense ||
_dev.Error)
if(!sense || _dev.Error)
{
sense = _dev.ModeSense10(out cmdBuf, out _, false, true,
ScsiModeSensePageControl.Current, 0x3F, 0x00, 5, out _);
}
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
if(Modes.DecodeMode10(cmdBuf, _dev.ScsiType).HasValue)
{
@@ -1280,8 +1259,7 @@ partial class Dump
if(sense || _dev.Error)
sense = _dev.ModeSense(out cmdBuf, out _, 5, out _);
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
if(Modes.DecodeMode6(cmdBuf, _dev.ScsiType).HasValue)
{
@@ -1312,10 +1290,11 @@ partial class Dump
if(filesystems.Count > 0)
{
foreach(var filesystem in filesystems.Select(o => new
{
o.start,
o.type
}).Distinct())
{
o.start,
o.type
}).
Distinct())
{
UpdateStatus?.Invoke(string.Format(Localization.Core.Found_filesystem_0_at_sector_1,
filesystem.type, filesystem.start));
@@ -1333,8 +1312,7 @@ partial class Dump
sidecar.BlockMedias[0].MediaSubType = xmlType.subType;
// TODO: Implement device firmware revision
if(!_dev.IsRemovable ||
_dev.IsUsb)
if(!_dev.IsRemovable || _dev.IsUsb)
{
if(_dev.Type == DeviceType.ATAPI)
sidecar.BlockMedias[0].Interface = "ATAPI";
@@ -1377,17 +1355,17 @@ partial class Dump
UpdateStatus?.Invoke("");
UpdateStatus?.
Invoke(string.Format(
Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing,
_dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second),
totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second),
_imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing,
_dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second),
totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second),
_imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).
Per(totalDuration.Milliseconds())).Humanize());
Per(totalDuration.Milliseconds())).
Humanize());
if(maxSpeed > 0)
{

View File

@@ -89,7 +89,7 @@ partial class Dump
if(dcMode10?.Pages != null)
{
foreach(Modes.ModePage modePage in dcMode10.Value.Pages.Where(modePage =>
modePage is { Page: 0x01, Subpage: 0x00 }))
modePage is { Page: 0x01, Subpage: 0x00 }))
currentModePage = modePage;
}
}
@@ -100,8 +100,10 @@ partial class Dump
if(dcMode6?.Pages != null)
{
foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage =>
modePage is { Page: 0x01, Subpage: 0x00 }))
foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage => modePage is
{
Page: 0x01, Subpage: 0x00
}))
currentModePage = modePage;
}
}
@@ -249,10 +251,8 @@ partial class Dump
{
PulseProgress?.Invoke(runningPersistent
? string.
Format(
Localization.Core.
Retrying_sector_0_pass_1_recovering_partial_data_forward,
badSector, pass)
Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_forward,
badSector, pass)
: string.Format(Localization.Core.Retrying_sector_0_pass_1_forward, badSector,
pass));
}
@@ -260,10 +260,8 @@ partial class Dump
{
PulseProgress?.Invoke(runningPersistent
? string.
Format(
Localization.Core.
Retrying_sector_0_pass_1_recovering_partial_data_reverse,
badSector, pass)
Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_reverse,
badSector, pass)
: string.Format(Localization.Core.Retrying_sector_0_pass_1_reverse, badSector,
pass));
}
@@ -301,9 +299,7 @@ partial class Dump
outputFormat.WriteSector(buffer, badSector);
}
if(pass < _retryPasses &&
!_aborted &&
_resume.BadBlocks.Count > 0)
if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0)
{
pass++;
forward = !forward;
@@ -320,7 +316,10 @@ partial class Dump
var md = new Modes.DecodedMode
{
Header = new Modes.ModeHeader(),
Pages = new[] { currentModePage.Value }
Pages = new[]
{
currentModePage.Value
}
};
md6 = Modes.EncodeMode6(md, _dev.ScsiType);
@@ -384,17 +383,24 @@ partial class Dump
if(!titleKey.HasValue)
continue;
outputFormat.WriteSectorTag(new[] { titleKey.Value.CMI }, missingKey, SectorTagType.DvdSectorCmi);
outputFormat.WriteSectorTag(new[]
{
titleKey.Value.CMI
}, missingKey, SectorTagType.DvdSectorCmi);
// If the CMI bit is 1, the sector is using copy protection, else it is not
// If the decoded title key is zeroed, there should be no copy protection
if((titleKey.Value.CMI & 0x80) >> 7 == 0 ||
titleKey.Value.Key.All(k => k == 0))
if((titleKey.Value.CMI & 0x80) >> 7 == 0 || titleKey.Value.Key.All(k => k == 0))
{
outputFormat.WriteSectorTag(new byte[] { 0, 0, 0, 0, 0 }, missingKey, SectorTagType.DvdSectorTitleKey);
outputFormat.WriteSectorTag(new byte[]
{
0, 0, 0, 0, 0
}, missingKey, SectorTagType.DvdSectorTitleKey);
outputFormat.WriteSectorTag(new byte[] { 0, 0, 0, 0, 0 }, missingKey,
SectorTagType.DvdTitleKeyDecrypted);
outputFormat.WriteSectorTag(new byte[]
{
0, 0, 0, 0, 0
}, missingKey, SectorTagType.DvdTitleKeyDecrypted);
_resume.MissingTitleKeys.Remove(missingKey);
@@ -421,9 +427,7 @@ partial class Dump
}
}
if(pass < _retryPasses &&
!_aborted &&
_resume.MissingTitleKeys.Count > 0)
if(pass < _retryPasses && !_aborted && _resume.MissingTitleKeys.Count > 0)
{
pass++;
forward = !forward;

View File

@@ -67,8 +67,7 @@ partial class Dump
DecodedSense? decodedSense = Sense.Decode(buffer);
if(_dev.LastError != 0 ||
decodedSense?.SenseKey == SenseKeys.IllegalRequest)
if(_dev.LastError != 0 || decodedSense?.SenseKey == SenseKeys.IllegalRequest)
{
UpdateStatus?.Invoke(Localization.Core.The_current_environment_doesn_t_support_the_medium_scan_command);
@@ -77,8 +76,7 @@ partial class Dump
}
// TODO: Find a place where MEDIUM SCAN works properly
else if(buffer?.Length > 0 &&
!ArrayHelpers.ArrayIsNullOrEmpty(buffer))
else if(buffer?.Length > 0 && !ArrayHelpers.ArrayIsNullOrEmpty(buffer))
AaruConsole.WriteLine(Localization.Core.MEDIUM_SCAN_github_plead_message);
changingCounter = false;
@@ -115,11 +113,8 @@ partial class Dump
c = (uint)(blocks - b);
UpdateProgress?.
Invoke(
written
? string.Format(Localization.Core.Scanning_for_0_written_blocks_starting_in_block_1, c, b)
: string.Format(Localization.Core.Scanning_for_0_blank_blocks_starting_in_block_1, c, b),
b, (long)blocks);
Invoke(written ? string.Format(Localization.Core.Scanning_for_0_written_blocks_starting_in_block_1, c, b) : string.Format(Localization.Core.Scanning_for_0_blank_blocks_starting_in_block_1, c, b),
b, (long)blocks);
conditionMet = _dev.MediumScan(out _, written, false, false, false, false, b, c, c, out _, out _,
uint.MaxValue, out _);
@@ -205,25 +200,20 @@ partial class Dump
if(extent.Item2 + 1 - i < blocksToRead)
blocksToRead = (uint)(extent.Item2 + 1 - i);
if(currentSpeed > maxSpeed &&
currentSpeed > 0)
if(currentSpeed > maxSpeed && currentSpeed > 0)
maxSpeed = currentSpeed;
if(currentSpeed < minSpeed &&
currentSpeed > 0)
if(currentSpeed < minSpeed && currentSpeed > 0)
minSpeed = currentSpeed;
UpdateProgress?.
Invoke(
string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks,
ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i, (long)blocks);
Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i, (long)blocks);
sense = scsiReader.ReadBlocks(out buffer, i, blocksToRead, out double cmdDuration, out _, out _);
totalDuration += cmdDuration;
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
mhddLog.Write(i, cmdDuration, blocksToRead);
ibgLog.Write(i, currentSpeed * 1024);

View File

@@ -84,8 +84,7 @@ partial class Dump
continue;
}
if((sense || _dev.Error) &&
!recoveredError)
if((sense || _dev.Error) && !recoveredError)
continue;
_resume.BadBlocks.Remove(badSector);

View File

@@ -226,8 +226,9 @@ public partial class Dump
}
else
{
supportsCmd23 = Decoders.SecureDigital.Decoders.DecodeSCR(scr)?.CommandSupport.
HasFlag(CommandSupport.SetBlockCount) ?? false;
supportsCmd23 = Decoders.SecureDigital.Decoders.DecodeSCR(scr)?.
CommandSupport.HasFlag(CommandSupport.SetBlockCount) ??
false;
mediaTags.Add(MediaTagType.SD_SCR, null);
}
@@ -298,8 +299,7 @@ public partial class Dump
if(error)
blocksToRead /= 2;
if(!error ||
blocksToRead == 1)
if(!error || blocksToRead == 1)
break;
}
@@ -315,9 +315,7 @@ public partial class Dump
}
}
if(_useBufferedReads &&
blocksToRead > 1 &&
!supportsCmd23)
if(_useBufferedReads && blocksToRead > 1 && !supportsCmd23)
{
while(true)
{
@@ -326,8 +324,7 @@ public partial class Dump
if(error)
blocksToRead /= 2;
if(!error ||
blocksToRead == 1)
if(!error || blocksToRead == 1)
break;
// Device is in timeout, reopen to reset
@@ -344,9 +341,7 @@ public partial class Dump
}
}
if(!_useBufferedReads &&
blocksToRead > 1 &&
!supportsCmd23)
if(!_useBufferedReads && blocksToRead > 1 && !supportsCmd23)
{
while(true)
{
@@ -360,8 +355,7 @@ public partial class Dump
if(_dev.LastError == 110)
_dev.ReOpen();
if(!error ||
blocksToRead == 1)
if(!error || blocksToRead == 1)
break;
}
@@ -423,8 +417,7 @@ public partial class Dump
ResumeSupport.Process(true, false, blocks, _dev.Manufacturer, _dev.Model, _dev.Serial, _dev.PlatformId,
ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision, _private, _force);
if(currentTry == null ||
extents == null)
if(currentTry == null || extents == null)
{
StoppingErrorMessage?.Invoke(Localization.Core.Could_not_process_resume_file_not_continuing);
@@ -472,7 +465,8 @@ public partial class Dump
_dumpLog.WriteLine(outputFormat.ErrorMessage);
StoppingErrorMessage?.Invoke(Localization.Core.Error_creating_output_image_not_continuing +
Environment.NewLine + outputFormat.ErrorMessage);
Environment.NewLine +
outputFormat.ErrorMessage);
return;
}
@@ -509,12 +503,12 @@ public partial class Dump
: MediaTagType.MMC_CID);
// Cannot write CID to image
if(!ret &&
!_force)
if(!ret && !_force)
{
_dumpLog.WriteLine(Localization.Core.Cannot_write_CID_to_output_image);
StoppingErrorMessage?.Invoke(Localization.Core.Cannot_write_CID_to_output_image + Environment.NewLine +
StoppingErrorMessage?.Invoke(Localization.Core.Cannot_write_CID_to_output_image +
Environment.NewLine +
outputFormat.ErrorMessage);
return;
@@ -530,12 +524,12 @@ public partial class Dump
: MediaTagType.MMC_CSD);
// Cannot write CSD to image
if(!ret &&
!_force)
if(!ret && !_force)
{
_dumpLog.WriteLine(Localization.Core.Cannot_write_CSD_to_output_image);
StoppingErrorMessage?.Invoke(Localization.Core.Cannot_write_CSD_to_output_image + Environment.NewLine +
StoppingErrorMessage?.Invoke(Localization.Core.Cannot_write_CSD_to_output_image +
Environment.NewLine +
outputFormat.ErrorMessage);
return;
@@ -547,13 +541,13 @@ public partial class Dump
ret = outputFormat.WriteMediaTag(ecsd, MediaTagType.MMC_ExtendedCSD);
// Cannot write Extended CSD to image
if(!ret &&
!_force)
if(!ret && !_force)
{
_dumpLog.WriteLine(Localization.Core.Cannot_write_Extended_CSD_to_output_image);
StoppingErrorMessage?.Invoke(Localization.Core.Cannot_write_Extended_CSD_to_output_image +
Environment.NewLine + outputFormat.ErrorMessage);
Environment.NewLine +
outputFormat.ErrorMessage);
return;
}
@@ -568,12 +562,12 @@ public partial class Dump
: MediaTagType.MMC_OCR);
// Cannot write OCR to image
if(!ret &&
!_force)
if(!ret && !_force)
{
_dumpLog.WriteLine(Localization.Core.Cannot_write_OCR_to_output_image);
StoppingErrorMessage?.Invoke(Localization.Core.Cannot_write_OCR_to_output_image + Environment.NewLine +
StoppingErrorMessage?.Invoke(Localization.Core.Cannot_write_OCR_to_output_image +
Environment.NewLine +
outputFormat.ErrorMessage);
return;
@@ -585,12 +579,12 @@ public partial class Dump
ret = outputFormat.WriteMediaTag(scr, MediaTagType.SD_SCR);
// Cannot write SCR to image
if(!ret &&
!_force)
if(!ret && !_force)
{
_dumpLog.WriteLine(Localization.Core.Cannot_write_SCR_to_output_image);
StoppingErrorMessage?.Invoke(Localization.Core.Cannot_write_SCR_to_output_image + Environment.NewLine +
StoppingErrorMessage?.Invoke(Localization.Core.Cannot_write_SCR_to_output_image +
Environment.NewLine +
outputFormat.ErrorMessage);
return;
@@ -646,19 +640,15 @@ public partial class Dump
if(blocks - i < blocksToRead)
blocksToRead = (byte)(blocks - i);
if(currentSpeed > maxSpeed &&
currentSpeed > 0)
if(currentSpeed > maxSpeed && currentSpeed > 0)
maxSpeed = currentSpeed;
if(currentSpeed < minSpeed &&
currentSpeed > 0)
if(currentSpeed < minSpeed && currentSpeed > 0)
minSpeed = currentSpeed;
UpdateProgress?.
Invoke(
string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks,
ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i, (long)blocks);
Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i, (long)blocks);
if(blocksToRead == 1)
{
@@ -757,10 +747,7 @@ public partial class Dump
#region Trimming
if(_resume.BadBlocks.Count > 0 &&
!_aborted &&
_trim &&
newTrim)
if(_resume.BadBlocks.Count > 0 && !_aborted && _trim && newTrim)
{
_trimStopwatch.Restart();
UpdateStatus?.Invoke(Localization.Core.Trimming_skipped_sectors);
@@ -814,9 +801,7 @@ public partial class Dump
#region Error handling
if(_resume.BadBlocks.Count > 0 &&
!_aborted &&
_retryPasses > 0)
if(_resume.BadBlocks.Count > 0 && !_aborted && _retryPasses > 0)
{
var pass = 1;
var forward = true;
@@ -865,9 +850,7 @@ public partial class Dump
_dumpLog.WriteLine(Localization.Core.Correctly_retried_block_0_in_pass_1, badSector, pass);
}
if(pass < _retryPasses &&
!_aborted &&
_resume.BadBlocks.Count > 0)
if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0)
{
pass++;
forward = !forward;
@@ -897,7 +880,8 @@ public partial class Dump
if(!outputFormat.SetImageInfo(metadata))
{
ErrorMessage?.Invoke(Localization.Core.Error_0_setting_metadata + Environment.NewLine +
ErrorMessage?.Invoke(Localization.Core.Error_0_setting_metadata +
Environment.NewLine +
outputFormat.ErrorMessage);
}
@@ -971,7 +955,8 @@ public partial class Dump
_sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second));
_dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalChkDuration.Milliseconds()).
ByteSize.FromBytes(blockSize * (blocks + 1)).
Per(totalChkDuration.Milliseconds()).
Humanize());
(string type, string subType) xmlType = (null, null);
@@ -1023,17 +1008,17 @@ public partial class Dump
UpdateStatus?.Invoke("");
UpdateStatus?.
Invoke(string.Format(
Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing,
_dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second),
totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second),
_imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing,
_dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second),
totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second),
_imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).
Per(totalDuration.Milliseconds()).Humanize()));
Per(totalDuration.Milliseconds()).
Humanize()));
if(maxSpeed > 0)
{

View File

@@ -205,11 +205,11 @@ partial class Dump
Array.Copy(readBuffer, 4, tmpBuf, 0, readBuffer.Length - 4);
mediaTags.Add(MediaTagType.DVD_PFI, tmpBuf);
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Video_partition_total_size_0_sectors,
totalSize);
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Video_partition_total_size_0_sectors, totalSize);
ulong l0Video = (PFI.Decode(readBuffer, MediaType.DVDROM)?.Layer0EndPSN ?? 0) -
(PFI.Decode(readBuffer, MediaType.DVDROM)?.DataAreaStartPSN ?? 0) + 1;
(PFI.Decode(readBuffer, MediaType.DVDROM)?.DataAreaStartPSN ?? 0) +
1;
ulong l1Video = totalSize - l0Video + 1;
UpdateStatus?.Invoke(Localization.Core.Reading_Disc_Manufacturing_Information);
@@ -236,19 +236,22 @@ partial class Dump
UpdateStatus?.Invoke(Localization.Core.Video_partition_is_too_big_did_lock_work_Trying_cold_values);
_dumpLog.WriteLine(Localization.Core.Video_partition_is_too_big_did_lock_work_Trying_cold_values);
totalSize = (ulong)((coldReadCapacity[0] << 24) + (coldReadCapacity[1] << 16) + (coldReadCapacity[2] << 8) +
coldReadCapacity[3]) & 0xFFFFFFFF;
totalSize = (ulong)((coldReadCapacity[0] << 24) +
(coldReadCapacity[1] << 16) +
(coldReadCapacity[2] << 8) +
coldReadCapacity[3]) &
0xFFFFFFFF;
tmpBuf = new byte[coldPfi.Length - 4];
Array.Copy(coldPfi, 4, tmpBuf, 0, coldPfi.Length - 4);
mediaTags.Remove(MediaTagType.DVD_PFI);
mediaTags.Add(MediaTagType.DVD_PFI, tmpBuf);
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Video_partition_total_size_0_sectors,
totalSize);
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Video_partition_total_size_0_sectors, totalSize);
l0Video = (PFI.Decode(coldPfi, MediaType.DVDROM)?.Layer0EndPSN ?? 0) -
(PFI.Decode(coldPfi, MediaType.DVDROM)?.DataAreaStartPSN ?? 0) + 1;
(PFI.Decode(coldPfi, MediaType.DVDROM)?.DataAreaStartPSN ?? 0) +
1;
l1Video = totalSize - l0Video + 1;
@@ -291,10 +294,10 @@ partial class Dump
ulong gameSize =
((ulong)((readBuffer[0] << 24) + (readBuffer[1] << 16) + (readBuffer[2] << 8) + readBuffer[3]) &
0xFFFFFFFF) + 1;
0xFFFFFFFF) +
1;
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Game_partition_total_size_0_sectors,
gameSize);
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Game_partition_total_size_0_sectors, gameSize);
// Get middle zone size
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Getting_middle_zone_size);
@@ -453,8 +456,7 @@ partial class Dump
if(sense || _dev.Error)
blocksToRead /= 2;
if(!_dev.Error ||
blocksToRead == 1)
if(!_dev.Error || blocksToRead == 1)
break;
}
@@ -513,7 +515,8 @@ partial class Dump
_dumpLog.WriteLine(outputFormat.ErrorMessage);
StoppingErrorMessage?.Invoke(Localization.Core.Error_creating_output_image_not_continuing +
Environment.NewLine + outputFormat.ErrorMessage);
Environment.NewLine +
outputFormat.ErrorMessage);
return;
}
@@ -529,8 +532,7 @@ partial class Dump
ResumeSupport.Process(true, true, totalSize, _dev.Manufacturer, _dev.Model, _dev.Serial, _dev.PlatformId,
ref _resume, ref currentTry, ref extents, _dev.FirmwareRevision, _private, _force);
if(currentTry == null ||
extents == null)
if(currentTry == null || extents == null)
StoppingErrorMessage?.Invoke(Localization.Core.Could_not_process_resume_file_not_continuing);
if(_createGraph)
@@ -606,7 +608,8 @@ partial class Dump
else
{
extentStart = (xboxSs.Value.Layer0EndPSN + 1) * 2 -
((xboxSs.Value.Extents[e].StartPSN ^ 0xFFFFFF) + 1) - 0x30000;
((xboxSs.Value.Extents[e].StartPSN ^ 0xFFFFFF) + 1) -
0x30000;
}
if(xboxSs.Value.Extents[e].EndPSN <= xboxSs.Value.Layer0EndPSN)
@@ -614,7 +617,8 @@ partial class Dump
else
{
extentEnd = (xboxSs.Value.Layer0EndPSN + 1) * 2 -
((xboxSs.Value.Extents[e].EndPSN ^ 0xFFFFFF) + 1) - 0x30000;
((xboxSs.Value.Extents[e].EndPSN ^ 0xFFFFFF) + 1) -
0x30000;
}
}
@@ -644,27 +648,22 @@ partial class Dump
if(extentStart - i < blocksToRead)
blocksToRead = (uint)(extentStart - i);
if(currentSpeed > maxSpeed &&
currentSpeed > 0)
if(currentSpeed > maxSpeed && currentSpeed > 0)
maxSpeed = currentSpeed;
if(currentSpeed < minSpeed &&
currentSpeed > 0)
if(currentSpeed < minSpeed && currentSpeed > 0)
minSpeed = currentSpeed;
UpdateProgress?.
Invoke(
string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks,
ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i, (long)totalSize);
Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i, (long)totalSize);
sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, false, false, false, (uint)i, blockSize, 0,
blocksToRead, false, _dev.Timeout, out cmdDuration);
totalDuration += cmdDuration;
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
mhddLog.Write(i, cmdDuration, blocksToRead);
ibgLog.Write(i, currentSpeed * 1024);
@@ -704,8 +703,10 @@ partial class Dump
i += _skip - blocksToRead;
string[] senseLines = Sense.PrettifySense(senseBuf).
Split(new[] { Environment.NewLine },
StringSplitOptions.RemoveEmptyEntries);
Split(new[]
{
Environment.NewLine
}, StringSplitOptions.RemoveEmptyEntries);
foreach(string senseLine in senseLines)
_dumpLog.WriteLine(senseLine);
@@ -790,10 +791,8 @@ partial class Dump
blocksToRead = (uint)(middleZone - 1 - middle);
UpdateProgress?.
Invoke(
string.Format(Localization.Core.Reading_sector_0_of_1_2, middle + currentSector, totalSize,
ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)(middle + currentSector), (long)totalSize);
Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, middle + currentSector, totalSize, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)(middle + currentSector), (long)totalSize);
mhddLog.Write(middle + currentSector, cmdDuration, blocksToRead);
ibgLog.Write(middle + currentSector, currentSpeed * 1024);
@@ -853,27 +852,22 @@ partial class Dump
if(l0Video + l1Video - l1 < blocksToRead)
blocksToRead = (uint)(l0Video + l1Video - l1);
if(currentSpeed > maxSpeed &&
currentSpeed > 0)
if(currentSpeed > maxSpeed && currentSpeed > 0)
maxSpeed = currentSpeed;
if(currentSpeed < minSpeed &&
currentSpeed > 0)
if(currentSpeed < minSpeed && currentSpeed > 0)
minSpeed = currentSpeed;
UpdateProgress?.
Invoke(
string.Format(Localization.Core.Reading_sector_0_of_1_2, currentSector, totalSize,
ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)currentSector, (long)totalSize);
Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, currentSector, totalSize, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)currentSector, (long)totalSize);
sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, false, false, false, (uint)l1, blockSize, 0,
blocksToRead, false, _dev.Timeout, out cmdDuration);
totalDuration += cmdDuration;
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
mhddLog.Write(currentSector, cmdDuration, blocksToRead);
ibgLog.Write(currentSector, currentSpeed * 1024);
@@ -907,7 +901,10 @@ partial class Dump
l1 += _skip - blocksToRead;
string[] senseLines = Sense.PrettifySense(senseBuf).
Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
Split(new[]
{
Environment.NewLine
}, StringSplitOptions.RemoveEmptyEntries);
foreach(string senseLine in senseLines)
_dumpLog.WriteLine(senseLine);
@@ -984,10 +981,7 @@ partial class Dump
#region Trimming
if(_resume.BadBlocks.Count > 0 &&
!_aborted &&
_trim &&
newTrim)
if(_resume.BadBlocks.Count > 0 && !_aborted && _trim && newTrim)
{
_trimStopwatch.Restart();
UpdateStatus?.Invoke(Localization.Core.Trimming_skipped_sectors);
@@ -1040,9 +1034,7 @@ partial class Dump
#region Error handling
if(_resume.BadBlocks.Count > 0 &&
!_aborted &&
_retryPasses > 0)
if(_resume.BadBlocks.Count > 0 && !_aborted && _retryPasses > 0)
{
List<ulong> tmpList = new();
@@ -1083,7 +1075,7 @@ partial class Dump
if(dcMode10.HasValue)
{
foreach(Modes.ModePage modePage in dcMode10.Value.Pages.Where(modePage =>
modePage is { Page: 0x01, Subpage: 0x00 }))
modePage is { Page: 0x01, Subpage: 0x00 }))
currentModePage = modePage;
}
}
@@ -1095,7 +1087,7 @@ partial class Dump
if(dcMode6.HasValue)
{
foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage =>
modePage is { Page: 0x01, Subpage: 0x00 }))
modePage is { Page: 0x01, Subpage: 0x00 }))
currentModePage = modePage;
}
}
@@ -1181,10 +1173,8 @@ partial class Dump
{
PulseProgress?.Invoke(runningPersistent
? string.
Format(
Localization.Core.
Retrying_sector_0_pass_1_recovering_partial_data_forward,
badSector, pass)
Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_forward,
badSector, pass)
: string.Format(Localization.Core.Retrying_sector_0_pass_1_forward,
badSector, pass));
}
@@ -1192,10 +1182,8 @@ partial class Dump
{
PulseProgress?.Invoke(runningPersistent
? string.
Format(
Localization.Core.
Retrying_sector_0_pass_1_recovering_partial_data_reverse,
badSector, pass)
Format(Localization.Core.Retrying_sector_0_pass_1_recovering_partial_data_reverse,
badSector, pass)
: string.Format(Localization.Core.Retrying_sector_0_pass_1_reverse,
badSector, pass));
}
@@ -1208,8 +1196,7 @@ partial class Dump
if(sense || _dev.Error)
_errorLog?.WriteLine(currentSector, _dev.Error, _dev.LastError, senseBuf);
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
_resume.BadBlocks.Remove(badSector);
extents.Add(badSector);
@@ -1225,9 +1212,7 @@ partial class Dump
outputFormat.WriteSector(readBuffer, badSector);
}
if(pass < _retryPasses &&
!_aborted &&
_resume.BadBlocks.Count > 0)
if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0)
{
pass++;
forward = !forward;
@@ -1244,7 +1229,10 @@ partial class Dump
var md = new Modes.DecodedMode
{
Header = new Modes.ModeHeader(),
Pages = new[] { currentModePage.Value }
Pages = new[]
{
currentModePage.Value
}
};
md6 = Modes.EncodeMode6(md, _dev.ScsiType);
@@ -1284,7 +1272,8 @@ partial class Dump
_dumpLog.WriteLine(string.Format(Localization.Core.Cannot_write_tag_0, tag.Key));
StoppingErrorMessage?.Invoke(string.Format(Localization.Core.Cannot_write_tag_0, tag.Key) +
Environment.NewLine + outputFormat.ErrorMessage);
Environment.NewLine +
outputFormat.ErrorMessage);
return;
}
@@ -1306,7 +1295,8 @@ partial class Dump
if(!outputFormat.SetImageInfo(metadata))
{
ErrorMessage?.Invoke(Localization.Core.Error_0_setting_metadata + Environment.NewLine +
ErrorMessage?.Invoke(Localization.Core.Error_0_setting_metadata +
Environment.NewLine +
outputFormat.ErrorMessage);
}
@@ -1355,17 +1345,17 @@ partial class Dump
UpdateStatus?.Invoke("");
UpdateStatus?.
Invoke(string.Format(
Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing,
_dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second),
totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second),
_imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing,
_dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second),
totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second),
_imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).
Per(totalDuration.Milliseconds()).Humanize()));
Per(totalDuration.Milliseconds()).
Humanize()));
if(maxSpeed > 0)
{

View File

@@ -95,15 +95,13 @@ public partial class DeviceInfo
AaruConsole.DebugWriteLine(MODULE_NAME, "SECTOR = 0x{0:X2}", errorRegisters.Sector);
AaruConsole.DebugWriteLine(MODULE_NAME, "CYLHIGH = 0x{0:X2}",
errorRegisters.CylinderHigh);
AaruConsole.DebugWriteLine(MODULE_NAME, "CYLHIGH = 0x{0:X2}", errorRegisters.CylinderHigh);
AaruConsole.DebugWriteLine(MODULE_NAME, "CYLLOW = 0x{0:X2}", errorRegisters.CylinderLow);
AaruConsole.DebugWriteLine(MODULE_NAME, "DEVICE = 0x{0:X2}", errorRegisters.DeviceHead);
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Error_code_equals_0,
dev.LastError);
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Error_code_equals_0, dev.LastError);
break;
}
@@ -138,15 +136,13 @@ public partial class DeviceInfo
AaruConsole.DebugWriteLine(MODULE_NAME, "SECTOR = 0x{0:X2}", errorRegisters.Sector);
AaruConsole.DebugWriteLine(MODULE_NAME, "CYLHIGH = 0x{0:X2}",
errorRegisters.CylinderHigh);
AaruConsole.DebugWriteLine(MODULE_NAME, "CYLHIGH = 0x{0:X2}", errorRegisters.CylinderHigh);
AaruConsole.DebugWriteLine(MODULE_NAME, "CYLLOW = 0x{0:X2}", errorRegisters.CylinderLow);
AaruConsole.DebugWriteLine(MODULE_NAME, "DEVICE = 0x{0:X2}", errorRegisters.DeviceHead);
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Error_code_equals_0,
dev.LastError);
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Error_code_equals_0, dev.LastError);
break;
}
@@ -201,8 +197,7 @@ public partial class DeviceInfo
sense = dev.ModeSense10(out byte[] modeBuf, out senseBuf, false, true, ScsiModeSensePageControl.Current,
0x3F, 0xFF, 5, out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
ScsiModeSense10 = modeBuf;
if(sense || dev.Error)
@@ -210,13 +205,11 @@ public partial class DeviceInfo
sense = dev.ModeSense10(out modeBuf, out senseBuf, false, true, ScsiModeSensePageControl.Current,
0x3F, 0x00, 5, out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
ScsiModeSense10 = modeBuf;
}
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
ScsiMode = Modes.DecodeMode10(modeBuf, devType);
bool useMode10 = !(sense || dev.Error || !ScsiMode.HasValue);
@@ -224,8 +217,7 @@ public partial class DeviceInfo
sense = dev.ModeSense6(out modeBuf, out senseBuf, false, ScsiModeSensePageControl.Current, 0x3F, 0xFF,
5, out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
ScsiModeSense6 = modeBuf;
if(sense || dev.Error)
@@ -233,8 +225,7 @@ public partial class DeviceInfo
sense = dev.ModeSense6(out modeBuf, out senseBuf, false, ScsiModeSensePageControl.Current, 0x3F,
0x00, 5, out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
ScsiModeSense6 = modeBuf;
}
@@ -242,14 +233,11 @@ public partial class DeviceInfo
{
sense = dev.ModeSense(out modeBuf, out senseBuf, 5, out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
ScsiModeSense6 = modeBuf;
}
if(!sense &&
!dev.Error &&
!useMode10)
if(!sense && !dev.Error && !useMode10)
ScsiMode = Modes.DecodeMode6(modeBuf, devType);
switch(devType)
@@ -584,8 +572,7 @@ public partial class DeviceInfo
sense = dev.ReadExtendedCsd(out mmcBuf, out _, dev.Timeout, out _);
if(!sense &&
!ArrayHelpers.ArrayIsNullOrEmpty(mmcBuf))
if(!sense && !ArrayHelpers.ArrayIsNullOrEmpty(mmcBuf))
ExtendedCSD = mmcBuf;
}

View File

@@ -148,8 +148,8 @@ sealed partial class Reader
ReadBlocks(out buffer, block, 1, out duration, out recoveredError, out blankCheck);
internal bool ReadBlocks(out byte[] buffer, ulong block, out double duration, out bool recoveredError,
out bool blankCheck) => ReadBlocks(out buffer, block, BlocksToRead, out duration,
out recoveredError, out blankCheck);
out bool blankCheck) => ReadBlocks(out buffer, block, BlocksToRead, out duration,
out recoveredError, out blankCheck);
internal bool ReadBlocks(out byte[] buffer, ulong block, uint count, out double duration, out bool recoveredError,
out bool blankCheck)

View File

@@ -64,8 +64,7 @@ sealed partial class Reader
if(_dev.Type != DeviceType.ATA)
return;
if(_ataId.CurrentCylinders > 0 &&
_ataId is { CurrentHeads: > 0, CurrentSectorsPerTrack: > 0 })
if(_ataId.CurrentCylinders > 0 && _ataId is { CurrentHeads: > 0, CurrentSectorsPerTrack: > 0 })
{
Cylinders = _ataId.CurrentCylinders;
Heads = (byte)_ataId.CurrentHeads;
@@ -172,19 +171,14 @@ sealed partial class Reader
if(IsLba)
{
if(Blocks > 0xFFFFFFF &&
!_ataReadLba48 &&
!_ataReadDmaLba48)
if(Blocks > 0xFFFFFFF && !_ataReadLba48 && !_ataReadDmaLba48)
{
ErrorMessage = Localization.Core.Device_needs_48_bit_LBA_commands_but_I_cant_issue_them_Aborting;
return true;
}
if(!_ataReadLba &&
!_ataReadRetryLba &&
!_ataReadDmaLba &&
!_ataReadDmaRetryLba)
if(!_ataReadLba && !_ataReadRetryLba && !_ataReadDmaLba && !_ataReadDmaRetryLba)
{
ErrorMessage = Localization.Core.Device_needs_28_bit_LBA_commands_but_I_cant_issue_them_Aborting;
@@ -193,10 +187,7 @@ sealed partial class Reader
}
else
{
if(!_ataRead &&
!_ataReadRetry &&
!_ataReadDma &&
!_ataReadDmaRetry)
if(!_ataRead && !_ataReadRetry && !_ataReadDma && !_ataReadDmaRetry)
{
ErrorMessage = Localization.Core.Device_needs_CHS_commands_but_I_cant_issue_them_Aborting;
@@ -236,13 +227,11 @@ sealed partial class Reader
bool AtaGetBlockSize()
{
if((_ataId.PhysLogSectorSize & 0x8000) == 0x0000 &&
(_ataId.PhysLogSectorSize & 0x4000) == 0x4000)
if((_ataId.PhysLogSectorSize & 0x8000) == 0x0000 && (_ataId.PhysLogSectorSize & 0x4000) == 0x4000)
{
if((_ataId.PhysLogSectorSize & 0x1000) == 0x1000)
{
if(_ataId.LogicalSectorWords <= 255 ||
_ataId.LogicalAlignment == 0xFFFF)
if(_ataId.LogicalSectorWords <= 255 || _ataId.LogicalAlignment == 0xFFFF)
LogicalBlockSize = 512;
else
LogicalBlockSize = _ataId.LogicalSectorWords * 2;
@@ -325,13 +314,11 @@ sealed partial class Reader
if(error)
BlocksToRead /= 2;
if(!error ||
BlocksToRead == 1)
if(!error || BlocksToRead == 1)
break;
}
if(!error ||
!IsLba)
if(!error || !IsLba)
return false;
BlocksToRead = 1;

View File

@@ -93,10 +93,7 @@ sealed partial class Reader
_read16 = !_dev.Read16(out _, out senseBuf, 0, false, false, false, lba, LogicalBlockSize, 0, 1, false,
_timeout, out _);
if(_read6 ||
_read10 ||
_read12 ||
_read16)
if(_read6 || _read10 || _read12 || _read16)
break;
lba = (uint)rnd.Next(1, (int)Blocks);
@@ -131,9 +128,8 @@ sealed partial class Reader
}
case true when !_read10 && !_read12 && !_read16 && Blocks > 0x001FFFFF + 1:
ErrorMessage =
string.Format(
Localization.Core.Device_only_supports_SCSI_READ_6_but_has_more_than_0_blocks_1_blocks_total,
0x001FFFFF + 1, Blocks);
string.Format(Localization.Core.Device_only_supports_SCSI_READ_6_but_has_more_than_0_blocks_1_blocks_total,
0x001FFFFF + 1, Blocks);
return true;
}
@@ -144,13 +140,11 @@ sealed partial class Reader
if(_read10)
_read12 = false;
if(!_read16 &&
Blocks > 0xFFFFFFFF + (long)1)
if(!_read16 && Blocks > 0xFFFFFFFF + (long)1)
{
ErrorMessage =
string.Format(
Localization.Core.Device_only_supports_SCSI_READ_10_but_has_more_than_0_blocks_1_blocks_total,
0xFFFFFFFF + (long)1, Blocks);
string.Format(Localization.Core.Device_only_supports_SCSI_READ_10_but_has_more_than_0_blocks_1_blocks_total,
0xFFFFFFFF + (long)1, Blocks);
return true;
}
@@ -234,21 +228,20 @@ sealed partial class Reader
case 512:
{
foreach(ushort testSize in new ushort[]
{
// Long sector sizes for floppies
514,
{
// Long sector sizes for floppies
514,
// Long sector sizes for SuperDisk
536, 558,
// Long sector sizes for SuperDisk
536, 558,
// Long sector sizes for 512-byte magneto-opticals
600, 610, 630
})
// Long sector sizes for 512-byte magneto-opticals
600, 610, 630
})
{
testSense = _dev.ReadLong16(out _, out senseBuf, false, 0, testSize, _timeout, out _);
if(!testSense &&
!_dev.Error)
if(!testSense && !_dev.Error)
{
_readLong16 = true;
LongBlockSize = testSize;
@@ -275,18 +268,17 @@ sealed partial class Reader
case 1024:
{
foreach(ushort testSize in new ushort[]
{
// Long sector sizes for floppies
1026,
{
// Long sector sizes for floppies
1026,
// Long sector sizes for 1024-byte magneto-opticals
1200
})
// Long sector sizes for 1024-byte magneto-opticals
1200
})
{
testSense = _dev.ReadLong16(out _, out senseBuf, false, 0, testSize, _timeout, out _);
if(!testSense &&
!_dev.Error)
if(!testSense && !_dev.Error)
{
_readLong16 = true;
LongBlockSize = testSize;
@@ -314,8 +306,7 @@ sealed partial class Reader
{
testSense = _dev.ReadLong16(out _, out senseBuf, false, 0, 2380, _timeout, out _);
if(!testSense &&
!_dev.Error)
if(!testSense && !_dev.Error)
{
_readLong16 = true;
LongBlockSize = 2380;
@@ -326,8 +317,7 @@ sealed partial class Reader
testSense = _dev.ReadLong10(out _, out senseBuf, false, false, 0, 2380, _timeout,
out _);
if(!testSense &&
!_dev.Error)
if(!testSense && !_dev.Error)
{
_readLong10 = true;
LongBlockSize = 2380;
@@ -341,8 +331,7 @@ sealed partial class Reader
{
testSense = _dev.ReadLong16(out _, out senseBuf, false, 0, 4760, _timeout, out _);
if(!testSense &&
!_dev.Error)
if(!testSense && !_dev.Error)
{
_readLong16 = true;
LongBlockSize = 4760;
@@ -353,8 +342,7 @@ sealed partial class Reader
testSense = _dev.ReadLong10(out _, out senseBuf, false, false, 0, 4760, _timeout,
out _);
if(!testSense &&
!_dev.Error)
if(!testSense && !_dev.Error)
{
_readLong10 = true;
LongBlockSize = 4760;
@@ -368,8 +356,7 @@ sealed partial class Reader
{
testSense = _dev.ReadLong16(out _, out senseBuf, false, 0, 9424, _timeout, out _);
if(!testSense &&
!_dev.Error)
if(!testSense && !_dev.Error)
{
_readLong16 = true;
LongBlockSize = 9424;
@@ -380,8 +367,7 @@ sealed partial class Reader
testSense = _dev.ReadLong10(out _, out senseBuf, false, false, 0, 9424, _timeout,
out _);
if(!testSense &&
!_dev.Error)
if(!testSense && !_dev.Error)
{
_readLong10 = true;
LongBlockSize = 9424;
@@ -394,8 +380,7 @@ sealed partial class Reader
}
}
if(!CanReadRaw &&
_dev.Manufacturer == "SYQUEST")
if(!CanReadRaw && _dev.Manufacturer == "SYQUEST")
{
testSense = _dev.SyQuestReadLong10(out _, out senseBuf, 0, 0xFFFF, _timeout, out _);
@@ -475,13 +460,11 @@ sealed partial class Reader
}
}
if(!CanReadRaw &&
LogicalBlockSize == 256)
if(!CanReadRaw && LogicalBlockSize == 256)
{
testSense = _dev.SyQuestReadLong6(out _, out senseBuf, 0, 262, _timeout, out _);
if(!testSense &&
!_dev.Error)
if(!testSense && !_dev.Error)
{
_syqReadLong6 = true;
LongBlockSize = 262;
@@ -511,13 +494,11 @@ sealed partial class Reader
}
// READ LONG (10) for some DVD drives
if(!CanReadRaw &&
_dev.Manufacturer == "MATSHITA")
if(!CanReadRaw && _dev.Manufacturer == "MATSHITA")
{
testSense = _dev.ReadLong10(out _, out senseBuf, false, false, 0, 37856, _timeout, out _);
if(!testSense &&
!_dev.Error)
if(!testSense && !_dev.Error)
{
_readLongDvd = true;
LongBlockSize = 37856;
@@ -635,8 +616,7 @@ sealed partial class Reader
BlocksToRead /= 2;
}
if(!_dev.Error ||
BlocksToRead == 1)
if(!_dev.Error || BlocksToRead == 1)
break;
}
@@ -730,8 +710,7 @@ sealed partial class Reader
if(sense || _dev.Error)
_errorLog?.WriteLine(block, _dev.Error, _dev.LastError, senseBuf);
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
return false;
recoveredError = Sense.Decode(senseBuf)?.SenseKey == SenseKeys.RecoveredError;

View File

@@ -79,8 +79,7 @@ public sealed partial class DeviceReport
if(ataId.UnformattedBPS != 0)
mediaTest.UnformattedBPS = ataId.UnformattedBPS;
if(ataId.Cylinders > 0 &&
ataId is { Heads: > 0, SectorsPerTrack: > 0 })
if(ataId.Cylinders > 0 && ataId is { Heads: > 0, SectorsPerTrack: > 0 })
{
mediaTest.CHS = new Chs
{
@@ -92,8 +91,7 @@ public sealed partial class DeviceReport
mediaTest.Blocks = (ulong)(ataId.Cylinders * ataId.Heads * ataId.SectorsPerTrack);
}
if(ataId.CurrentCylinders > 0 &&
ataId is { CurrentHeads: > 0, CurrentSectorsPerTrack: > 0 })
if(ataId.CurrentCylinders > 0 && ataId is { CurrentHeads: > 0, CurrentSectorsPerTrack: > 0 })
{
mediaTest.CurrentCHS = new Chs
{
@@ -121,8 +119,7 @@ public sealed partial class DeviceReport
mediaTest.Blocks = ataId.LBA48Sectors;
}
if(ataId.NominalRotationRate != 0x0000 &&
ataId.NominalRotationRate != 0xFFFF)
if(ataId.NominalRotationRate != 0x0000 && ataId.NominalRotationRate != 0xFFFF)
{
if(ataId.NominalRotationRate == 0x0001)
mediaTest.SolidStateDevice = true;
@@ -136,13 +133,11 @@ public sealed partial class DeviceReport
uint logicalSectorSize;
uint physicalSectorSize;
if((ataId.PhysLogSectorSize & 0x8000) == 0x0000 &&
(ataId.PhysLogSectorSize & 0x4000) == 0x4000)
if((ataId.PhysLogSectorSize & 0x8000) == 0x0000 && (ataId.PhysLogSectorSize & 0x4000) == 0x4000)
{
if((ataId.PhysLogSectorSize & 0x1000) == 0x1000)
{
if(ataId.LogicalSectorWords <= 255 ||
ataId.LogicalAlignment == 0xFFFF)
if(ataId.LogicalSectorWords <= 255 || ataId.LogicalAlignment == 0xFFFF)
logicalSectorSize = 512;
else
logicalSectorSize = ataId.LogicalSectorWords * 2;
@@ -167,13 +162,11 @@ public sealed partial class DeviceReport
{
mediaTest.PhysicalBlockSize = physicalSectorSize;
if((ataId.LogicalAlignment & 0x8000) == 0x0000 &&
(ataId.LogicalAlignment & 0x4000) == 0x4000)
if((ataId.LogicalAlignment & 0x8000) == 0x0000 && (ataId.LogicalAlignment & 0x4000) == 0x4000)
mediaTest.LogicalAlignment = (ushort)(ataId.LogicalAlignment & 0x3FFF);
}
if(ataId.EccBytes != 0x0000 &&
ataId.EccBytes != 0xFFFF)
if(ataId.EccBytes != 0x0000 && ataId.EccBytes != 0xFFFF)
mediaTest.LongBlockSize = logicalSectorSize + ataId.EccBytes;
if(ataId.UnformattedBPS > logicalSectorSize &&
@@ -198,8 +191,8 @@ public sealed partial class DeviceReport
sense = _dev.Read(out readBuf, out errorChs, false, 0, 0, 1, 1, _dev.Timeout, out _);
});
mediaTest.SupportsReadSectors = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 &&
readBuf.Length > 0;
mediaTest.SupportsReadSectors =
!sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0;
AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense,
errorChs.Status, errorChs.Error, readBuf.Length);
@@ -212,8 +205,8 @@ public sealed partial class DeviceReport
sense = _dev.Read(out readBuf, out errorChs, true, 0, 0, 1, 1, _dev.Timeout, out _);
});
mediaTest.SupportsReadRetry = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 &&
readBuf.Length > 0;
mediaTest.SupportsReadRetry =
!sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0;
AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense,
errorChs.Status, errorChs.Error, readBuf.Length);
@@ -226,8 +219,8 @@ public sealed partial class DeviceReport
sense = _dev.ReadDma(out readBuf, out errorChs, false, 0, 0, 1, 1, _dev.Timeout, out _);
});
mediaTest.SupportsReadDma = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 &&
readBuf.Length > 0;
mediaTest.SupportsReadDma =
!sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0;
AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense,
errorChs.Status, errorChs.Error, readBuf.Length);
@@ -240,8 +233,8 @@ public sealed partial class DeviceReport
sense = _dev.ReadDma(out readBuf, out errorChs, true, 0, 0, 1, 1, _dev.Timeout, out _);
});
mediaTest.SupportsReadDmaRetry = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 &&
readBuf.Length > 0;
mediaTest.SupportsReadDmaRetry =
!sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0;
AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense,
errorChs.Status, errorChs.Error, readBuf.Length);
@@ -257,8 +250,7 @@ public sealed partial class DeviceReport
mediaTest.SupportsSeek = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0;
AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2, sense,
errorChs.Status,
errorChs.Error);
errorChs.Status, errorChs.Error);
Spectre.ProgressSingleSpinner(ctx =>
{
@@ -266,8 +258,8 @@ public sealed partial class DeviceReport
sense = _dev.Read(out readBuf, out errorLba, false, 0, 1, _dev.Timeout, out _);
});
mediaTest.SupportsReadLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 &&
readBuf.Length > 0;
mediaTest.SupportsReadLba =
!sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0;
AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense,
errorChs.Status, errorChs.Error, readBuf.Length);
@@ -280,8 +272,8 @@ public sealed partial class DeviceReport
sense = _dev.Read(out readBuf, out errorLba, true, 0, 1, _dev.Timeout, out _);
});
mediaTest.SupportsReadRetryLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 &&
readBuf.Length > 0;
mediaTest.SupportsReadRetryLba =
!sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0;
AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense,
errorChs.Status, errorChs.Error, readBuf.Length);
@@ -294,8 +286,8 @@ public sealed partial class DeviceReport
sense = _dev.ReadDma(out readBuf, out errorLba, false, 0, 1, _dev.Timeout, out _);
});
mediaTest.SupportsReadDmaLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 &&
readBuf.Length > 0;
mediaTest.SupportsReadDmaLba =
!sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0;
AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense,
errorChs.Status, errorChs.Error, readBuf.Length);
@@ -308,8 +300,8 @@ public sealed partial class DeviceReport
sense = _dev.ReadDma(out readBuf, out errorLba, true, 0, 1, _dev.Timeout, out _);
});
mediaTest.SupportsReadDmaRetryLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 &&
readBuf.Length > 0;
mediaTest.SupportsReadDmaRetryLba =
!sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0;
AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense,
errorChs.Status, errorChs.Error, readBuf.Length);
@@ -325,8 +317,7 @@ public sealed partial class DeviceReport
mediaTest.SupportsSeekLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0;
AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2, sense,
errorChs.Status,
errorChs.Error);
errorChs.Status, errorChs.Error);
Spectre.ProgressSingleSpinner(ctx =>
{
@@ -334,8 +325,8 @@ public sealed partial class DeviceReport
sense = _dev.Read(out readBuf, out AtaErrorRegistersLba28 _, 0, 1, _dev.Timeout, out _);
});
mediaTest.SupportsReadLba48 = !sense && (errorLba48.Status & 0x01) != 0x01 && errorLba48.Error == 0 &&
readBuf.Length > 0;
mediaTest.SupportsReadLba48 =
!sense && (errorLba48.Status & 0x01) != 0x01 && errorLba48.Error == 0 && readBuf.Length > 0;
AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense,
errorChs.Status, errorChs.Error, readBuf.Length);
@@ -348,8 +339,8 @@ public sealed partial class DeviceReport
sense = _dev.ReadDma(out readBuf, out errorLba48, 0, 1, _dev.Timeout, out _);
});
mediaTest.SupportsReadDmaLba48 = !sense && (errorLba48.Status & 0x01) != 0x01 && errorLba48.Error == 0 &&
readBuf.Length > 0;
mediaTest.SupportsReadDmaLba48 =
!sense && (errorLba48.Status & 0x01) != 0x01 && errorLba48.Error == 0 && readBuf.Length > 0;
AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense,
errorChs.Status, errorChs.Error, readBuf.Length);
@@ -367,8 +358,7 @@ public sealed partial class DeviceReport
{
ataId = Identify.Decode(buffer).Value;
if(ataId.EccBytes != 0x0000 &&
ataId.EccBytes != 0xFFFF)
if(ataId.EccBytes != 0x0000 && ataId.EccBytes != 0xFFFF)
mediaTest.LongBlockSize = logicalSectorSize + ataId.EccBytes;
if(ataId.UnformattedBPS > logicalSectorSize &&
@@ -384,8 +374,11 @@ public sealed partial class DeviceReport
_dev.Timeout, out _);
});
mediaTest.SupportsReadLong = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 &&
readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
mediaTest.SupportsReadLong = !sense &&
(errorChs.Status & 0x01) != 0x01 &&
errorChs.Error == 0 &&
readBuf.Length > 0 &&
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense,
errorChs.Status, errorChs.Error, readBuf.Length);
@@ -400,9 +393,11 @@ public sealed partial class DeviceReport
_dev.Timeout, out _);
});
mediaTest.SupportsReadLongRetry = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 &&
readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) !=
checkCorrectRead;
mediaTest.SupportsReadLongRetry = !sense &&
(errorChs.Status & 0x01) != 0x01 &&
errorChs.Error == 0 &&
readBuf.Length > 0 &&
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense,
errorChs.Status, errorChs.Error, readBuf.Length);
@@ -417,8 +412,11 @@ public sealed partial class DeviceReport
out _);
});
mediaTest.SupportsReadLongLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 &&
readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
mediaTest.SupportsReadLongLba = !sense &&
(errorLba.Status & 0x01) != 0x01 &&
errorLba.Error == 0 &&
readBuf.Length > 0 &&
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense,
errorChs.Status, errorChs.Error, readBuf.Length);
@@ -433,9 +431,11 @@ public sealed partial class DeviceReport
out _);
});
mediaTest.SupportsReadLongRetryLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 &&
readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) !=
checkCorrectRead;
mediaTest.SupportsReadLongRetryLba = !sense &&
(errorLba.Status & 0x01) != 0x01 &&
errorLba.Error == 0 &&
readBuf.Length > 0 &&
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense,
errorChs.Status, errorChs.Error, readBuf.Length);
@@ -464,8 +464,7 @@ public sealed partial class DeviceReport
if(ataId.UnformattedBPS != 0)
capabilities.UnformattedBPS = ataId.UnformattedBPS;
if(ataId.Cylinders > 0 &&
ataId is { Heads: > 0, SectorsPerTrack: > 0 })
if(ataId.Cylinders > 0 && ataId is { Heads: > 0, SectorsPerTrack: > 0 })
{
capabilities.CHS = new Chs
{
@@ -477,8 +476,7 @@ public sealed partial class DeviceReport
capabilities.Blocks = (ulong)(ataId.Cylinders * ataId.Heads * ataId.SectorsPerTrack);
}
if(ataId.CurrentCylinders > 0 &&
ataId is { CurrentHeads: > 0, CurrentSectorsPerTrack: > 0 })
if(ataId.CurrentCylinders > 0 && ataId is { CurrentHeads: > 0, CurrentSectorsPerTrack: > 0 })
{
capabilities.CurrentCHS = new Chs
{
@@ -502,8 +500,7 @@ public sealed partial class DeviceReport
capabilities.Blocks = ataId.LBA48Sectors;
}
if(ataId.NominalRotationRate != 0x0000 &&
ataId.NominalRotationRate != 0xFFFF)
if(ataId.NominalRotationRate != 0x0000 && ataId.NominalRotationRate != 0xFFFF)
{
if(ataId.NominalRotationRate == 0x0001)
capabilities.SolidStateDevice = true;
@@ -517,13 +514,11 @@ public sealed partial class DeviceReport
uint logicalSectorSize;
uint physicalSectorSize;
if((ataId.PhysLogSectorSize & 0x8000) == 0x0000 &&
(ataId.PhysLogSectorSize & 0x4000) == 0x4000)
if((ataId.PhysLogSectorSize & 0x8000) == 0x0000 && (ataId.PhysLogSectorSize & 0x4000) == 0x4000)
{
if((ataId.PhysLogSectorSize & 0x1000) == 0x1000)
{
if(ataId.LogicalSectorWords <= 255 ||
ataId.LogicalAlignment == 0xFFFF)
if(ataId.LogicalSectorWords <= 255 || ataId.LogicalAlignment == 0xFFFF)
logicalSectorSize = 512;
else
logicalSectorSize = ataId.LogicalSectorWords * 2;
@@ -548,13 +543,11 @@ public sealed partial class DeviceReport
{
capabilities.PhysicalBlockSize = physicalSectorSize;
if((ataId.LogicalAlignment & 0x8000) == 0x0000 &&
(ataId.LogicalAlignment & 0x4000) == 0x4000)
if((ataId.LogicalAlignment & 0x8000) == 0x0000 && (ataId.LogicalAlignment & 0x4000) == 0x4000)
capabilities.LogicalAlignment = (ushort)(ataId.LogicalAlignment & 0x3FFF);
}
if(ataId.EccBytes != 0x0000 &&
ataId.EccBytes != 0xFFFF)
if(ataId.EccBytes != 0x0000 && ataId.EccBytes != 0xFFFF)
capabilities.LongBlockSize = logicalSectorSize + ataId.EccBytes;
if(ataId.UnformattedBPS > logicalSectorSize &&
@@ -579,8 +572,8 @@ public sealed partial class DeviceReport
sense = _dev.Read(out readBuf, out errorChs, false, 0, 0, 1, 1, _dev.Timeout, out _);
});
capabilities.SupportsReadSectors = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 &&
readBuf.Length > 0;
capabilities.SupportsReadSectors =
!sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0;
AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense,
errorChs.Status, errorChs.Error, readBuf.Length);
@@ -621,8 +614,8 @@ public sealed partial class DeviceReport
sense = _dev.ReadDma(out readBuf, out errorChs, true, 0, 0, 1, 1, _dev.Timeout, out _);
});
capabilities.SupportsReadDmaRetry = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 &&
readBuf.Length > 0;
capabilities.SupportsReadDmaRetry =
!sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0;
AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense,
errorChs.Status, errorChs.Error, readBuf.Length);
@@ -660,8 +653,8 @@ public sealed partial class DeviceReport
sense = _dev.Read(out readBuf, out errorLba, true, 0, 1, _dev.Timeout, out _);
});
capabilities.SupportsReadRetryLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 &&
readBuf.Length > 0;
capabilities.SupportsReadRetryLba =
!sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0;
AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense,
errorLba.Status, errorLba.Error, readBuf.Length);
@@ -674,8 +667,8 @@ public sealed partial class DeviceReport
sense = _dev.ReadDma(out readBuf, out errorLba, false, 0, 1, _dev.Timeout, out _);
});
capabilities.SupportsReadDmaLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 &&
readBuf.Length > 0;
capabilities.SupportsReadDmaLba =
!sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0;
AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense,
errorLba.Status, errorLba.Error, readBuf.Length);
@@ -713,8 +706,8 @@ public sealed partial class DeviceReport
sense = _dev.Read(out readBuf, out errorLba48, 0, 1, _dev.Timeout, out _);
});
capabilities.SupportsReadLba48 = !sense && (errorLba48.Status & 0x01) != 0x01 && errorLba48.Error == 0 &&
readBuf.Length > 0;
capabilities.SupportsReadLba48 =
!sense && (errorLba48.Status & 0x01) != 0x01 && errorLba48.Error == 0 && readBuf.Length > 0;
AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense,
errorLba48.Status, errorLba48.Error, readBuf.Length);
@@ -727,8 +720,8 @@ public sealed partial class DeviceReport
sense = _dev.ReadDma(out readBuf, out errorLba48, 0, 1, _dev.Timeout, out _);
});
capabilities.SupportsReadDmaLba48 = !sense && (errorLba48.Status & 0x01) != 0x01 && errorLba48.Error == 0 &&
readBuf.Length > 0;
capabilities.SupportsReadDmaLba48 =
!sense && (errorLba48.Status & 0x01) != 0x01 && errorLba48.Error == 0 && readBuf.Length > 0;
AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense,
errorLba48.Status, errorLba48.Error, readBuf.Length);
@@ -746,8 +739,7 @@ public sealed partial class DeviceReport
{
ataId = Identify.Decode(buffer).Value;
if(ataId.EccBytes != 0x0000 &&
ataId.EccBytes != 0xFFFF)
if(ataId.EccBytes != 0x0000 && ataId.EccBytes != 0xFFFF)
capabilities.LongBlockSize = logicalSectorSize + ataId.EccBytes;
if(ataId.UnformattedBPS > logicalSectorSize &&
@@ -763,8 +755,11 @@ public sealed partial class DeviceReport
_dev.Timeout, out _);
});
capabilities.SupportsReadLong = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 &&
readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
capabilities.SupportsReadLong = !sense &&
(errorChs.Status & 0x01) != 0x01 &&
errorChs.Error == 0 &&
readBuf.Length > 0 &&
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense,
errorChs.Status, errorChs.Error, readBuf.Length);
@@ -779,9 +774,11 @@ public sealed partial class DeviceReport
_dev.Timeout, out _);
});
capabilities.SupportsReadLongRetry = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 &&
readBuf.Length > 0 &&
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
capabilities.SupportsReadLongRetry = !sense &&
(errorChs.Status & 0x01) != 0x01 &&
errorChs.Error == 0 &&
readBuf.Length > 0 &&
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense,
errorChs.Status, errorChs.Error, readBuf.Length);
@@ -796,8 +793,11 @@ public sealed partial class DeviceReport
out _);
});
capabilities.SupportsReadLongLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 &&
readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
capabilities.SupportsReadLongLba = !sense &&
(errorLba.Status & 0x01) != 0x01 &&
errorLba.Error == 0 &&
readBuf.Length > 0 &&
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense,
errorLba.Status, errorLba.Error, readBuf.Length);
@@ -812,9 +812,11 @@ public sealed partial class DeviceReport
out _);
});
capabilities.SupportsReadLongRetryLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 &&
readBuf.Length > 0 && BitConverter.ToUInt64(readBuf, 0) !=
checkCorrectRead;
capabilities.SupportsReadLongRetryLba = !sense &&
(errorLba.Status & 0x01) != 0x01 &&
errorLba.Error == 0 &&
readBuf.Length > 0 &&
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
AaruConsole.DebugWriteLine(ATA_MODULE_NAME, Localization.Core.Sense_0_Status_1_Error_2_Length_3, sense,
errorLba.Status, errorLba.Error, readBuf.Length);

View File

@@ -53,8 +53,7 @@ public sealed partial class DeviceReport
var pressedKey = new ConsoleKeyInfo();
while(pressedKey.Key != ConsoleKey.Y &&
pressedKey.Key != ConsoleKey.N)
while(pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)
{
AaruConsole.Write(Localization.Core.
Have_you_previously_tried_with_a_GD_ROM_disc_and_did_the_computer_hang_or_crash_Q);
@@ -256,8 +255,7 @@ public sealed partial class DeviceReport
return;
}
if(newLeadOutTrack.PMIN >= 0xA0 &&
!tocIsNotBcd)
if(newLeadOutTrack.PMIN >= 0xA0 && !tocIsNotBcd)
newLeadOutTrack.PMIN -= 0x90;
if(newLeadOutTrack.PMIN != leadOutTrack.PMIN ||
@@ -1112,14 +1110,14 @@ public sealed partial class DeviceReport
while(true)
{
report.GdRomSwapDiscCapabilities.Lba100000PqReadable = !_dev.ReadCd(out byte[] lba100000PqBuffer,
out byte[] lba100000PqSenseBuffer,
100000, 2368, cluster,
MmcSectorTypes.AllTypes, false,
false, true,
MmcHeaderCodes.AllHeaders, true,
true, MmcErrorField.None,
MmcSubchannel.Q16, _dev.Timeout,
out _);
out byte[] lba100000PqSenseBuffer,
100000, 2368, cluster,
MmcSectorTypes.AllTypes, false,
false, true,
MmcHeaderCodes.AllHeaders, true,
true, MmcErrorField.None,
MmcSubchannel.Q16, _dev.Timeout,
out _);
report.GdRomSwapDiscCapabilities.Lba100000PqData = lba100000PqBuffer;
report.GdRomSwapDiscCapabilities.Lba100000PqSense = lba100000PqSenseBuffer;
@@ -1176,14 +1174,14 @@ public sealed partial class DeviceReport
while(true)
{
report.GdRomSwapDiscCapabilities.Lba450000PqReadable = !_dev.ReadCd(out byte[] lba450000PqBuffer,
out byte[] lba450000PqSenseBuffer,
450000, 2368, cluster,
MmcSectorTypes.AllTypes, false,
false, true,
MmcHeaderCodes.AllHeaders, true,
true, MmcErrorField.None,
MmcSubchannel.Q16, _dev.Timeout,
out _);
out byte[] lba450000PqSenseBuffer,
450000, 2368, cluster,
MmcSectorTypes.AllTypes, false,
false, true,
MmcHeaderCodes.AllHeaders, true,
true, MmcErrorField.None,
MmcSubchannel.Q16, _dev.Timeout,
out _);
report.GdRomSwapDiscCapabilities.Lba450000PqData = lba450000PqBuffer;
report.GdRomSwapDiscCapabilities.Lba450000PqSense = lba450000PqSenseBuffer;
@@ -1209,14 +1207,14 @@ public sealed partial class DeviceReport
while(true)
{
report.GdRomSwapDiscCapabilities.Lba400000PqReadable = !_dev.ReadCd(out byte[] lba400000PqBuffer,
out byte[] lba400000PqSenseBuffer,
400000, 2368, cluster,
MmcSectorTypes.AllTypes, false,
false, true,
MmcHeaderCodes.AllHeaders, true,
true, MmcErrorField.None,
MmcSubchannel.Q16, _dev.Timeout,
out _);
out byte[] lba400000PqSenseBuffer,
400000, 2368, cluster,
MmcSectorTypes.AllTypes, false,
false, true,
MmcHeaderCodes.AllHeaders, true,
true, MmcErrorField.None,
MmcSubchannel.Q16, _dev.Timeout,
out _);
report.GdRomSwapDiscCapabilities.Lba400000PqData = lba400000PqBuffer;
report.GdRomSwapDiscCapabilities.Lba400000PqSense = lba400000PqSenseBuffer;
@@ -1304,14 +1302,14 @@ public sealed partial class DeviceReport
while(true)
{
report.GdRomSwapDiscCapabilities.Lba100000RwReadable = !_dev.ReadCd(out byte[] lba100000RwBuffer,
out byte[] lba100000RwSenseBuffer,
100000, 2448, cluster,
MmcSectorTypes.AllTypes, false,
false, true,
MmcHeaderCodes.AllHeaders, true,
true, MmcErrorField.None,
MmcSubchannel.Raw, _dev.Timeout,
out _);
out byte[] lba100000RwSenseBuffer,
100000, 2448, cluster,
MmcSectorTypes.AllTypes, false,
false, true,
MmcHeaderCodes.AllHeaders, true,
true, MmcErrorField.None,
MmcSubchannel.Raw, _dev.Timeout,
out _);
report.GdRomSwapDiscCapabilities.Lba100000RwData = lba100000RwBuffer;
report.GdRomSwapDiscCapabilities.Lba100000RwSense = lba100000RwSenseBuffer;
@@ -1368,14 +1366,14 @@ public sealed partial class DeviceReport
while(true)
{
report.GdRomSwapDiscCapabilities.Lba450000RwReadable = !_dev.ReadCd(out byte[] lba450000RwBuffer,
out byte[] lba450000RwSenseBuffer,
450000, 2448, cluster,
MmcSectorTypes.AllTypes, false,
false, true,
MmcHeaderCodes.AllHeaders, true,
true, MmcErrorField.None,
MmcSubchannel.Raw, _dev.Timeout,
out _);
out byte[] lba450000RwSenseBuffer,
450000, 2448, cluster,
MmcSectorTypes.AllTypes, false,
false, true,
MmcHeaderCodes.AllHeaders, true,
true, MmcErrorField.None,
MmcSubchannel.Raw, _dev.Timeout,
out _);
report.GdRomSwapDiscCapabilities.Lba450000RwData = lba450000RwBuffer;
report.GdRomSwapDiscCapabilities.Lba450000RwSense = lba450000RwSenseBuffer;
@@ -1401,14 +1399,14 @@ public sealed partial class DeviceReport
while(true)
{
report.GdRomSwapDiscCapabilities.Lba400000RwReadable = !_dev.ReadCd(out byte[] lba400000RwBuffer,
out byte[] lba400000RwSenseBuffer,
400000, 2448, cluster,
MmcSectorTypes.AllTypes, false,
false, true,
MmcHeaderCodes.AllHeaders, true,
true, MmcErrorField.None,
MmcSubchannel.Raw, _dev.Timeout,
out _);
out byte[] lba400000RwSenseBuffer,
400000, 2448, cluster,
MmcSectorTypes.AllTypes, false,
false, true,
MmcHeaderCodes.AllHeaders, true,
true, MmcErrorField.None,
MmcSubchannel.Raw, _dev.Timeout,
out _);
report.GdRomSwapDiscCapabilities.Lba400000RwData = lba400000RwBuffer;
report.GdRomSwapDiscCapabilities.Lba400000RwSense = lba400000RwSenseBuffer;
@@ -1504,8 +1502,7 @@ public sealed partial class DeviceReport
pressedKey = new ConsoleKeyInfo();
while(pressedKey.Key != ConsoleKey.Y &&
pressedKey.Key != ConsoleKey.N)
while(pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)
{
AaruConsole.Write(Localization.Core.Test_read_whole_high_density_area_proceed_Q);
@@ -1676,11 +1673,9 @@ public sealed partial class DeviceReport
? _dev.ReadCd(out buffer, out senseBuffer, lba, blockSize, cluster, MmcSectorTypes.Cdda, false,
false, false, MmcHeaderCodes.None, true, false, MmcErrorField.None, subchannel,
_dev.Timeout, out _)
: _dev.ReadCd(out buffer, out senseBuffer, lba, blockSize,
cluster, MmcSectorTypes.AllTypes, false, false,
true, MmcHeaderCodes.AllHeaders, true, true,
MmcErrorField.None, subchannel, _dev.Timeout,
out _);
: _dev.ReadCd(out buffer, out senseBuffer, lba, blockSize, cluster, MmcSectorTypes.AllTypes,
false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
subchannel, _dev.Timeout, out _);
if(sense)
{

View File

@@ -602,13 +602,13 @@ public sealed partial class DeviceReport
sense = _dev.ReadCapacity(out buffer, out senseBuffer, _dev.Timeout, out _);
});
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
mediaTest.SupportsReadCapacity = true;
mediaTest.Blocks = ((ulong)((buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) + buffer[3]) &
0xFFFFFFFF) + 1;
0xFFFFFFFF) +
1;
mediaTest.BlockSize = (uint)((buffer[5] << 24) + (buffer[5] << 16) + (buffer[6] << 8) + buffer[7]);
}
@@ -619,8 +619,7 @@ public sealed partial class DeviceReport
sense = _dev.ReadCapacity16(out buffer, out buffer, _dev.Timeout, out _);
});
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
mediaTest.SupportsReadCapacity16 = true;
var temp = new byte[8];
@@ -640,8 +639,7 @@ public sealed partial class DeviceReport
0x00, _dev.Timeout, out _);
});
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
decMode = Modes.DecodeMode10(buffer, _dev.ScsiType);
@@ -654,8 +652,7 @@ public sealed partial class DeviceReport
sense = _dev.ModeSense(out buffer, out senseBuffer, _dev.Timeout, out _);
});
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
decMode ??= Modes.DecodeMode6(buffer, _dev.ScsiType);
@@ -906,8 +903,7 @@ public sealed partial class DeviceReport
break;
}
if(mediaType.StartsWith("BD-R", StringComparison.Ordinal) &&
mediaType != "BD-ROM")
if(mediaType.StartsWith("BD-R", StringComparison.Ordinal) && mediaType != "BD-ROM")
{
Spectre.ProgressSingleSpinner(ctx =>
{
@@ -984,8 +980,7 @@ public sealed partial class DeviceReport
mediaTest.EmbossedPfiData = buffer;
}
if(mediaType.StartsWith("DVD+R", StringComparison.Ordinal) ||
mediaType == "DVD+MRW")
if(mediaType.StartsWith("DVD+R", StringComparison.Ordinal) || mediaType == "DVD+MRW")
{
Spectre.ProgressSingleSpinner(ctx =>
{
@@ -1295,8 +1290,7 @@ public sealed partial class DeviceReport
mediaTest.ReadCdMsfFullData = buffer;
}
if(mediaTest.SupportsReadCdRaw == true ||
mediaType == "Audio CD")
if(mediaTest.SupportsReadCdRaw == true || mediaType == "Audio CD")
{
Spectre.ProgressSingleSpinner(ctx =>
{
@@ -1339,7 +1333,10 @@ public sealed partial class DeviceReport
{
ctx.AddTask(Localization.Core.Trying_to_read_CD_Lead_In).IsIndeterminate();
foreach(int i in new[] { -5000, -4000, -3000, -2000, -1000, -500, -250 })
foreach(int i in new[]
{
-5000, -4000, -3000, -2000, -1000, -500, -250
})
{
if(mediaType == "Audio CD")
{
@@ -1960,14 +1957,12 @@ public sealed partial class DeviceReport
}
}
if(mediaTest.SupportsReadLong == true &&
mediaTest.LongBlockSize == mediaTest.BlockSize)
if(mediaTest.SupportsReadLong == true && mediaTest.LongBlockSize == mediaTest.BlockSize)
{
// DVDs
sense = _dev.ReadLong10(out buffer, out senseBuffer, false, false, 16, 37856, _dev.Timeout, out _);
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
mediaTest.ReadLong10Data = buffer;
mediaTest.SupportsReadLong = true;
@@ -2024,8 +2019,7 @@ public sealed partial class DeviceReport
{
ctx.AddTask(Localization.Core.Trying_MediaTek_READ_DRAM_command).IsIndeterminate();
if(mediaType == "Audio CD" &&
mediaTest.SupportsReadCd == true)
if(mediaType == "Audio CD" && mediaTest.SupportsReadCd == true)
{
_dev.ReadCd(out _, out _, 0, 2352, 1, MmcSectorTypes.Cdda, false, false, false, MmcHeaderCodes.None,
true, false, MmcErrorField.None, MmcSubchannel.None, _dev.Timeout, out _);
@@ -2092,8 +2086,7 @@ public sealed partial class DeviceReport
if(!(mediaTest.Blocks > 0))
return;
if(mediaType == "Audio CD" &&
mediaTest.SupportsReadCd == true)
if(mediaType == "Audio CD" && mediaTest.SupportsReadCd == true)
{
_dev.ReadCd(out _, out _, (uint)(mediaTest.Blocks + 1), 2352, 1, MmcSectorTypes.Cdda, false, false,
false, MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.None,
@@ -2207,8 +2200,7 @@ public sealed partial class DeviceReport
FullTOC.TrackDataDescriptor secondSessionFirstTrack =
decodedToc.TrackDescriptors.FirstOrDefault(t => t is { SessionNumber: > 1, POINT: <= 99 });
if(firstSessionLeadOutTrack.SessionNumber == 0 ||
secondSessionFirstTrack.SessionNumber == 0)
if(firstSessionLeadOutTrack.SessionNumber == 0 || secondSessionFirstTrack.SessionNumber == 0)
{
AaruConsole.ErrorWriteLine(Localization.Core.
Could_not_find_second_session_Have_you_inserted_the_correct_type_of_disc);
@@ -2228,12 +2220,14 @@ public sealed partial class DeviceReport
// Skip Lead-Out pre-gap
var firstSessionLeadOutLba = (uint)(firstSessionLeadOutTrack.PMIN * 60 * 75 +
firstSessionLeadOutTrack.PSEC * 75 +
firstSessionLeadOutTrack.PFRAME + 150);
firstSessionLeadOutTrack.PFRAME +
150);
// Skip second session track pre-gap
var secondSessionLeadInLba = (uint)(secondSessionFirstTrack.PMIN * 60 * 75 +
secondSessionFirstTrack.PSEC * 75 +
secondSessionFirstTrack.PFRAME - 300);
secondSessionFirstTrack.PFRAME -
300);
Spectre.ProgressSingleSpinner(ctx =>
{

View File

@@ -174,8 +174,7 @@ public sealed partial class DeviceReport
_dev.Timeout, out _);
});
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
decMode = Modes.DecodeMode10(buffer, _dev.ScsiType);
seqTest.ModeSense10Data = buffer;
@@ -187,8 +186,7 @@ public sealed partial class DeviceReport
sense = _dev.ModeSense(out buffer, out _, _dev.Timeout, out _);
});
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
decMode ??= Modes.DecodeMode6(buffer, _dev.ScsiType);

View File

@@ -121,7 +121,8 @@ public sealed partial class DeviceReport
Spectre.ProgressSingleSpinner(ctx =>
{
ProgressTask task = ctx.AddTask(Localization.Core.Querying_SCSI_EVPD_pages,
maxValue: evpdPages.Count(page => page != 0x80)).IsIndeterminate();
maxValue: evpdPages.Count(page => page != 0x80)).
IsIndeterminate();
foreach(byte page in evpdPages.Where(page => page != 0x80))
{
@@ -231,10 +232,10 @@ public sealed partial class DeviceReport
IsIndeterminate();
foreach(ScsiModeSensePageControl pageControl in new[]
{
ScsiModeSensePageControl.Default, ScsiModeSensePageControl.Current,
ScsiModeSensePageControl.Changeable
})
{
ScsiModeSensePageControl.Default, ScsiModeSensePageControl.Current,
ScsiModeSensePageControl.Changeable
})
{
var saveBuffer = false;
@@ -256,8 +257,7 @@ public sealed partial class DeviceReport
sense = _dev.ModeSense10(out mode10Buffer, out _, false, false, pageControl, 0x3F, 0x00,
_dev.Timeout, out _);
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
v2.SCSI.SupportsModeSense10 = true;
decMode ??= Modes.DecodeMode10(mode10Buffer, devType);
@@ -314,10 +314,10 @@ public sealed partial class DeviceReport
IsIndeterminate();
foreach(ScsiModeSensePageControl pageControl in new[]
{
ScsiModeSensePageControl.Default, ScsiModeSensePageControl.Current,
ScsiModeSensePageControl.Changeable
})
{
ScsiModeSensePageControl.Default, ScsiModeSensePageControl.Current,
ScsiModeSensePageControl.Changeable
})
{
var saveBuffer = false;
@@ -349,8 +349,7 @@ public sealed partial class DeviceReport
sense = _dev.ModeSense6(out mode6Buffer, out _, false, pageControl, 0x00, 0x00,
_dev.Timeout, out _);
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
v2.SCSI.SupportsModeSense6 = true;
decMode ??= Modes.DecodeMode6(mode6Buffer, devType);
@@ -453,8 +452,7 @@ public sealed partial class DeviceReport
modePages.Add(modePage);
if(modePage.page == 0x2A &&
modePage.subpage == 0x00)
if(modePage.page == 0x2A && modePage.subpage == 0x00)
cdromMode = page.PageResponse;
}
@@ -477,13 +475,13 @@ public sealed partial class DeviceReport
sense = _dev.ReadCapacity(out buffer, out senseBuffer, _dev.Timeout, out _);
});
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
mediaTest.SupportsReadCapacity = true;
mediaTest.Blocks = ((ulong)((buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) + buffer[3]) &
0xFFFFFFFF) + 1;
0xFFFFFFFF) +
1;
mediaTest.BlockSize = (uint)((buffer[4] << 24) + (buffer[5] << 16) + (buffer[6] << 8) + buffer[7]);
}
@@ -494,8 +492,7 @@ public sealed partial class DeviceReport
sense = _dev.ReadCapacity16(out buffer, out buffer, _dev.Timeout, out _);
});
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
mediaTest.SupportsReadCapacity16 = true;
var temp = new byte[8];
@@ -515,8 +512,7 @@ public sealed partial class DeviceReport
0x00, _dev.Timeout, out _);
});
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
decMode = Modes.DecodeMode10(buffer, _dev.ScsiType);
mediaTest.ModeSense10Data = buffer;
@@ -528,8 +524,7 @@ public sealed partial class DeviceReport
sense = _dev.ModeSense(out buffer, out senseBuffer, _dev.Timeout, out _);
});
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
decMode ??= Modes.DecodeMode6(buffer, _dev.ScsiType);
@@ -660,22 +655,22 @@ public sealed partial class DeviceReport
case 512:
{
foreach(ushort testSize in new ushort[]
{
// Long sector sizes for floppies
514,
{
// Long sector sizes for floppies
514,
// Long sector sizes for SuperDisk
536, 558,
// Long sector sizes for SuperDisk
536, 558,
// Long sector sizes for 512-byte magneto-opticals
600, 610, 630
})
// Long sector sizes for 512-byte magneto-opticals
600, 610, 630
})
{
sense = mediaTest.SupportsReadLong16 == true
? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, testSize, _dev.Timeout,
out _)
: _dev.ReadLong10(out buffer, out senseBuffer, false,
false, 0, testSize, _dev.Timeout, out _);
: _dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, testSize,
_dev.Timeout, out _);
if(sense || _dev.Error)
continue;
@@ -690,19 +685,19 @@ public sealed partial class DeviceReport
case 1024:
{
foreach(ushort testSize in new ushort[]
{
// Long sector sizes for floppies
1026,
{
// Long sector sizes for floppies
1026,
// Long sector sizes for 1024-byte magneto-opticals
1200
})
// Long sector sizes for 1024-byte magneto-opticals
1200
})
{
sense = mediaTest.SupportsReadLong16 == true
? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, testSize, _dev.Timeout,
out _)
: _dev.ReadLong10(out buffer, out senseBuffer, false,
false, 0, testSize, _dev.Timeout, out _);
: _dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, testSize,
_dev.Timeout, out _);
if(sense || _dev.Error)
continue;
@@ -721,8 +716,7 @@ public sealed partial class DeviceReport
: _dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 2380, _dev.Timeout,
out _);
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
mediaTest.LongBlockSize = 2380;
break;
@@ -734,8 +728,7 @@ public sealed partial class DeviceReport
: _dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 4760, _dev.Timeout,
out _);
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
mediaTest.LongBlockSize = 4760;
break;
@@ -747,8 +740,7 @@ public sealed partial class DeviceReport
: _dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, 9424, _dev.Timeout,
out _);
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
mediaTest.LongBlockSize = 9424;
break;
@@ -786,13 +778,13 @@ public sealed partial class DeviceReport
sense = _dev.ReadCapacity(out buffer, out senseBuffer, _dev.Timeout, out _);
});
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
capabilities.SupportsReadCapacity = true;
capabilities.Blocks = ((ulong)((buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) + buffer[3]) &
0xFFFFFFFF) + 1;
0xFFFFFFFF) +
1;
capabilities.BlockSize = (uint)((buffer[4] << 24) + (buffer[5] << 16) + (buffer[6] << 8) + buffer[7]);
}
@@ -803,8 +795,7 @@ public sealed partial class DeviceReport
sense = _dev.ReadCapacity16(out buffer, out buffer, _dev.Timeout, out _);
});
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
capabilities.SupportsReadCapacity16 = true;
var temp = new byte[8];
@@ -824,8 +815,7 @@ public sealed partial class DeviceReport
0x00, _dev.Timeout, out _);
});
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
decMode = Modes.DecodeMode10(buffer, _dev.ScsiType);
capabilities.ModeSense10Data = buffer;
@@ -837,8 +827,7 @@ public sealed partial class DeviceReport
sense = _dev.ModeSense(out buffer, out senseBuffer, _dev.Timeout, out _);
});
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
decMode ??= Modes.DecodeMode6(buffer, _dev.ScsiType);
@@ -970,29 +959,30 @@ public sealed partial class DeviceReport
{
ctx.AddTask(capabilities.SupportsReadLong16 == true
? Localization.Core.Trying_SCSI_READ_LONG_16
: Localization.Core.Trying_SCSI_READ_LONG_10).IsIndeterminate();
: Localization.Core.Trying_SCSI_READ_LONG_10).
IsIndeterminate();
switch(capabilities.BlockSize)
{
case 512:
{
foreach(ushort testSize in new ushort[]
{
// Long sector sizes for floppies
514,
{
// Long sector sizes for floppies
514,
// Long sector sizes for SuperDisk
536, 558,
// Long sector sizes for SuperDisk
536, 558,
// Long sector sizes for 512-byte magneto-opticals
600, 610, 630
})
// Long sector sizes for 512-byte magneto-opticals
600, 610, 630
})
{
sense = capabilities.SupportsReadLong16 == true
? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, testSize, _dev.Timeout,
out _)
: _dev.ReadLong10(out buffer, out senseBuffer, false,
false, 0, testSize, _dev.Timeout, out _);
: _dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, testSize,
_dev.Timeout, out _);
if(sense || _dev.Error)
continue;
@@ -1008,19 +998,19 @@ public sealed partial class DeviceReport
case 1024:
{
foreach(ushort testSize in new ushort[]
{
// Long sector sizes for floppies
1026,
{
// Long sector sizes for floppies
1026,
// Long sector sizes for 1024-byte magneto-opticals
1200
})
// Long sector sizes for 1024-byte magneto-opticals
1200
})
{
sense = capabilities.SupportsReadLong16 == true
? _dev.ReadLong16(out buffer, out senseBuffer, false, 0, testSize, _dev.Timeout,
out _)
: _dev.ReadLong10(out buffer, out senseBuffer, false,
false, 0, testSize, _dev.Timeout, out _);
: _dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, testSize,
_dev.Timeout, out _);
if(sense || _dev.Error)
continue;

View File

@@ -56,8 +56,7 @@ public sealed partial class MediaScan
bool sense = _dev.AtaIdentify(out byte[] cmdBuf, out _);
if(!sense &&
Identify.Decode(cmdBuf).HasValue)
if(!sense && Identify.Decode(cmdBuf).HasValue)
{
// Initialize reader
var ataReader = new Reader(_dev, timeout, cmdBuf, null);
@@ -141,19 +140,15 @@ public sealed partial class MediaScan
if(results.Blocks - i < blocksToRead)
blocksToRead = (byte)(results.Blocks - i);
if(currentSpeed > results.MaxSpeed &&
currentSpeed > 0)
if(currentSpeed > results.MaxSpeed && currentSpeed > 0)
results.MaxSpeed = currentSpeed;
if(currentSpeed < results.MinSpeed &&
currentSpeed > 0)
if(currentSpeed < results.MinSpeed && currentSpeed > 0)
results.MinSpeed = currentSpeed;
UpdateProgress?.
Invoke(
string.Format(Localization.Core.Reading_sector_0_of_1_2, i, results.Blocks,
ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i, (long)results.Blocks);
Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, results.Blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i, (long)results.Blocks);
bool error = ataReader.ReadBlocks(out cmdBuf, i, blocksToRead, out duration, out _, out _);
@@ -241,12 +236,10 @@ public sealed partial class MediaScan
ataReader.Seek(seekPos, out seekCur);
if(seekCur > results.SeekMax &&
seekCur > 0)
if(seekCur > results.SeekMax && seekCur > 0)
results.SeekMax = seekCur;
if(seekCur < results.SeekMin &&
seekCur > 0)
if(seekCur < results.SeekMin && seekCur > 0)
results.SeekMin = seekCur;
results.SeekTotal += seekCur;
@@ -278,17 +271,16 @@ public sealed partial class MediaScan
if(_aborted)
break;
if(currentSpeed > results.MaxSpeed &&
currentSpeed > 0)
if(currentSpeed > results.MaxSpeed && currentSpeed > 0)
results.MaxSpeed = currentSpeed;
if(currentSpeed < results.MinSpeed &&
currentSpeed > 0)
if(currentSpeed < results.MinSpeed && currentSpeed > 0)
results.MinSpeed = currentSpeed;
PulseProgress?.Invoke(string.Format(Localization.Core.Reading_cylinder_0_head_1_sector_2_3,
cy, hd, sc,
ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).
ByteSize.FromMegabytes(currentSpeed).
Per(_oneSecond).
Humanize()));
bool error = ataReader.ReadChs(out cmdBuf, cy, hd, sc, out duration, out _);
@@ -380,12 +372,10 @@ public sealed partial class MediaScan
ataReader.SeekChs(seekCy, seekHd, seekSc, out seekCur);
if(seekCur > results.SeekMax &&
seekCur > 0)
if(seekCur > results.SeekMax && seekCur > 0)
results.SeekMax = seekCur;
if(seekCur < results.SeekMin &&
seekCur > 0)
if(seekCur < results.SeekMin && seekCur > 0)
results.SeekMin = seekCur;
results.SeekTotal += seekCur;

View File

@@ -188,8 +188,7 @@ public sealed partial class MediaScan
results.Blocks = scsiReader.GetDeviceBlocks();
foundReadCommand = !scsiReader.FindReadCommand();
if(!foundReadCommand &&
_dev.ScsiType != PeripheralDeviceTypes.MultiMediaDevice)
if(!foundReadCommand && _dev.ScsiType != PeripheralDeviceTypes.MultiMediaDevice)
{
StoppingErrorMessage?.Invoke(Localization.Core.Unable_to_read_medium);
@@ -198,8 +197,7 @@ public sealed partial class MediaScan
blockSize = scsiReader.LogicalBlockSize;
if(results.Blocks != 0 &&
blockSize != 0)
if(results.Blocks != 0 && blockSize != 0)
{
results.Blocks++;
@@ -323,8 +321,7 @@ public sealed partial class MediaScan
if(_dev.Error || sense)
blocksToRead /= 2;
if(!_dev.Error ||
blocksToRead == 1)
if(!_dev.Error || blocksToRead == 1)
break;
}
}
@@ -358,19 +355,15 @@ public sealed partial class MediaScan
if(results.Blocks - i < blocksToRead)
blocksToRead = (uint)(results.Blocks - i);
if(currentSpeed > results.MaxSpeed &&
currentSpeed > 0)
if(currentSpeed > results.MaxSpeed && currentSpeed > 0)
results.MaxSpeed = currentSpeed;
if(currentSpeed < results.MinSpeed &&
currentSpeed > 0)
if(currentSpeed < results.MinSpeed && currentSpeed > 0)
results.MinSpeed = currentSpeed;
UpdateProgress?.
Invoke(
string.Format(Localization.Core.Reading_sector_0_of_1_2, i, results.Blocks,
ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i, (long)results.Blocks);
Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, results.Blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i, (long)results.Blocks);
if(readcd)
{
@@ -522,25 +515,20 @@ public sealed partial class MediaScan
if(results.Blocks - i < blocksToRead)
blocksToRead = (uint)(results.Blocks - i);
if(currentSpeed > results.MaxSpeed &&
currentSpeed > 0)
if(currentSpeed > results.MaxSpeed && currentSpeed > 0)
results.MaxSpeed = currentSpeed;
if(currentSpeed < results.MinSpeed &&
currentSpeed > 0)
if(currentSpeed < results.MinSpeed && currentSpeed > 0)
results.MinSpeed = currentSpeed;
UpdateProgress?.
Invoke(
string.Format(Localization.Core.Reading_sector_0_of_1_2, i, results.Blocks,
ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i, (long)results.Blocks);
Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, results.Blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i, (long)results.Blocks);
sense = scsiReader.ReadBlocks(out _, i, blocksToRead, out double cmdDuration, out _, out _);
results.ProcessingTime += cmdDuration;
if(!sense &&
!_dev.Error)
if(!sense && !_dev.Error)
{
switch(cmdDuration)
{
@@ -642,12 +630,10 @@ public sealed partial class MediaScan
else
scsiReader.ReadBlock(out _, seekPos, out seekCur, out _, out _);
if(seekCur > results.SeekMax &&
seekCur > 0)
if(seekCur > results.SeekMax && seekCur > 0)
results.SeekMax = seekCur;
if(seekCur < results.SeekMin &&
seekCur > 0)
if(seekCur < results.SeekMin && seekCur > 0)
results.SeekMin = seekCur;
results.SeekTotal += seekCur;

View File

@@ -128,8 +128,9 @@ public sealed partial class MediaScan
if(!sense)
{
supportsCmd23 = Decoders.SecureDigital.Decoders.DecodeSCR(cmdBuf)?.CommandSupport.
HasFlag(CommandSupport.SetBlockCount) ?? false;
supportsCmd23 = Decoders.SecureDigital.Decoders.DecodeSCR(cmdBuf)?.
CommandSupport.HasFlag(CommandSupport.SetBlockCount) ??
false;
}
}
@@ -177,8 +178,7 @@ public sealed partial class MediaScan
if(sense)
blocksToRead /= 2;
if(!sense ||
blocksToRead == 1)
if(!sense || blocksToRead == 1)
break;
}
@@ -241,19 +241,15 @@ public sealed partial class MediaScan
if(results.Blocks - i < blocksToRead)
blocksToRead = (byte)(results.Blocks - i);
if(currentSpeed > results.MaxSpeed &&
currentSpeed > 0)
if(currentSpeed > results.MaxSpeed && currentSpeed > 0)
results.MaxSpeed = currentSpeed;
if(currentSpeed < results.MinSpeed &&
currentSpeed > 0)
if(currentSpeed < results.MinSpeed && currentSpeed > 0)
results.MinSpeed = currentSpeed;
UpdateProgress?.
Invoke(
string.Format(Localization.Core.Reading_sector_0_of_1_2, i, results.Blocks,
ByteSize.FromBytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i, (long)results.Blocks);
Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, results.Blocks, ByteSize.FromBytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i, (long)results.Blocks);
bool error;
@@ -356,12 +352,10 @@ public sealed partial class MediaScan
_dev.ReadSingleBlock(out cmdBuf, out _, seekPos, blockSize, byteAddressed, timeout, out double seekCur);
if(seekCur > results.SeekMax &&
seekCur > 0)
if(seekCur > results.SeekMax && seekCur > 0)
results.SeekMax = seekCur;
if(seekCur < results.SeekMin &&
seekCur > 0)
if(seekCur < results.SeekMin && seekCur > 0)
results.SeekMin = seekCur;
results.SeekTotal += seekCur;