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

@@ -83,7 +83,7 @@ resharper_braces_for_ifelse
resharper_braces_for_while = required_for_multiline
resharper_builtin_type_apply_to_native_integer = false
resharper_constructor_or_destructor_body = expression_body
resharper_csharp_align_first_arg_by_paren = false
resharper_csharp_align_first_arg_by_paren = true
resharper_csharp_empty_block_style = together_same_line
resharper_csharp_place_comments_at_first_column = true
resharper_csharp_prefer_qualified_reference = false
@@ -108,6 +108,7 @@ resharper_int_align_enum_initializers
resharper_int_align_eq = true
resharper_keep_existing_embedded_arrangement = false
resharper_keep_existing_initializer_arrangement = false
resharper_keep_existing_linebreaks = false
resharper_keep_existing_list_patterns_arrangement = false
resharper_keep_existing_property_patterns_arrangement = false
resharper_keep_existing_switch_expression_arrangement = false
@@ -125,6 +126,7 @@ resharper_outdent_statement_labels
resharper_parentheses_redundancy_style = remove
resharper_place_attribute_on_same_line = false
resharper_place_simple_embedded_statement_on_same_line = false
resharper_place_simple_initializer_on_single_line = false
resharper_qualified_using_at_nested_scope = true
resharper_show_autodetect_configure_formatting_tip = false
resharper_simple_block_style = on_single_line
@@ -146,6 +148,8 @@ resharper_use_indent_from_vs
resharper_wrap_after_dot_in_method_calls = true
resharper_wrap_base_clause_style = chop_if_long
resharper_wrap_braced_init_list_style = chop_if_long
resharper_wrap_chained_binary_expressions = chop_if_long
resharper_wrap_chained_method_calls = chop_if_long
resharper_wrap_ctor_initializer_style = chop_if_long
resharper_wrap_lines = true
resharper_xmldoc_attribute_indent = align_by_first_attribute

View File

@@ -57,11 +57,7 @@ public static class ADC
static extern int AARU_adc_decode_buffer(byte[] dstBuffer, int dstSize, byte[] srcBuffer, int srcSize);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static int GetChunkType(byte byt) => (byt & 0x80) == 0x80
? PLAIN
: (byt & 0x40) == 0x40
? THREE_BYTE
: TWO_BYTE;
static int GetChunkType(byte byt) => (byt & 0x80) == 0x80 ? PLAIN : (byt & 0x40) == 0x40 ? THREE_BYTE : TWO_BYTE;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static int GetChunkSize(byte byt) => GetChunkType(byt) switch

View File

@@ -61,8 +61,7 @@ public static class AppleRle
var repeatMode = false; // true if we're repeating, false if we're just copying
int inPosition = 0, outPosition = 0;
while(inPosition <= source.Length &&
outPosition <= destination.Length)
while(inPosition <= source.Length && outPosition <= destination.Length)
{
switch(repeatMode)
{
@@ -102,9 +101,7 @@ public static class AppleRle
byte b2 = source[inPosition++];
var s = (short)(b1 << 8 | b2);
if(s == 0 ||
s >= DART_CHUNK ||
s <= -DART_CHUNK)
if(s == 0 || s >= DART_CHUNK || s <= -DART_CHUNK)
continue;
if(s < 0)

View File

@@ -59,7 +59,7 @@ public class LZIP
/// <returns>The size of the compressed data</returns>
public static int EncodeBuffer(byte[] source, byte[] destination, int dictionarySize, int matchLengthLimit) =>
Native.IsSupported
? AARU_lzip_encode_buffer(destination, destination.Length, source, source.Length,
dictionarySize, matchLengthLimit)
? AARU_lzip_encode_buffer(destination, destination.Length, source, source.Length, dictionarySize,
matchLengthLimit)
: 0;
}

View File

@@ -202,8 +202,7 @@ public class TeleDiskLzh
else
{
// still chars from last string
while(_tdctl.Bufndx < _tdctl.Bufcnt &&
count < len)
while(_tdctl.Bufndx < _tdctl.Bufcnt && count < len)
{
c = _textBuf[_tdctl.Bufpos + _tdctl.Bufndx & N - 1];
buf[count] = (byte)c;

View File

@@ -116,8 +116,7 @@ public sealed class DataFile
/// <param name="whatWriting">What is the data about?</param>
public static void WriteTo(string who, string outputPrefix, string outputSuffix, string whatWriting, byte[] data)
{
if(!string.IsNullOrEmpty(outputPrefix) &&
!string.IsNullOrEmpty(outputSuffix))
if(!string.IsNullOrEmpty(outputPrefix) && !string.IsNullOrEmpty(outputSuffix))
WriteTo(who, outputPrefix + outputSuffix, data, whatWriting);
}

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;

View File

@@ -104,10 +104,8 @@ public sealed class Entropy
};
UpdateProgressEvent?.
Invoke(
string.Format(Localization.Core.Entropying_track_0_of_1, currentTrack.Sequence,
inputTracks.Max(t => t.Sequence)),
currentTrack.Sequence, inputTracks.Max(t => t.Sequence));
Invoke(string.Format(Localization.Core.Entropying_track_0_of_1, currentTrack.Sequence, inputTracks.Max(t => t.Sequence)),
currentTrack.Sequence, inputTracks.Max(t => t.Sequence));
var entTable = new ulong[256];
ulong trackSize = 0;
@@ -123,10 +121,8 @@ public sealed class Entropy
for(ulong i = 0; i < trackEntropy.Sectors; i++)
{
UpdateProgress2Event?.
Invoke(
string.Format(Localization.Core.Entropying_sector_0_of_track_1, i + 1,
currentTrack.Sequence),
(long)(i + 1), (long)currentTrack.EndSector);
Invoke(string.Format(Localization.Core.Entropying_sector_0_of_track_1, i + 1, currentTrack.Sequence),
(long)(i + 1), (long)currentTrack.EndSector);
ErrorNumber errno = opticalMediaImage.ReadSector(i, currentTrack.Sequence, out byte[] sector);
@@ -156,7 +152,8 @@ public sealed class Entropy
EndProgress2Event?.Invoke();
trackEntropy.Entropy += entTable.Select(l => l / (double)trackSize).
Select(frequency => -(frequency * Math.Log(frequency, 2))).Sum();
Select(frequency => -(frequency * Math.Log(frequency, 2))).
Sum();
if(duplicatedSectors)
trackEntropy.UniqueSectors = uniqueSectorsPerTrack.Count;
@@ -233,7 +230,8 @@ public sealed class Entropy
EndProgressEvent?.Invoke();
entropy.Entropy += entTable.Select(l => l / (double)diskSize).
Select(frequency => -(frequency * Math.Log(frequency, 2))).Sum();
Select(frequency => -(frequency * Math.Log(frequency, 2))).
Sum();
if(duplicatedSectors)
entropy.UniqueSectors = uniqueSectors.Count;
@@ -283,7 +281,8 @@ public sealed class Entropy
EndProgressEvent?.Invoke();
entropy.Entropy += entTable.Select(l => l / (double)data.Length).
Select(frequency => -(frequency * Math.Log(frequency, 2))).Sum();
Select(frequency => -(frequency * Math.Log(frequency, 2))).
Sum();
return entropy;
}

View File

@@ -61,8 +61,7 @@ public class BlockMap : IMediaGraph
_sectorsPerSquare = (int)((long)maxSectors / squares);
while(_sectorsPerSquare > 0 &&
_squareSize > 4)
while(_sectorsPerSquare > 0 && _squareSize > 4)
{
_squareSize--;
@@ -266,8 +265,8 @@ public class BlockMap : IMediaGraph
{
foreach(SKRect rect in sectors.Select(sector => GetSquareRectangle(_sectorsPerSquare == 0
? (int)sector
: (int)
(sector / (ulong)_sectorsPerSquare))))
: (int)(sector /
(ulong)_sectorsPerSquare))))
{
_canvas.DrawRect(rect, new SKPaint
{

View File

@@ -103,8 +103,7 @@ public sealed class Spiral : IMediaGraph
/// <param name="lastSector">Last sector that will be drawn into the spiral</param>
public Spiral(int width, int height, DiscParameters parameters, ulong lastSector)
{
if(parameters == _gdParameters ||
parameters == _gdRecordableParameters)
if(parameters == _gdParameters || parameters == _gdRecordableParameters)
_gdrom = true;
// GD-ROM LD area ends at 29mm, HD area starts at 30mm radius
@@ -197,8 +196,7 @@ public sealed class Spiral : IMediaGraph
});
// If there's a recordable information area, get its points
if(recordableAreaEndDiameter > 0 &&
recordableAreaStartDiameter > 0)
if(recordableAreaEndDiameter > 0 && recordableAreaStartDiameter > 0)
{
_recordableInformationPoints = GetSpiralPoints(center, recordableAreaStartDiameter / 2,
recordableAreaEndDiameter / 2, _gdrom ? a : a * 1.5f);

View File

@@ -124,8 +124,7 @@ public static class ImageInfo
if(!string.IsNullOrWhiteSpace(imageFormat.Info.Comments))
AaruConsole.WriteLine(Localization.Core.Comments_0_WithMarkup, Markup.Escape(imageFormat.Info.Comments));
if(imageFormat.Info.MediaSequence != 0 &&
imageFormat.Info.LastMediaSequence != 0)
if(imageFormat.Info.MediaSequence != 0 && imageFormat.Info.LastMediaSequence != 0)
{
AaruConsole.WriteLine(Localization.Core.Media_is_number_0_on_a_set_of_1_medias,
imageFormat.Info.MediaSequence, imageFormat.Info.LastMediaSequence);
@@ -419,8 +418,7 @@ public static class ImageInfo
{
errno = imageFormat.ReadMediaTag(MediaTagType.CD_FullTOC, out byte[] toc);
if(errno == ErrorNumber.NoError &&
toc.Length > 0)
if(errno == ErrorNumber.NoError && toc.Length > 0)
{
ushort dataLen = Swapping.Swap(BitConverter.ToUInt16(toc, 0));
@@ -443,8 +441,7 @@ public static class ImageInfo
{
errno = imageFormat.ReadMediaTag(MediaTagType.CD_PMA, out byte[] pma);
if(errno == ErrorNumber.NoError &&
pma.Length > 0)
if(errno == ErrorNumber.NoError && pma.Length > 0)
{
ushort dataLen = Swapping.Swap(BitConverter.ToUInt16(pma, 0));
@@ -678,8 +675,7 @@ public static class ImageInfo
break;
default:
AaruConsole.DebugWriteLine(MODULE_NAME,
Localization.Core.Found_unknown_tuple_ID_0,
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Found_unknown_tuple_ID_0,
(byte)tuple.Code);
break;

View File

@@ -430,9 +430,7 @@ public sealed class ErrorLog
_logSw.WriteLine(Localization.Core.SCSI_reading_LBA_0_operating_system_error_1, block, errno);
_logSw.Flush();
if(senseBuffer is null ||
senseBuffer.Length == 0 ||
senseBuffer.All(s => s == 0))
if(senseBuffer is null || senseBuffer.Length == 0 || senseBuffer.All(s => s == 0))
return;
}
@@ -517,22 +515,16 @@ public sealed class ErrorLog
{
if(osError)
{
_logSw.WriteLine(
byteAddressed
? Localization.Core.SD_MMC_reading_LBA_0_byte_addressed_operating_system_error_1
: Localization.Core.SD_MMC_reading_LBA_0_block_addressed_operating_system_error_1,
block, errno);
_logSw.WriteLine(byteAddressed ? Localization.Core.SD_MMC_reading_LBA_0_byte_addressed_operating_system_error_1 : Localization.Core.SD_MMC_reading_LBA_0_block_addressed_operating_system_error_1,
block, errno);
_logSw.Flush();
return;
}
_logSw.WriteLine(
byteAddressed
? Localization.Core.SD_MMC_reading_LBA_0_byte_addressed_error_1
: Localization.Core.SD_MMC_reading_LBA_0_block_addressed_error_1,
block, string.Join(" - ", response.Select(r => $"0x{r:X8}")));
_logSw.WriteLine(byteAddressed ? Localization.Core.SD_MMC_reading_LBA_0_byte_addressed_error_1 : Localization.Core.SD_MMC_reading_LBA_0_block_addressed_error_1,
block, string.Join(" - ", response.Select(r => $"0x{r:X8}")));
throw new NotImplementedException();
}

View File

@@ -249,8 +249,7 @@ sealed class IbgLog
if(_ibgSampleRate < 100)
return;
if(_ibgIntSpeed > 0 &&
!_ibgStartSet)
if(_ibgIntSpeed > 0 && !_ibgStartSet)
{
_ibgStartSpeed = _ibgIntSpeed / _ibgSnaps / _ibgDivider;
_ibgStartSet = true;

View File

@@ -59,8 +59,7 @@ sealed class MhddLog
internal MhddLog(string outputFile, Device dev, ulong blocks, ulong blockSize, ulong blocksToRead, bool @private,
uint mediaGraphDimensions = 0)
{
if(dev == null ||
string.IsNullOrEmpty(outputFile))
if(dev == null || string.IsNullOrEmpty(outputFile))
return;
if(mediaGraphDimensions > 0)
@@ -117,10 +116,16 @@ sealed class MhddLog
byte[] scanBlockSizeBytes = Encoding.ASCII.GetBytes(scanBlockSize);
byte[] verBytes = Encoding.ASCII.GetBytes(MHDD_VER);
var pointer = (uint)(deviceBytes.Length + modeBytes.Length + fwBytes.Length + snBytes.Length +
sectorsBytes.Length + sectorSizeBytes.Length + scanBlockSizeBytes.Length +
verBytes.Length + 2 * 9 + // New lines
4); // Pointer
var pointer = (uint)(deviceBytes.Length +
modeBytes.Length +
fwBytes.Length +
snBytes.Length +
sectorsBytes.Length +
sectorSizeBytes.Length +
scanBlockSizeBytes.Length +
verBytes.Length +
2 * 9 + // New lines
4); // Pointer
var newLine = new byte[2];
newLine[0] = 0x0D;

View File

@@ -188,8 +188,7 @@ public class SubchannelLog
for(var i = 0; i < 12; i++)
{
if(p[i] == 0 ||
p[i] == 0xFF)
if(p[i] == 0 || p[i] == 0xFF)
continue;
corruptedPause = true;

View File

@@ -80,8 +80,7 @@ public static class CompactDisc
sub = Subchannel.ConvertQToRaw(sub);
// If not desired to fix, or to save, the subchannel, just save as is (or none)
if(!fixSubchannelPosition &&
desiredSubchannel != MmcSubchannel.None)
if(!fixSubchannelPosition && desiredSubchannel != MmcSubchannel.None)
outputPlugin.WriteSectorsTag(sub, sectorAddress, length, SectorTagType.CdSectorSubchannel);
subLog?.WriteEntry(sub, supportedSubchannel == MmcSubchannel.Raw, (long)sectorAddress, length, false, false);
@@ -92,8 +91,7 @@ public static class CompactDisc
updateStatus, smallestPregapLbaPerTrack, dumping,
out newPregapSectors, sectorAddress);
if(!fixSubchannelPosition ||
desiredSubchannel == MmcSubchannel.None)
if(!fixSubchannelPosition || desiredSubchannel == MmcSubchannel.None)
return indexesChanged;
int prePos = int.MinValue;
@@ -121,8 +119,7 @@ public static class CompactDisc
// Check P and weight
for(int p = subPos; p < subPos + 12; p++)
{
if(deSub[p] != 0 &&
deSub[p] != 255)
if(deSub[p] != 0 && deSub[p] != 255)
pOk = false;
for(var w = 0; w < 8; w++)
@@ -192,10 +189,7 @@ public static class CompactDisc
}
// RW is not a known pattern or packet, fix it
if(!rwOk &&
!rwPacket &&
!cdtextPacket &&
fixSubchannel)
if(!rwOk && !rwPacket && !cdtextPacket && fixSubchannel)
{
for(int rw = subPos + 24; rw < subPos + 96; rw++)
deSub[rw] = 0;
@@ -209,10 +203,7 @@ public static class CompactDisc
int aPos;
// Fix Q
if(!crcOk &&
fixSubchannel &&
subPos > 0 &&
subPos < deSub.Length - 96)
if(!crcOk && fixSubchannel && subPos > 0 && subPos < deSub.Length - 96)
{
isrcs.TryGetValue(currentTrack, out string knownGoodIsrc);
@@ -258,9 +249,7 @@ public static class CompactDisc
}
}
if(!pOk ||
!crcOk ||
!rwOk)
if(!pOk || !crcOk || !rwOk)
continue;
var aframe = (byte)(q[9] / 16 * 10 + (q[9] & 0x0F));
@@ -417,8 +406,7 @@ public static class CompactDisc
continue;
// Pregap
if(q[2] == 0 &&
trackNo > 1)
if(q[2] == 0 && trackNo > 1)
{
var pmin = (byte)(q[3] / 16 * 10 + (q[3] & 0x0F));
var psec = (byte)(q[4] / 16 * 10 + (q[4] & 0x0F));
@@ -443,9 +431,8 @@ public static class CompactDisc
tracks[i].StartSector -= (ulong)dif;
smallestPregapLbaPerTrack[trackNo] = qPos;
if(i > 0 &&
tracks[i - 1].EndSector >= tracks[i].StartSector)
tracks[i - 1].EndSector = tracks[i].StartSector - 1;
if(i > 0 && tracks[i - 1].EndSector >= tracks[i].StartSector)
tracks[i - 1].EndSector = tracks[i].StartSector - 1;
dumpLog?.WriteLine(string.Format(Localization.Core.Pregap_for_track_0_set_to_1_sectors,
trackNo, tracks[i].Pregap));
@@ -468,9 +455,8 @@ public static class CompactDisc
tracks[i].Pregap = (ulong)qPos;
tracks[i].StartSector -= tracks[i].Pregap - oldPregap;
if(i > 0 &&
tracks[i - 1].EndSector >= tracks[i].StartSector)
tracks[i - 1].EndSector = tracks[i].StartSector - 1;
if(i > 0 && tracks[i - 1].EndSector >= tracks[i].StartSector)
tracks[i - 1].EndSector = tracks[i].StartSector - 1;
dumpLog?.WriteLine(string.Format(Localization.Core.Pregap_for_track_0_set_to_1_sectors,
trackNo, tracks[i].Pregap));
@@ -495,12 +481,10 @@ public static class CompactDisc
int aPos = amin * 60 * 75 + asec * 75 + aframe - 150;
// Do not set INDEX 1 to a value higher than what the TOC already said.
if(q[2] == 1 &&
aPos > (int)tracks[i].StartSector)
if(q[2] == 1 && aPos > (int)tracks[i].StartSector)
continue;
if(tracks[i].Indexes.ContainsKey(q[2]) &&
aPos >= tracks[i].Indexes[q[2]])
if(tracks[i].Indexes.ContainsKey(q[2]) && aPos >= tracks[i].Indexes[q[2]])
continue;
dumpLog?.WriteLine(string.Format(Localization.Core.Setting_index_0_for_track_1_to_LBA_2, q[2],
@@ -824,8 +808,7 @@ public static class CompactDisc
Array.Copy(cdTextPack1, 0, cdTextPack1ForCrc, 0, 16);
ushort calculatedCdtp1Crc = CRC16CCITTContext.Calculate(cdTextPack1ForCrc);
if(cdTextPack1Crc != calculatedCdtp1Crc &&
cdTextPack1Crc != 0)
if(cdTextPack1Crc != calculatedCdtp1Crc && cdTextPack1Crc != 0)
status = false;
}
@@ -836,8 +819,7 @@ public static class CompactDisc
Array.Copy(cdTextPack2, 0, cdTextPack2ForCrc, 0, 16);
ushort calculatedCdtp2Crc = CRC16CCITTContext.Calculate(cdTextPack2ForCrc);
if(cdTextPack2Crc != calculatedCdtp2Crc &&
cdTextPack2Crc != 0)
if(cdTextPack2Crc != calculatedCdtp2Crc && cdTextPack2Crc != 0)
status = false;
}
@@ -848,8 +830,7 @@ public static class CompactDisc
Array.Copy(cdTextPack3, 0, cdTextPack3ForCrc, 0, 16);
ushort calculatedCdtp3Crc = CRC16CCITTContext.Calculate(cdTextPack3ForCrc);
if(cdTextPack3Crc != calculatedCdtp3Crc &&
cdTextPack3Crc != 0)
if(cdTextPack3Crc != calculatedCdtp3Crc && cdTextPack3Crc != 0)
status = false;
}
@@ -861,8 +842,7 @@ public static class CompactDisc
Array.Copy(cdTextPack4, 0, cdTextPack4ForCrc, 0, 16);
ushort calculatedCdtp4Crc = CRC16CCITTContext.Calculate(cdTextPack4ForCrc);
if(cdTextPack4Crc == calculatedCdtp4Crc ||
cdTextPack4Crc == 0)
if(cdTextPack4Crc == calculatedCdtp4Crc || cdTextPack4Crc == 0)
return status;
return false;
@@ -1007,10 +987,7 @@ public static class CompactDisc
q[0] = (byte)oldAdr;
}
if(preCrcOk &&
nextCrcOk &&
(nextQ[0] & 0xF0) == (preQ[0] & 0xF0) &&
(q[0] & 0xF0) != (nextQ[0] & 0xF0))
if(preCrcOk && nextCrcOk && (nextQ[0] & 0xF0) == (preQ[0] & 0xF0) && (q[0] & 0xF0) != (nextQ[0] & 0xF0))
{
q[0] = (byte)((q[0] & 0x03) + (nextQ[0] & 0xF0));
@@ -1037,8 +1014,7 @@ public static class CompactDisc
if(preCrcOk && nextCrcOk)
{
if(preQ[1] == nextQ[1] &&
preQ[1] != q[1])
if(preQ[1] == nextQ[1] && preQ[1] != q[1])
{
q[1] = preQ[1];
fixedTno = true;
@@ -1053,8 +1029,7 @@ public static class CompactDisc
if(preCrcOk && nextCrcOk)
{
if(preQ[2] == nextQ[2] &&
preQ[2] != q[2])
if(preQ[2] == nextQ[2] && preQ[2] != q[2])
{
q[2] = preQ[2];
fixedIndex = true;
@@ -1145,9 +1120,7 @@ public static class CompactDisc
}
// Next is not pregap and we didn't fix relative position with previous
if(nextQ[2] > 0 &&
nextCrcOk &&
!fixedRelPos)
if(nextQ[2] > 0 && nextCrcOk && !fixedRelPos)
{
rmin = (byte)(nextQ[3] / 16 * 10 + (nextQ[3] & 0x0F));
rsec = (byte)(nextQ[4] / 16 * 10 + (nextQ[4] & 0x0F));
@@ -1262,9 +1235,7 @@ public static class CompactDisc
}
// Next is not pregap and we didn't fix relative position with previous
if(nextQ[2] > 0 &&
nextCrcOk &&
!fixedAbsPos)
if(nextQ[2] > 0 && nextCrcOk && !fixedAbsPos)
{
rmin = (byte)(nextQ[7] / 16 * 10 + (nextQ[7] & 0x0F));
rsec = (byte)(nextQ[8] / 16 * 10 + (nextQ[8] & 0x0F));
@@ -1350,12 +1321,7 @@ public static class CompactDisc
bool relOk = dPos == 1;
if(q[0] != preQ[0] ||
q[1] != preQ[1] ||
q[2] != preQ[2] ||
q[6] != 0 ||
!absOk ||
!relOk)
if(q[0] != preQ[0] || q[1] != preQ[1] || q[2] != preQ[2] || q[6] != 0 || !absOk || !relOk)
return false;
CRC16CCITTContext.Data(q, 10, out qCrc);
@@ -1388,12 +1354,7 @@ public static class CompactDisc
bool relOk = dPos == 1;
if(q[0] != nextQ[0] ||
q[1] != nextQ[1] ||
q[2] != nextQ[2] ||
q[6] != 0 ||
!absOk ||
!relOk)
if(q[0] != nextQ[0] || q[1] != nextQ[1] || q[2] != nextQ[2] || q[6] != 0 || !absOk || !relOk)
return false;
CRC16CCITTContext.Data(q, 10, out qCrc);
@@ -1488,9 +1449,7 @@ public static class CompactDisc
return true;
}
if(!fixCrc ||
!nextCrcOk ||
!preCrcOk)
if(!fixCrc || !nextCrcOk || !preCrcOk)
return false;
CRC16CCITTContext.Data(q, 10, out qCrc);
@@ -1587,9 +1546,7 @@ public static class CompactDisc
return true;
}
if(!fixCrc ||
!nextCrcOk ||
!preCrcOk)
if(!fixCrc || !nextCrcOk || !preCrcOk)
return false;
CRC16CCITTContext.Data(q, 10, out qCrc);

View File

@@ -80,10 +80,16 @@ public static class MMC
0x50, 0x6C, 0x61, 0x79, 0x53, 0x74, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x35, 0x00, 0x00, 0x00, 0x00
};
static readonly byte[] _operaId = { 0x01, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x01 };
static readonly byte[] _operaId =
{
0x01, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x01
};
// Only present on bootable CDs, but those make more than 99% of all available
static readonly byte[] _fmTownsBootId = { 0x49, 0x50, 0x4C, 0x34, 0xEB, 0x55, 0x06 };
static readonly byte[] _fmTownsBootId =
{
0x49, 0x50, 0x4C, 0x34, 0xEB, 0x55, 0x06
};
/// <summary>Present on first two seconds of second track, says "COPYRIGHT BANDAI"</summary>
static readonly byte[] _playdiaCopyright = "COPYRIGHT BANDAI"u8.ToArray();
@@ -125,7 +131,10 @@ public static class MMC
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);
@@ -140,7 +149,10 @@ public static class MMC
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];
@@ -196,12 +208,14 @@ public static class MMC
if(sector16?.Length != 2352)
return false;
byte[] cdiMark = { 0x01, 0x43, 0x44, 0x2D };
byte[] cdiMark =
{
0x01, 0x43, 0x44, 0x2D
};
bool isData = IsData(sector0);
if(!isData ||
sector0[0xF] != 2 && sector0[0xF] != 1)
if(!isData || sector0[0xF] != 2 && sector0[0xF] != 1)
return false;
var testMark = new byte[4];
@@ -212,8 +226,7 @@ public static class MMC
static bool IsVideoNowColor(byte[] videoFrame)
{
if(videoFrame is null ||
videoFrame.Length < _videoNowColorFrameMarker.Length)
if(videoFrame is null || videoFrame.Length < _videoNowColorFrameMarker.Length)
return false;
var buffer = new byte[_videoNowColorFrameMarker.Length];
@@ -447,8 +460,7 @@ public static class MMC
break;
case 0x20:
AaruConsole.DebugWriteLine(MODULE_NAME,
Localization.Core.TOC_says_disc_type_is_CD_ROM_XA);
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.TOC_says_disc_type_is_CD_ROM_XA);
mediaType = MediaType.CDROMXA;
@@ -457,7 +469,7 @@ public static class MMC
}
foreach(FullTOC.TrackDataDescriptor track in
decodedToc.Value.TrackDescriptors.Where(t => t.POINT is > 0 and <= 0x99))
decodedToc.Value.TrackDescriptors.Where(t => t.POINT is > 0 and <= 0x99))
{
if(track.TNO == 1 &&
((TocControl)(track.CONTROL & 0x0D) == TocControl.DataTrack ||
@@ -467,8 +479,11 @@ public static class MMC
if((TocControl)(track.CONTROL & 0x0D) == TocControl.DataTrack ||
(TocControl)(track.CONTROL & 0x0D) == TocControl.DataTrackIncremental)
{
var startAddress = (uint)(track.PHOUR * 3600 * 75 + track.PMIN * 60 * 75 +
track.PSEC * 75 + track.PFRAME - 150);
var startAddress = (uint)(track.PHOUR * 3600 * 75 +
track.PMIN * 60 * 75 +
track.PSEC * 75 +
track.PFRAME -
150);
if(startAddress < startOfFirstDataTrack)
startOfFirstDataTrack = startAddress;
@@ -504,19 +519,14 @@ public static class MMC
break;
}
if(hasDataTrack &&
!hasAudioTrack &&
sessions == 1)
if(hasDataTrack && !hasAudioTrack && sessions == 1)
{
AaruConsole.DebugWriteLine(MODULE_NAME,
Localization.Core.Disc_has_only_data_in_a_session_CD_ROM);
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Disc_has_only_data_in_a_session_CD_ROM);
mediaType = MediaType.CDROM;
}
if(hasVideoTrack &&
!hasDataTrack &&
sessions == 1)
if(hasVideoTrack && !hasDataTrack && sessions == 1)
{
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Disc_has_video_tracks_CD_Video);
@@ -534,7 +544,9 @@ public static class MMC
TocControl.DataTrackIncremental)).
Select(track => (uint)(track.PHOUR * 3600 * 75 +
track.PMIN * 60 * 75 +
track.PSEC * 75 + track.PFRAME - 150) +
track.PSEC * 75 +
track.PFRAME -
150) +
16))
{
sense = dev.ReadCd(out cmdBuf, out _, startAddress, 2352, 1, MmcSectorTypes.AllTypes, false, false,
@@ -559,8 +571,7 @@ public static class MMC
cmdBuf[15] != 0x02)
continue;
AaruConsole.DebugWriteLine(MODULE_NAME,
Localization.Core.Disc_has_a_mode_two_data_track_CD_ROM_XA);
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Disc_has_a_mode_two_data_track_CD_ROM_XA);
mediaType = MediaType.CDROMXA;
@@ -578,14 +589,14 @@ public static class MMC
var firstSectorSecondSessionFirstTrack = (uint)(secondSessionFirstTrackTrack.PHOUR * 3600 * 75 +
secondSessionFirstTrackTrack.PMIN * 60 * 75 +
secondSessionFirstTrackTrack.PSEC * 75 +
secondSessionFirstTrackTrack.PFRAME - 150);
secondSessionFirstTrackTrack.PFRAME -
150);
sense = dev.ReadCd(out cmdBuf, out _, firstSectorSecondSessionFirstTrack, 2352, 1, MmcSectorTypes.AllTypes,
false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
MmcSubchannel.None, dev.Timeout, out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
firstTrackSecondSession = cmdBuf;
else
{
@@ -593,8 +604,7 @@ public static class MMC
false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
MmcSubchannel.None, dev.Timeout, out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
firstTrackSecondSession = cmdBuf;
}
@@ -602,8 +612,7 @@ public static class MMC
MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, true,
MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
firstTrackSecondSessionAudio = cmdBuf;
else
{
@@ -611,8 +620,7 @@ public static class MMC
MmcSectorTypes.Cdda, false, false, false, MmcHeaderCodes.None, true, false,
MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
firstTrackSecondSessionAudio = cmdBuf;
}
}
@@ -648,8 +656,11 @@ public static class MMC
if(firstTrack?.POINT is >= 1 and < 0xA0)
{
var firstTrackSector = (uint)(firstTrack.Value.PHOUR * 3600 * 75 + firstTrack.Value.PMIN * 60 * 75 +
firstTrack.Value.PSEC * 75 + firstTrack.Value.PFRAME - 150);
var firstTrackSector = (uint)(firstTrack.Value.PHOUR * 3600 * 75 +
firstTrack.Value.PMIN * 60 * 75 +
firstTrack.Value.PSEC * 75 +
firstTrack.Value.PFRAME -
150);
// Check for hidden data before start of track 1
if(firstTrackSector > 0)
@@ -658,8 +669,7 @@ public static class MMC
MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None,
dev.Timeout, out _);
if(!dev.Error &&
!sense)
if(!dev.Error && !sense)
{
hiddenTrack = true;
@@ -671,8 +681,7 @@ public static class MMC
false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
MmcSubchannel.None, dev.Timeout, out _);
if(!sense &&
IsCdi(sector0, sector16))
if(!sense && IsCdi(sector0, sector16))
{
mediaType = MediaType.CDIREADY;
@@ -756,8 +765,7 @@ public static class MMC
MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None,
dev.Timeout, out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
{
sector0 = new byte[2048];
Array.Copy(cmdBuf, 16, sector0, 0, 2048);
@@ -766,8 +774,7 @@ public static class MMC
MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None,
dev.Timeout, out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
{
sector1 = new byte[2048];
Array.Copy(cmdBuf, 16, sector1, 0, 2048);
@@ -777,8 +784,7 @@ public static class MMC
MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None,
dev.Timeout, out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
{
playdia1 = new byte[2048];
Array.Copy(cmdBuf, 24, playdia1, 0, 2048);
@@ -788,8 +794,7 @@ public static class MMC
MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None,
dev.Timeout, out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
{
playdia2 = new byte[2048];
Array.Copy(cmdBuf, 24, playdia2, 0, 2048);
@@ -801,8 +806,7 @@ public static class MMC
false, false, true, MmcHeaderCodes.AllHeaders, true, true,
MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
{
firstDataSectorNotZero = new byte[2048];
Array.Copy(cmdBuf, 16, firstDataSectorNotZero, 0, 2048);
@@ -812,8 +816,7 @@ public static class MMC
MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true,
true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
{
secondDataSectorNotZero = new byte[2048];
Array.Copy(cmdBuf, 16, secondDataSectorNotZero, 0, 2048);
@@ -843,8 +846,7 @@ public static class MMC
MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.None,
dev.Timeout, out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
{
sector0 = new byte[2048];
Array.Copy(cmdBuf, 0, sector0, 0, 2048);
@@ -853,8 +855,7 @@ public static class MMC
MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.None,
dev.Timeout, out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
{
sector1 = new byte[2048];
Array.Copy(cmdBuf, 1, sector0, 0, 2048);
@@ -864,8 +865,7 @@ public static class MMC
MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.None,
dev.Timeout, out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
{
playdia1 = new byte[2048];
Array.Copy(cmdBuf, 0, playdia1, 0, 2048);
@@ -875,8 +875,7 @@ public static class MMC
MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.None,
dev.Timeout, out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
{
playdia2 = new byte[2048];
Array.Copy(cmdBuf, 0, playdia2, 0, 2048);
@@ -888,8 +887,7 @@ public static class MMC
false, false, false, MmcHeaderCodes.None, true, false,
MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
{
firstDataSectorNotZero = new byte[2048];
Array.Copy(cmdBuf, 0, firstDataSectorNotZero, 0, 2048);
@@ -899,8 +897,7 @@ public static class MMC
MmcSectorTypes.Mode2, false, false, false, MmcHeaderCodes.None, true,
false, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
{
secondDataSectorNotZero = new byte[2048];
Array.Copy(cmdBuf, 0, secondDataSectorNotZero, 0, 2048);
@@ -930,8 +927,7 @@ public static class MMC
MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.None,
dev.Timeout, out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
{
sector0 = cmdBuf;
@@ -939,16 +935,14 @@ public static class MMC
MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.None,
dev.Timeout, out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
sector1 = cmdBuf;
sense = dev.ReadCd(out cmdBuf, out _, 0, 2048, 12, MmcSectorTypes.Mode1, false, false,
false, MmcHeaderCodes.None, true, false, MmcErrorField.None,
MmcSubchannel.None, dev.Timeout, out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
ps2BootSectors = cmdBuf;
if(startOfFirstDataTrack != uint.MaxValue)
@@ -957,16 +951,14 @@ public static class MMC
MmcSectorTypes.Mode1, false, false, false, MmcHeaderCodes.None, true,
false, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
firstDataSectorNotZero = cmdBuf;
sense = dev.ReadCd(out cmdBuf, out _, startOfFirstDataTrack + 1, 2048, 1,
MmcSectorTypes.Mode1, false, false, false, MmcHeaderCodes.None, true,
false, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
secondDataSectorNotZero = cmdBuf;
}
}
@@ -997,24 +989,20 @@ public static class MMC
sense = dev.Read16(out cmdBuf, out _, 0, false, false, false, 0, 2048, 0, 1, false, dev.Timeout, out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
{
sector0 = cmdBuf;
sense = dev.Read16(out cmdBuf, out _, 0, false, false, false, 1, 2048, 0, 1, false, dev.Timeout,
out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
sector1 = cmdBuf;
sense = dev.Read16(out cmdBuf, out _, 0, false, false, false, 0, 2048, 0, 12, false, dev.Timeout,
out _);
if(!sense &&
!dev.Error &&
cmdBuf.Length == 0x6000)
if(!sense && !dev.Error && cmdBuf.Length == 0x6000)
ps2BootSectors = cmdBuf;
}
else
@@ -1022,24 +1010,20 @@ public static class MMC
sense = dev.Read12(out cmdBuf, out _, 0, false, false, false, false, 0, 2048, 0, 1, false,
dev.Timeout, out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
{
sector0 = cmdBuf;
sense = dev.Read12(out cmdBuf, out _, 0, false, false, false, false, 1, 2048, 0, 1, false,
dev.Timeout, out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
sector1 = cmdBuf;
sense = dev.Read12(out cmdBuf, out _, 0, false, false, false, false, 0, 2048, 0, 12, false,
dev.Timeout, out _);
if(!sense &&
!dev.Error &&
cmdBuf.Length == 0x6000)
if(!sense && !dev.Error && cmdBuf.Length == 0x6000)
ps2BootSectors = cmdBuf;
}
else
@@ -1047,46 +1031,38 @@ public static class MMC
sense = dev.Read10(out cmdBuf, out _, 0, false, false, false, false, 0, 2048, 0, 1, dev.Timeout,
out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
{
sector0 = cmdBuf;
sense = dev.Read10(out cmdBuf, out _, 0, false, false, false, false, 1, 2048, 0, 1,
dev.Timeout, out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
sector1 = cmdBuf;
sense = dev.Read10(out cmdBuf, out _, 0, false, false, false, false, 0, 2048, 0, 12,
dev.Timeout, out _);
if(!sense &&
!dev.Error &&
cmdBuf.Length == 0x6000)
if(!sense && !dev.Error && cmdBuf.Length == 0x6000)
ps2BootSectors = cmdBuf;
}
else
{
sense = dev.Read6(out cmdBuf, out _, 0, 2048, 1, dev.Timeout, out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
{
sector0 = cmdBuf;
sense = dev.Read6(out cmdBuf, out _, 1, 2048, 1, dev.Timeout, out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
sector1 = cmdBuf;
sense = dev.Read6(out cmdBuf, out _, 0, 2048, 12, dev.Timeout, out _);
if(!sense &&
!dev.Error &&
cmdBuf.Length == 0x6000)
if(!sense && !dev.Error && cmdBuf.Length == 0x6000)
ps2BootSectors = cmdBuf;
}
}
@@ -1207,8 +1183,7 @@ public static class MMC
break;
// If it is PVD or end of descriptor chain, break
if(isoSector[0] == 1 ||
isoSector[0] == 255)
if(isoSector[0] == 1 || isoSector[0] == 255)
break;
isoSectorPosition++;
@@ -1226,8 +1201,7 @@ public static class MMC
var rootStart = BitConverter.ToUInt32(isoSector, 158);
var rootLength = BitConverter.ToUInt32(isoSector, 166);
if(rootStart == 0 ||
rootLength == 0)
if(rootStart == 0 || rootLength == 0)
return;
rootLength /= 2048;
@@ -1273,8 +1247,7 @@ public static class MMC
if(name.EndsWith(";1", StringComparison.InvariantCulture))
name = name[..^2];
if(name == "PHOTO_CD" &&
(isoSector[rootPos + 25] & 0x02) == 0x02)
if(name == "PHOTO_CD" && (isoSector[rootPos + 25] & 0x02) == 0x02)
{
pcdStart = BitConverter.ToUInt32(isoSector, rootPos + 2);
pcdLength = BitConverter.ToUInt32(isoSector, rootPos + 10) / 2048;
@@ -1443,8 +1416,7 @@ public static class MMC
string ps2BootSectorsHash = Sha256Context.Data(ps2BootSectors, out _);
AaruConsole.DebugWriteLine(MODULE_NAME,
Localization.Core.PlayStation_2_boot_sectors_SHA256_0,
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.PlayStation_2_boot_sectors_SHA256_0,
ps2BootSectorsHash);
if(ps2BootSectorsHash is PS2_PAL_HASH or PS2_NTSC_HASH or PS2_JAPANESE_HASH)
@@ -1482,8 +1454,7 @@ public static class MMC
}
}
if(playdia1 != null &&
playdia2 != null)
if(playdia1 != null && playdia2 != null)
{
var pd1 = new byte[_playdiaCopyright.Length];
var pd2 = new byte[_playdiaCopyright.Length];
@@ -1491,8 +1462,7 @@ public static class MMC
Array.Copy(playdia1, 38, pd1, 0, pd1.Length);
Array.Copy(playdia2, 0, pd2, 0, pd1.Length);
if(_playdiaCopyright.SequenceEqual(pd1) &&
_playdiaCopyright.SequenceEqual(pd2))
if(_playdiaCopyright.SequenceEqual(pd1) && _playdiaCopyright.SequenceEqual(pd2))
{
mediaType = MediaType.Playdia;
@@ -1674,8 +1644,7 @@ public static class MMC
break;
// If it is PVD or end of descriptor chain, break
if(isoSector[0] == 1 ||
isoSector[0] == 255)
if(isoSector[0] == 1 || isoSector[0] == 255)
break;
isoSectorPosition++;
@@ -1693,8 +1662,7 @@ public static class MMC
var rootStart = BitConverter.ToUInt32(isoSector, 158);
var rootLength = BitConverter.ToUInt32(isoSector, 166);
if(rootStart == 0 ||
rootLength == 0)
if(rootStart == 0 || rootLength == 0)
return;
rootLength /= 2048;
@@ -1851,8 +1819,7 @@ public static class MMC
string line = sr.ReadLine();
// End of file
if(line is null ||
line.Length == 0)
if(line is null || line.Length == 0)
{
if(lineNumber == 0)
correctNeoGeoCd = false;
@@ -1906,8 +1873,7 @@ public static class MMC
}
// Second part must be a single digit
if(split[1].Length != 1 ||
!byte.TryParse(split[1], out _))
if(split[1].Length != 1 || !byte.TryParse(split[1], out _))
{
correctNeoGeoCd = false;
@@ -2173,8 +2139,7 @@ public static class MMC
string line = sr.ReadLine();
// End of file
if(line is null ||
line.Length == 0)
if(line is null || line.Length == 0)
break;
line = line.Replace(" ", "");
@@ -2206,8 +2171,7 @@ public static class MMC
break;
}
if(ps1BootFile != null &&
rootEntries.Contains(ps1BootFile.ToUpperInvariant()))
if(ps1BootFile != null && rootEntries.Contains(ps1BootFile.ToUpperInvariant()))
{
mediaType = MediaType.PS1CD;
@@ -2215,8 +2179,7 @@ public static class MMC
Localization.Core.Found_correct_SYSTEM_CNF_file_in_root_PS1);
}
if(ps2BootFile != null &&
rootEntries.Contains(ps2BootFile.ToUpperInvariant()))
if(ps2BootFile != null && rootEntries.Contains(ps2BootFile.ToUpperInvariant()))
{
mediaType = MediaType.PS2CD;
@@ -2248,8 +2211,7 @@ public static class MMC
string ps2BootSectorsHash = Sha256Context.Data(ps2BootSectors, out _);
AaruConsole.DebugWriteLine(MODULE_NAME,
Localization.Core.PlayStation_2_boot_sectors_SHA256_0,
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.PlayStation_2_boot_sectors_SHA256_0,
ps2BootSectorsHash);
if(ps2BootSectorsHash is PS2_PAL_HASH or PS2_NTSC_HASH or PS2_JAPANESE_HASH)
@@ -2290,8 +2252,7 @@ public static class MMC
tmp = new byte[_ps4Id.Length];
Array.Copy(sector1, 512, tmp, 0, tmp.Length);
if(tmp.SequenceEqual(_ps4Id) &&
mediaType == MediaType.BDROM)
if(tmp.SequenceEqual(_ps4Id) && mediaType == MediaType.BDROM)
{
mediaType = MediaType.PS4BD;
@@ -2300,8 +2261,7 @@ public static class MMC
}
}
if(blurayDi is { Units.Length: > 0 } &&
blurayDi?.Units[0].DiscTypeIdentifier != null)
if(blurayDi is { Units.Length: > 0 } && blurayDi?.Units[0].DiscTypeIdentifier != null)
{
string blurayType = StringHandlers.CToString(blurayDi?.Units[0].DiscTypeIdentifier);

View File

@@ -92,7 +92,10 @@ public static class CompactDisc
if(dataTrack != null)
{
// Build sync
sectorSync = new byte[] { 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00 };
sectorSync = new byte[]
{
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00
};
tmpBuf = new byte[sectorSync.Length];
@@ -107,8 +110,7 @@ public static class CompactDisc
sense = dev.PlextorReadCdDa(out cmdBuf, out _, wantedLba, sectorSize, 3, PlextorSubchannel.None,
dev.Timeout, out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
{
supportsPlextorReadCdDa = true;
@@ -144,7 +146,8 @@ public static class CompactDisc
}
if(!offsetFound &&
(debug || dbDev?.ATAPI?.RemovableMedias?.Any(d => d.CanReadCdScrambled == true) == true ||
(debug ||
dbDev?.ATAPI?.RemovableMedias?.Any(d => d.CanReadCdScrambled == true) == true ||
dbDev?.SCSI?.RemovableMedias?.Any(d => d.CanReadCdScrambled == true) == true ||
dbDev?.SCSI?.MultiMediaDevice?.TestedMedia?.Any(d => d.CanReadCdScrambled == true) == true ||
dev.Manufacturer.Equals("hl-dt-st", StringComparison.InvariantCultureIgnoreCase)))
@@ -153,8 +156,7 @@ public static class CompactDisc
false, false, MmcHeaderCodes.None, true, false, MmcErrorField.None,
MmcSubchannel.None, dev.Timeout, out _);
if(!sense &&
!dev.Error)
if(!sense && !dev.Error)
{
// Clear cache
for(var i = 0; i < 63; i++)
@@ -212,8 +214,7 @@ public static class CompactDisc
for(var i = 1; i < tracks.Length; i++)
{
if(tracks[i - 1].Type == TrackType.Audio ||
tracks[i].Type != TrackType.Audio)
if(tracks[i - 1].Type == TrackType.Audio || tracks[i].Type != TrackType.Audio)
continue;
dataTrack = tracks[i - 1];
@@ -222,8 +223,7 @@ public static class CompactDisc
break;
}
if(dataTrack is null ||
audioTrack is null)
if(dataTrack is null || audioTrack is null)
return;
// Found them

View File

@@ -62,8 +62,7 @@ public sealed class ScsiInfo
/// <param name="dev">Device</param>
public ScsiInfo(Device dev)
{
if(dev.Type != DeviceType.SCSI &&
dev.Type != DeviceType.ATAPI)
if(dev.Type != DeviceType.SCSI && dev.Type != DeviceType.ATAPI)
return;
MediaType = MediaType.Unknown;
@@ -210,11 +209,9 @@ public sealed class ScsiInfo
if(!sense)
ReadCapacity16 = cmdBuf;
if(ReadCapacity == null ||
Blocks is 0xFFFFFFFF or 0)
if(ReadCapacity == null || Blocks is 0xFFFFFFFF or 0)
{
if(ReadCapacity16 == null &&
Blocks == 0)
if(ReadCapacity16 == null && Blocks == 0)
{
if(dev.ScsiType != PeripheralDeviceTypes.MultiMediaDevice)
{
@@ -234,8 +231,7 @@ public sealed class ScsiInfo
}
}
if(Blocks != 0 &&
BlockSize != 0)
if(Blocks != 0 && BlockSize != 0)
Blocks++;
break;
@@ -248,8 +244,7 @@ public sealed class ScsiInfo
{
sense = dev.ReportDensitySupport(out medBuf, out senseBuf, true, dev.Timeout, out _);
if(!sense &&
!seqBuf.SequenceEqual(medBuf))
if(!sense && !seqBuf.SequenceEqual(medBuf))
{
DensitySupport = seqBuf;
DensitySupportHeader = Decoders.SCSI.SSC.DensitySupport.DecodeDensity(seqBuf);
@@ -262,8 +257,7 @@ public sealed class ScsiInfo
{
sense = dev.ReportDensitySupport(out medBuf, out senseBuf, true, true, dev.Timeout, out _);
if(!sense &&
!seqBuf.SequenceEqual(medBuf))
if(!sense && !seqBuf.SequenceEqual(medBuf))
{
MediaTypeSupport = medBuf;
MediaTypeSupportHeader = Decoders.SCSI.SSC.DensitySupport.DecodeMediumType(seqBuf);
@@ -304,11 +298,9 @@ public sealed class ScsiInfo
if(sense)
{
AaruConsole.DebugWriteLine(MODULE_NAME, "READ GET CONFIGURATION:\n{0}",
Sense.PrettifySense(senseBuf));
AaruConsole.DebugWriteLine(MODULE_NAME, "READ GET CONFIGURATION:\n{0}", Sense.PrettifySense(senseBuf));
if(dev.IsUsb &&
scsiMediumType is 0x40 or 0x41 or 0x42)
if(dev.IsUsb && scsiMediumType is 0x40 or 0x41 or 0x42)
MediaType = MediaType.FlashDrive;
}
else
@@ -316,8 +308,7 @@ public sealed class ScsiInfo
MmcConfiguration = cmdBuf;
Features.SeparatedFeatures ftr = Features.Separate(cmdBuf);
AaruConsole.DebugWriteLine(MODULE_NAME,
Localization.Core.GET_CONFIGURATION_current_profile_is_0,
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.GET_CONFIGURATION_current_profile_is_0,
ftr.CurrentProfile);
switch(ftr.CurrentProfile)
@@ -455,8 +446,7 @@ public sealed class ScsiInfo
}
}
if(MediaType == MediaType.PD650 &&
Blocks == 1281856)
if(MediaType == MediaType.PD650 && Blocks == 1281856)
MediaType = MediaType.PD650_WORM;
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
@@ -476,8 +466,7 @@ public sealed class ScsiInfo
if(sense)
{
AaruConsole.DebugWriteLine(MODULE_NAME,
Localization.Core.READ_DISC_STRUCTURE_Write_Protection_Status_0,
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_Write_Protection_Status_0,
Sense.PrettifySense(senseBuf));
}
else
@@ -496,10 +485,9 @@ public sealed class ScsiInfo
if(MediaType is MediaType.DVDDownload or MediaType.DVDPR or MediaType.DVDPRDL or MediaType.DVDPRW
or MediaType.DVDPRWDL or MediaType.DVDR or MediaType.DVDRAM or MediaType.DVDRDL
or MediaType.DVDROM
or MediaType.DVDRW or MediaType.DVDRWDL or MediaType.HDDVDR or MediaType.HDDVDRAM
or MediaType.HDDVDRDL
or MediaType.HDDVDROM or MediaType.HDDVDRW or MediaType.HDDVDRWDL)
or MediaType.DVDROM or MediaType.DVDRW or MediaType.DVDRWDL or MediaType.HDDVDR
or MediaType.HDDVDRAM or MediaType.HDDVDRDL or MediaType.HDDVDROM or MediaType.HDDVDRW
or MediaType.HDDVDRWDL)
{
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.PhysicalInformation, 0, dev.Timeout, out _);
@@ -614,8 +602,7 @@ public sealed class ScsiInfo
if(sense)
{
AaruConsole.DebugWriteLine(MODULE_NAME,
Localization.Core.READ_DISC_STRUCTURE_DVD_AACS_0,
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_DVD_AACS_0,
Sense.PrettifySense(senseBuf));
}
else
@@ -645,8 +632,7 @@ public sealed class ScsiInfo
if(sense)
{
AaruConsole.DebugWriteLine(MODULE_NAME,
Localization.Core.READ_DISC_STRUCTURE_Medium_Status_0,
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_Medium_Status_0,
Sense.PrettifySense(senseBuf));
}
else
@@ -779,8 +765,7 @@ public sealed class ScsiInfo
if(sense)
{
AaruConsole.DebugWriteLine(MODULE_NAME,
Localization.Core.READ_DISC_STRUCTURE_Pre_Recorded_Info_0,
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_Pre_Recorded_Info_0,
Sense.PrettifySense(senseBuf));
}
else
@@ -807,8 +792,7 @@ public sealed class ScsiInfo
if(sense)
{
AaruConsole.DebugWriteLine(MODULE_NAME,
Localization.Core.READ_DISC_STRUCTURE_DVD_R_Media_ID_0,
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_DVD_R_Media_ID_0,
Sense.PrettifySense(senseBuf));
}
else
@@ -820,8 +804,7 @@ public sealed class ScsiInfo
if(sense)
{
AaruConsole.DebugWriteLine(MODULE_NAME,
Localization.Core.READ_DISC_STRUCTURE_DVD_R_PFI_0,
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_DVD_R_PFI_0,
Sense.PrettifySense(senseBuf));
}
else
@@ -876,8 +859,7 @@ public sealed class ScsiInfo
if(sense)
{
AaruConsole.DebugWriteLine(MODULE_NAME,
Localization.Core.READ_DISC_STRUCTURE_HD_DVD_CMI_0,
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_HD_DVD_CMI_0,
Sense.PrettifySense(senseBuf));
}
else
@@ -911,8 +893,7 @@ public sealed class ScsiInfo
if(sense)
{
AaruConsole.DebugWriteLine(MODULE_NAME,
Localization.Core.READ_DISC_STRUCTURE_Last_RMD_0,
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_Last_RMD_0,
Sense.PrettifySense(senseBuf));
}
else
@@ -932,8 +913,7 @@ public sealed class ScsiInfo
if(sense)
{
AaruConsole.DebugWriteLine(MODULE_NAME,
Localization.Core.READ_DISC_STRUCTURE_Layer_Capacity_0,
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_Layer_Capacity_0,
Sense.PrettifySense(senseBuf));
}
else
@@ -1093,8 +1073,7 @@ public sealed class ScsiInfo
if(sense)
{
AaruConsole.DebugWriteLine(MODULE_NAME,
"READ DISC STRUCTURE: Spare Area Information\n{0}",
AaruConsole.DebugWriteLine(MODULE_NAME, "READ DISC STRUCTURE: Spare Area Information\n{0}",
Sense.PrettifySense(senseBuf));
}
else
@@ -1105,8 +1084,7 @@ public sealed class ScsiInfo
if(sense)
{
AaruConsole.DebugWriteLine(MODULE_NAME,
Localization.Core.READ_DISC_STRUCTURE_Raw_DFL_0,
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_DISC_STRUCTURE_Raw_DFL_0,
Sense.PrettifySense(senseBuf));
}
else
@@ -1192,8 +1170,7 @@ public sealed class ScsiInfo
if(sense)
{
AaruConsole.DebugWriteLine(MODULE_NAME,
Localization.Core.READ_TOC_PMA_ATIP_Session_Info_0,
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_TOC_PMA_ATIP_Session_Info_0,
Sense.PrettifySense(senseBuf));
}
else if(cmdBuf.Length > 4)
@@ -1212,8 +1189,7 @@ public sealed class ScsiInfo
if(sense)
{
AaruConsole.DebugWriteLine(MODULE_NAME,
Localization.Core.READ_TOC_PMA_ATIP_Raw_TOC_0,
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_TOC_PMA_ATIP_Raw_TOC_0,
Sense.PrettifySense(senseBuf));
}
else if(cmdBuf.Length > 4)
@@ -1237,8 +1213,7 @@ public sealed class ScsiInfo
if(sense)
{
AaruConsole.DebugWriteLine(MODULE_NAME,
Localization.Core.READ_TOC_PMA_ATIP_CD_TEXT_0,
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.READ_TOC_PMA_ATIP_CD_TEXT_0,
Sense.PrettifySense(senseBuf));
}
else if(cmdBuf.Length > 4)
@@ -1249,9 +1224,7 @@ public sealed class ScsiInfo
sense = dev.ReadMcn(out string mcn, out _, out _, dev.Timeout, out _);
if(!sense &&
mcn != null &&
mcn != "0000000000000")
if(!sense && mcn != null && mcn != "0000000000000")
Mcn = mcn;
Isrcs = new Dictionary<byte, string>();
@@ -1260,9 +1233,7 @@ public sealed class ScsiInfo
{
sense = dev.ReadIsrc(i, out string isrc, out _, out _, dev.Timeout, out _);
if(!sense &&
isrc != null &&
isrc != "000000000000")
if(!sense && isrc != null && isrc != "000000000000")
Isrcs.Add(i, isrc);
}
@@ -1277,8 +1248,7 @@ public sealed class ScsiInfo
#region Nintendo
if(MediaType == MediaType.Unknown &&
Blocks > 0)
if(MediaType == MediaType.Unknown && Blocks > 0)
{
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.PhysicalInformation, 0, dev.Timeout, out _);
@@ -1367,8 +1337,7 @@ public sealed class ScsiInfo
DecodedXboxSecuritySector = SS.Decode(cmdBuf);
// Get video partition size
AaruConsole.DebugWriteLine(MODULE_NAME,
Localization.Core.Getting_video_partition_size);
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Getting_video_partition_size);
sense = dev.KreonLock(out senseBuf, dev.Timeout, out _);
@@ -1401,11 +1370,12 @@ public sealed class ScsiInfo
break;
}
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(cmdBuf, MediaType).Value.Layer0EndPSN -
PFI.Decode(cmdBuf, MediaType).Value.DataAreaStartPSN + 1;
PFI.Decode(cmdBuf, MediaType).Value.DataAreaStartPSN +
1;
ulong l1Video = totalSize - l0Video + 1;
@@ -1431,10 +1401,11 @@ public sealed class ScsiInfo
ulong gameSize =
((ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[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);
@@ -1469,12 +1440,15 @@ public sealed class ScsiInfo
break;
}
AaruConsole.DebugWriteLine(MODULE_NAME,
Localization.Core.Unlocked_total_size_0_sectors, totalSize);
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Unlocked_total_size_0_sectors,
totalSize);
ulong middleZone =
totalSize - (PFI.Decode(cmdBuf, MediaType).Value.Layer0EndPSN -
PFI.Decode(cmdBuf, MediaType).Value.DataAreaStartPSN + 1) - gameSize + 1;
ulong middleZone = totalSize -
(PFI.Decode(cmdBuf, MediaType).Value.Layer0EndPSN -
PFI.Decode(cmdBuf, MediaType).Value.DataAreaStartPSN +
1) -
gameSize +
1;
totalSize = l0Video + l1Video + middleZone * 2 + gameSize;
ulong layerBreak = l0Video + middleZone + gameSize / 2;
@@ -1503,13 +1477,10 @@ public sealed class ScsiInfo
break;
}
if(MediaType == MediaType.Unknown &&
dev.IsUsb &&
containsFloppyPage)
if(MediaType == MediaType.Unknown && dev.IsUsb && containsFloppyPage)
MediaType = MediaType.FlashDrive;
if(MediaType == MediaType.Unknown &&
!dev.IsRemovable)
if(MediaType == MediaType.Unknown && !dev.IsRemovable)
MediaType = MediaType.GENERIC_HDD;
if(DeviceInfo.ScsiType != PeripheralDeviceTypes.MultiMediaDevice ||

View File

@@ -88,8 +88,7 @@ public static class Options
sb = new StringBuilder();
inValue = false;
if(string.IsNullOrEmpty(name) ||
string.IsNullOrEmpty(value))
if(string.IsNullOrEmpty(name) || string.IsNullOrEmpty(value))
continue;
if(parsed.ContainsKey(name))
@@ -191,8 +190,7 @@ public static class Options
value = sb.ToString();
if(string.IsNullOrEmpty(name) ||
string.IsNullOrEmpty(value))
if(string.IsNullOrEmpty(name) || string.IsNullOrEmpty(value))
return parsed;
if(parsed.ContainsKey(name))

View File

@@ -206,8 +206,10 @@ public static class Partitions
}
}
Partition[] childArray = childPartitions.OrderBy(part => part.Start).ThenBy(part => part.Length).
ThenBy(part => part.Scheme).ToArray();
Partition[] childArray = childPartitions.OrderBy(part => part.Start).
ThenBy(part => part.Length).
ThenBy(part => part.Scheme).
ToArray();
for(long i = 0; i < childArray.LongLength; i++)
childArray[i].Sequence = (ulong)i;
@@ -219,8 +221,7 @@ public static class Partitions
/// <param name="partitions">List of partitions</param>
public static void AddSchemesToStats(List<Partition> partitions)
{
if(partitions == null ||
partitions.Count == 0)
if(partitions == null || partitions.Count == 0)
return;
List<string> schemes = new();

View File

@@ -112,15 +112,13 @@ public sealed class PluginBase
{
foreach(Type type in pluginRegister.GetAllFilesystemPlugins() ?? Enumerable.Empty<Type>())
{
if(Activator.CreateInstance(type) is IFilesystem plugin &&
!Filesystems.ContainsKey(plugin.Name.ToLower()))
if(Activator.CreateInstance(type) is IFilesystem plugin && !Filesystems.ContainsKey(plugin.Name.ToLower()))
Filesystems.Add(plugin.Name.ToLower(), type);
}
foreach(Type type in pluginRegister.GetAllFilterPlugins() ?? Enumerable.Empty<Type>())
{
if(Activator.CreateInstance(type) is IFilter plugin &&
!Filters.ContainsKey(plugin.Name.ToLower()))
if(Activator.CreateInstance(type) is IFilter plugin && !Filters.ContainsKey(plugin.Name.ToLower()))
Filters.Add(plugin.Name.ToLower(), type);
}
@@ -133,15 +131,13 @@ public sealed class PluginBase
foreach(Type type in pluginRegister.GetAllMediaImagePlugins() ?? Enumerable.Empty<Type>())
{
if(Activator.CreateInstance(type) is IMediaImage plugin &&
!MediaImages.ContainsKey(plugin.Name.ToLower()))
if(Activator.CreateInstance(type) is IMediaImage plugin && !MediaImages.ContainsKey(plugin.Name.ToLower()))
MediaImages.Add(plugin.Name.ToLower(), type);
}
foreach(Type type in pluginRegister.GetAllPartitionPlugins() ?? Enumerable.Empty<Type>())
{
if(Activator.CreateInstance(type) is IPartition plugin &&
!Partitions.ContainsKey(plugin.Name.ToLower()))
if(Activator.CreateInstance(type) is IPartition plugin && !Partitions.ContainsKey(plugin.Name.ToLower()))
Partitions.Add(plugin.Name.ToLower(), type);
}
@@ -168,8 +164,7 @@ public sealed class PluginBase
foreach(Type type in pluginRegister.GetAllArchivePlugins() ?? Enumerable.Empty<Type>())
{
if(Activator.CreateInstance(type) is IArchive plugin &&
!Archives.ContainsKey(plugin.Name.ToLower()))
if(Activator.CreateInstance(type) is IArchive plugin && !Archives.ContainsKey(plugin.Name.ToLower()))
Archives.Add(plugin.Name.ToLower(), type);
}

View File

@@ -59,8 +59,7 @@ public static class PrintScsiModePages
{
case 0x00:
{
if(devType == PeripheralDeviceTypes.MultiMediaDevice &&
page.Subpage == 0)
if(devType == PeripheralDeviceTypes.MultiMediaDevice && page.Subpage == 0)
AaruConsole.WriteLine(Modes.PrettifyModePage_00_SFF(page.PageResponse));
else
{

View File

@@ -79,7 +79,8 @@ public static class Remote
HttpResponseMessage response = httpClient.
PostAsync("/api/uploadreportv2",
new StringContent(json, Encoding.UTF8,
"application/json")).GetAwaiter().
"application/json")).
GetAwaiter().
GetResult();
if(!response.IsSuccessStatusCode)
@@ -121,8 +122,7 @@ public static class Remote
mctx.Database.EnsureCreated();
mctx.Database.
ExecuteSqlRaw(
"CREATE TABLE IF NOT EXISTS \"__EFMigrationsHistory\" (\"MigrationId\" TEXT PRIMARY KEY, \"ProductVersion\" TEXT)");
ExecuteSqlRaw("CREATE TABLE IF NOT EXISTS \"__EFMigrationsHistory\" (\"MigrationId\" TEXT PRIMARY KEY, \"ProductVersion\" TEXT)");
foreach(string migration in mctx.Database.GetPendingMigrations())
{
@@ -198,7 +198,9 @@ public static class Remote
if(create)
{
AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
AnsiConsole.Progress().
AutoClear(true).
HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx =>
{
@@ -214,7 +216,9 @@ public static class Remote
AaruConsole.WriteLine(Localization.Core.Added_0_usb_vendors, sync.UsbVendors.Count);
AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
AnsiConsole.Progress().
AutoClear(true).
HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx =>
{
@@ -232,7 +236,9 @@ public static class Remote
AaruConsole.WriteLine(Localization.Core.Added_0_usb_products, sync.UsbProducts.Count);
AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
AnsiConsole.Progress().
AutoClear(true).
HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx =>
{
@@ -252,7 +258,9 @@ public static class Remote
AaruConsole.WriteLine(Localization.Core.Added_0_CompactDisc_read_offsets, sync.Offsets.Count);
AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
AnsiConsole.Progress().
AutoClear(true).
HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx =>
{
@@ -273,7 +281,9 @@ public static class Remote
AaruConsole.WriteLine(Localization.Core.Added_0_known_devices, sync.Devices.Count);
AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
AnsiConsole.Progress().
AutoClear(true).
HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx =>
{
@@ -321,7 +331,9 @@ public static class Remote
long modifiedDevices = 0;
long modifiedNesHeaders = 0;
AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
AnsiConsole.Progress().
AutoClear(true).
HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx =>
{
@@ -352,7 +364,9 @@ public static class Remote
AaruConsole.WriteLine(Localization.Core.Added_0_usb_vendors, addedVendors);
AaruConsole.WriteLine(Localization.Core.Modified_0_USB_vendors, modifiedVendors);
AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
AnsiConsole.Progress().
AutoClear(true).
HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx =>
{
@@ -387,7 +401,9 @@ public static class Remote
AaruConsole.WriteLine(Localization.Core.Added_0_usb_products, addedProducts);
AaruConsole.WriteLine(Localization.Core.Modified_0_USB_products, modifiedProducts);
AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
AnsiConsole.Progress().
AutoClear(true).
HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx =>
{
@@ -425,7 +441,9 @@ public static class Remote
AaruConsole.WriteLine(Localization.Core.Added_0_CompactDisc_read_offsets, addedOffsets);
AaruConsole.WriteLine(Localization.Core.Modified_0_CompactDisc_read_offsets, modifiedOffsets);
AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
AnsiConsole.Progress().
AutoClear(true).
HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx =>
{
@@ -469,7 +487,9 @@ public static class Remote
AaruConsole.WriteLine(Localization.Core.Added_0_known_devices, addedDevices);
AaruConsole.WriteLine(Localization.Core.Modified_0_known_devices, modifiedDevices);
AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
AnsiConsole.Progress().
AutoClear(true).
HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx =>
{

View File

@@ -74,8 +74,7 @@ public sealed partial class Sidecar
}
};
if(image.Info.MediaSequence != 0 &&
image.Info.LastMediaSequence != 0)
if(image.Info.MediaSequence != 0 && image.Info.LastMediaSequence != 0)
{
sidecar.AudioMedias[0].Sequence.MediaSequence = (uint)image.Info.MediaSequence;
sidecar.AudioMedias[0].Sequence.TotalMedia = (uint)image.Info.LastMediaSequence;

View File

@@ -90,8 +90,7 @@ public sealed partial class Sidecar
}
};
if(image.Info.MediaSequence != 0 &&
image.Info.LastMediaSequence != 0)
if(image.Info.MediaSequence != 0 && image.Info.LastMediaSequence != 0)
{
sidecar.BlockMedias[0].Sequence.MediaSequence = (uint)image.Info.MediaSequence;
sidecar.BlockMedias[0].Sequence.TotalMedia = (uint)image.Info.LastMediaSequence;
@@ -570,7 +569,7 @@ public sealed partial class Sidecar
List<TapeFile> filesInPartition = new();
foreach(CommonTypes.Structs.TapeFile tapeFile in
tapeImage.Files.Where(f => f.Partition == tapePartition.Number))
tapeImage.Files.Where(f => f.Partition == tapePartition.Number))
{
var thisFile = new TapeFile
{
@@ -827,8 +826,7 @@ public sealed partial class Sidecar
UpdateStatus(Localization.Core.Saving_metadata);
if(image.Info.Cylinders > 0 &&
image.Info is { Heads: > 0, SectorsPerTrack: > 0 })
if(image.Info.Cylinders > 0 && image.Info is { Heads: > 0, SectorsPerTrack: > 0 })
{
sidecar.BlockMedias[0].Cylinders = image.Info.Cylinders;
sidecar.BlockMedias[0].Heads = (ushort)image.Info.Heads;
@@ -1005,8 +1003,7 @@ public sealed partial class Sidecar
var scpFilter = new ZZZNoFilter();
scpFilter.Open(scpFilePath);
if(image.Info.Heads <= 2 &&
scpImage.Identify(scpFilter))
if(image.Info.Heads <= 2 && scpImage.Identify(scpFilter))
{
try
{
@@ -1053,8 +1050,10 @@ public sealed partial class Sidecar
if(scpImage.ScpTracks.TryGetValue(t, out SuperCardPro.TrackHeader scpTrack))
{
var trackContents =
new byte[scpTrack.Entries.Last().dataOffset + scpTrack.Entries.Last().trackLength -
scpImage.Header.offsets[t] + 1];
new byte[scpTrack.Entries.Last().dataOffset +
scpTrack.Entries.Last().trackLength -
scpImage.Header.offsets[t] +
1];
scpStream.Position = scpImage.Header.offsets[t];
scpStream.EnsureRead(trackContents, 0, trackContents.Length);
@@ -1066,14 +1065,14 @@ public sealed partial class Sidecar
}
sidecar.BlockMedias[0].Track = scpBlockTrackTypes.OrderBy(t => t.Cylinder).
ThenBy(t => t.Head).ToList();
ThenBy(t => t.Head).
ToList();
}
else
{
AaruConsole.
ErrorWriteLine(
Localization.Core.SCP_image_do_not_same_number_tracks_0_disk_image_1_ignoring,
scpImage.Header.end + 1, image.Info.Cylinders);
ErrorWriteLine(Localization.Core.SCP_image_do_not_same_number_tracks_0_disk_image_1_ignoring,
scpImage.Header.end + 1, image.Info.Cylinders);
}
}
else
@@ -1121,8 +1120,7 @@ public sealed partial class Sidecar
var kfFilter = new ZZZNoFilter();
kfFilter.Open(kfFile);
if(image.Info.Heads <= 2 &&
kfImage.Identify(kfFilter))
if(image.Info.Heads <= 2 && kfImage.Identify(kfFilter))
{
try
{
@@ -1180,22 +1178,21 @@ public sealed partial class Sidecar
}
sidecar.BlockMedias[0].Track = kfBlockTrackTypes.OrderBy(t => t.Cylinder).
ThenBy(t => t.Head).ToList();
ThenBy(t => t.Head).
ToList();
}
else
{
AaruConsole.
ErrorWriteLine(
Localization.Core.KryoFlux_image_do_not_same_number_tracks_0_disk_image_1_ignoring,
kfImage.Info.Cylinders, image.Info.Cylinders);
ErrorWriteLine(Localization.Core.KryoFlux_image_do_not_same_number_tracks_0_disk_image_1_ignoring,
kfImage.Info.Cylinders, image.Info.Cylinders);
}
}
else
{
AaruConsole.
ErrorWriteLine(
Localization.Core.KryoFlux_image_do_not_same_number_heads_0_disk_image_1_ignoring,
kfImage.Info.Heads, image.Info.Heads);
ErrorWriteLine(Localization.Core.KryoFlux_image_do_not_same_number_heads_0_disk_image_1_ignoring,
kfImage.Info.Heads, image.Info.Heads);
}
}
}

View File

@@ -55,8 +55,7 @@ public sealed partial class Sidecar
List<Directory> directories = new();
List<ContentsFile> files = new();
while(filesystem.ReadDir(node, out string dirent) == ErrorNumber.NoError &&
dirent is not null)
while(filesystem.ReadDir(node, out string dirent) == ErrorNumber.NoError && dirent is not null)
{
ret = filesystem.Stat(dirent, out FileEntryInfo stat);
@@ -115,8 +114,7 @@ public sealed partial class Sidecar
List<Directory> directories = new();
List<ContentsFile> files = new();
while(filesystem.ReadDir(node, out string dirent) == ErrorNumber.NoError &&
dirent is not null)
while(filesystem.ReadDir(node, out string dirent) == ErrorNumber.NoError && dirent is not null)
{
ret = filesystem.Stat(path + "/" + filename + "/" + dirent, out FileEntryInfo entryStat);

View File

@@ -86,8 +86,7 @@ public sealed partial class Sidecar
}
};
if(image.Info.MediaSequence != 0 &&
image.Info.LastMediaSequence != 0)
if(image.Info.MediaSequence != 0 && image.Info.LastMediaSequence != 0)
{
sidecar.OpticalDiscs[0].Sequence.MediaSequence = (uint)image.Info.MediaSequence;
sidecar.OpticalDiscs[0].Sequence.TotalMedia = (uint)image.Info.LastMediaSequence;
@@ -183,16 +182,13 @@ public sealed partial class Sidecar
_ => dskType
};
if(dskType == MediaType.DVDR &&
pfi.Value.PartVersion >= 6)
if(dskType == MediaType.DVDR && pfi.Value.PartVersion >= 6)
dskType = MediaType.DVDRDL;
if(dskType == MediaType.DVDRW &&
pfi.Value.PartVersion >= 15)
if(dskType == MediaType.DVDRW && pfi.Value.PartVersion >= 15)
dskType = MediaType.DVDRWDL;
if(dskType == MediaType.GOD &&
pfi.Value.DiscSize == DVDSize.OneTwenty)
if(dskType == MediaType.GOD && pfi.Value.DiscSize == DVDSize.OneTwenty)
dskType = MediaType.WOD;
sidecar.OpticalDiscs[0].Dimensions = new Dimensions();
@@ -246,8 +242,7 @@ public sealed partial class Sidecar
trksLst = new List<CommonTypes.AaruMetadata.Track>();
}
if(sidecar.OpticalDiscs[0].Dimensions == null &&
image.Info.MediaType != MediaType.Unknown)
if(sidecar.OpticalDiscs[0].Dimensions == null && image.Info.MediaType != MediaType.Unknown)
sidecar.OpticalDiscs[0].Dimensions = Dimensions.FromMediaType(image.Info.MediaType);
if(_aborted)
@@ -299,8 +294,7 @@ public sealed partial class Sidecar
xmlTrk.StartSector = trk.StartSector;
xmlTrk.EndSector = trk.EndSector;
if(trk.Indexes?.TryGetValue(0, out int idx0) == true &&
idx0 >= 0)
if(trk.Indexes?.TryGetValue(0, out int idx0) == true && idx0 >= 0)
xmlTrk.StartSector = (ulong)idx0;
switch(sidecar.OpticalDiscs[0].DiscType)
@@ -513,8 +507,7 @@ public sealed partial class Sidecar
// For fast debugging, skip checksum
//skipChecksum:
var trkPartitions =
partitions.Where(p => p.Start >= trk.StartSector && p.End <= trk.EndSector).ToList();
var trkPartitions = partitions.Where(p => p.Start >= trk.StartSector && p.End <= trk.EndSector).ToList();
xmlTrk.FileSystemInformation = new List<CommonTypes.AaruMetadata.Partition>();
@@ -663,11 +656,13 @@ public sealed partial class Sidecar
if(trk.Indexes?.Count > 0)
{
xmlTrk.Indexes = trk.Indexes?.OrderBy(i => i.Key).Select(i => new TrackIndex
{
Index = i.Key,
Value = i.Value
}).ToList();
xmlTrk.Indexes = trk.Indexes?.OrderBy(i => i.Key).
Select(i => new TrackIndex
{
Index = i.Key,
Value = i.Value
}).
ToList();
}
trksLst.Add(xmlTrk);
@@ -679,10 +674,10 @@ public sealed partial class Sidecar
sidecar.OpticalDiscs[0].Track = trksLst;
// All XGD3 all have the same number of blocks
if(dskType == MediaType.XGD2 &&
sidecar.OpticalDiscs[0].Track.Count == 1)
if(dskType == MediaType.XGD2 && sidecar.OpticalDiscs[0].Track.Count == 1)
{
ulong blocks = sidecar.OpticalDiscs[0].Track[0].EndSector - sidecar.OpticalDiscs[0].Track[0].StartSector +
ulong blocks = sidecar.OpticalDiscs[0].Track[0].EndSector -
sidecar.OpticalDiscs[0].Track[0].StartSector +
1;
if(blocks is 25063 or 4229664 or 4246304) // Wxripper unlock

View File

@@ -8,6 +8,9 @@ public static class Spectre
{
/// <summary>Initializes a progress bar with a single spinner</summary>
/// <param name="action">Action to execute in the progress bar</param>
public static void ProgressSingleSpinner(Action<ProgressContext> action) => AnsiConsole.Progress().AutoClear(true).
HideCompleted(true).Columns(new TaskDescriptionColumn(), new SpinnerColumn()).Start(action);
public static void ProgressSingleSpinner(Action<ProgressContext> action) => AnsiConsole.Progress().
AutoClear(true).
HideCompleted(true).
Columns(new TaskDescriptionColumn(), new SpinnerColumn()).
Start(action);
}

View File

@@ -160,7 +160,8 @@ public static class Statistics
{
dto.Filesystems = new List<NameValueStats>();
foreach(string nvs in ctx.Filesystems.Where(c => !c.Synchronized).Select(c => c.Name).
foreach(string nvs in ctx.Filesystems.Where(c => !c.Synchronized).
Select(c => c.Name).
Distinct())
{
dto.Filesystems.Add(new NameValueStats
@@ -189,7 +190,8 @@ public static class Statistics
{
dto.MediaFormats = new List<NameValueStats>();
foreach(string nvs in ctx.MediaFormats.Where(c => !c.Synchronized).Select(c => c.Name).
foreach(string nvs in ctx.MediaFormats.Where(c => !c.Synchronized).
Select(c => c.Name).
Distinct())
{
dto.MediaFormats.Add(new NameValueStats
@@ -277,19 +279,22 @@ public static class Statistics
{
dto.OperatingSystems = new List<OsStats>();
foreach(string osName in ctx.OperatingSystems.Where(c => !c.Synchronized).Select(c => c.Name).
foreach(string osName in ctx.OperatingSystems.Where(c => !c.Synchronized).
Select(c => c.Name).
Distinct())
{
foreach(string osVersion in ctx.OperatingSystems.
Where(c => !c.Synchronized && c.Name == osName).
Select(c => c.Version).Distinct())
Select(c => c.Version).
Distinct())
{
dto.OperatingSystems.Add(new OsStats
{
name = osName,
version = osVersion,
Value = ctx.OperatingSystems.LongCount(c => !c.Synchronized && c.Name == osName &&
c.Version == osVersion)
Value = ctx.OperatingSystems.LongCount(c => !c.Synchronized &&
c.Name == osName &&
c.Version == osVersion)
});
}
}
@@ -300,12 +305,14 @@ public static class Statistics
dto.RemoteApplications = new List<OsStats>();
foreach(string remoteAppName in ctx.RemoteApplications.Where(c => !c.Synchronized).
Select(c => c.Name).Distinct())
Select(c => c.Name).
Distinct())
{
foreach(string remoteAppVersion in ctx.RemoteApplications.
Where(c => !c.Synchronized &&
c.Name == remoteAppName).
Select(c => c.Version).Distinct())
Select(c => c.Version).
Distinct())
{
dto.RemoteApplications.Add(new OsStats
{
@@ -323,7 +330,8 @@ public static class Statistics
{
dto.RemoteArchitectures = new List<NameValueStats>();
foreach(string nvs in ctx.RemoteArchitectures.Where(c => !c.Synchronized).Select(c => c.Name).
foreach(string nvs in ctx.RemoteArchitectures.Where(c => !c.Synchronized).
Select(c => c.Name).
Distinct())
{
dto.RemoteArchitectures.Add(new NameValueStats
@@ -339,18 +347,21 @@ public static class Statistics
dto.RemoteOperatingSystems = new List<OsStats>();
foreach(string remoteOsName in ctx.RemoteOperatingSystems.Where(c => !c.Synchronized).
Select(c => c.Name).Distinct())
Select(c => c.Name).
Distinct())
{
foreach(string remoteOsVersion in ctx.RemoteOperatingSystems.
Where(c => !c.Synchronized && c.Name == remoteOsName).
Select(c => c.Version).Distinct())
Select(c => c.Version).
Distinct())
{
dto.RemoteOperatingSystems.Add(new OsStats
{
name = remoteOsName,
name = remoteOsName,
version = remoteOsVersion,
Value = ctx.RemoteOperatingSystems.LongCount(c => !c.Synchronized &&
c.Name == remoteOsName && c.Version == remoteOsVersion)
c.Name == remoteOsName &&
c.Version == remoteOsVersion)
});
}
}
@@ -410,11 +421,13 @@ public static class Statistics
if(ctx.Filesystems.Any(c => !c.Synchronized))
{
foreach(string nvs in ctx.Filesystems.Where(c => !c.Synchronized).Select(c => c.Name).
foreach(string nvs in ctx.Filesystems.Where(c => !c.Synchronized).
Select(c => c.Name).
Distinct())
{
Filesystem existing =
ctx.Filesystems.FirstOrDefault(c => c.Synchronized && c.Name == nvs) ?? new Filesystem
ctx.Filesystems.FirstOrDefault(c => c.Synchronized && c.Name == nvs) ??
new Filesystem
{
Name = nvs,
Synchronized = true
@@ -447,11 +460,13 @@ public static class Statistics
if(ctx.MediaFormats.Any(c => !c.Synchronized))
{
foreach(string nvs in ctx.MediaFormats.Where(c => !c.Synchronized).Select(c => c.Name).
foreach(string nvs in ctx.MediaFormats.Where(c => !c.Synchronized).
Select(c => c.Name).
Distinct())
{
MediaFormat existing =
ctx.MediaFormats.FirstOrDefault(c => c.Synchronized && c.Name == nvs) ?? new MediaFormat
ctx.MediaFormats.FirstOrDefault(c => c.Synchronized && c.Name == nvs) ??
new MediaFormat
{
Name = nvs,
Synchronized = true
@@ -469,12 +484,12 @@ public static class Statistics
{
foreach(string nvs in ctx.Partitions.Where(c => !c.Synchronized).Select(c => c.Name).Distinct())
{
Partition existing =
ctx.Partitions.FirstOrDefault(c => c.Synchronized && c.Name == nvs) ?? new Partition
{
Name = nvs,
Synchronized = true
};
Partition existing = ctx.Partitions.FirstOrDefault(c => c.Synchronized && c.Name == nvs) ??
new Partition
{
Name = nvs,
Synchronized = true
};
existing.Count += (ulong)ctx.Partitions.LongCount(c => !c.Synchronized && c.Name == nvs);
@@ -520,7 +535,8 @@ public static class Statistics
ctx.Medias.Update(existing);
ctx.Medias.RemoveRange(ctx.Medias.Where(c => !c.Synchronized && c.Type == media &&
ctx.Medias.RemoveRange(ctx.Medias.Where(c => !c.Synchronized &&
c.Type == media &&
c.Real));
}
@@ -542,7 +558,8 @@ public static class Statistics
ctx.Medias.Update(existing);
ctx.Medias.RemoveRange(ctx.Medias.Where(c => !c.Synchronized && c.Type == media &&
ctx.Medias.RemoveRange(ctx.Medias.Where(c => !c.Synchronized &&
c.Type == media &&
!c.Real));
}
}
@@ -559,16 +576,19 @@ public static class Statistics
if(ctx.OperatingSystems.Any(c => !c.Synchronized))
{
foreach(string osName in ctx.OperatingSystems.Where(c => !c.Synchronized).Select(c => c.Name).
foreach(string osName in ctx.OperatingSystems.Where(c => !c.Synchronized).
Select(c => c.Name).
Distinct())
{
foreach(string osVersion in ctx.OperatingSystems.
Where(c => !c.Synchronized && c.Name == osName).
Select(c => c.Version).Distinct())
Select(c => c.Version).
Distinct())
{
OperatingSystem existing =
ctx.OperatingSystems.FirstOrDefault(c => c.Synchronized && c.Name == osName &&
c.Version == osVersion) ??
ctx.OperatingSystems.FirstOrDefault(c => c.Synchronized &&
c.Name == osName &&
c.Version == osVersion) ??
new OperatingSystem
{
Synchronized = true,
@@ -577,14 +597,15 @@ public static class Statistics
};
existing.Count +=
(ulong)ctx.OperatingSystems.LongCount(c => !c.Synchronized && c.Name == osName &&
c.Version == osVersion);
(ulong)ctx.OperatingSystems.LongCount(c => !c.Synchronized &&
c.Name == osName &&
c.Version == osVersion);
ctx.OperatingSystems.Update(existing);
ctx.OperatingSystems.RemoveRange(ctx.OperatingSystems.Where(c => !c.Synchronized &&
c.Name == osName &&
c.Version == osVersion));
c.Name == osName &&
c.Version == osVersion));
}
}
}
@@ -592,12 +613,14 @@ public static class Statistics
if(ctx.RemoteApplications.Any(c => !c.Synchronized))
{
foreach(string remoteAppName in ctx.RemoteApplications.Where(c => !c.Synchronized).
Select(c => c.Name).Distinct())
Select(c => c.Name).
Distinct())
{
foreach(string remoteAppVersion in ctx.RemoteApplications.
Where(c => !c.Synchronized &&
c.Name == remoteAppName).
Select(c => c.Version).Distinct())
Select(c => c.Version).
Distinct())
{
RemoteApplication existing =
ctx.RemoteApplications.FirstOrDefault(c => c.Synchronized &&
@@ -618,15 +641,16 @@ public static class Statistics
ctx.RemoteApplications.Update(existing);
ctx.RemoteApplications.RemoveRange(ctx.RemoteApplications.Where(c => !c.Synchronized &&
c.Name == remoteAppName &&
c.Version == remoteAppVersion));
c.Name == remoteAppName &&
c.Version == remoteAppVersion));
}
}
}
if(ctx.RemoteArchitectures.Any(c => !c.Synchronized))
{
foreach(string nvs in ctx.RemoteArchitectures.Where(c => !c.Synchronized).Select(c => c.Name).
foreach(string nvs in ctx.RemoteArchitectures.Where(c => !c.Synchronized).
Select(c => c.Name).
Distinct())
{
RemoteArchitecture existing =
@@ -643,16 +667,18 @@ public static class Statistics
ctx.RemoteArchitectures.Update(existing);
ctx.RemoteArchitectures.RemoveRange(ctx.RemoteArchitectures.Where(c => !c.Synchronized &&
c.Name == nvs));
c.Name == nvs));
}
}
foreach(string remoteOsName in ctx.RemoteOperatingSystems.Where(c => !c.Synchronized).
Select(c => c.Name).Distinct())
Select(c => c.Name).
Distinct())
{
foreach(string remoteOsVersion in ctx.RemoteOperatingSystems.
Where(c => !c.Synchronized && c.Name == remoteOsName).
Select(c => c.Version).Distinct())
Select(c => c.Version).
Distinct())
{
RemoteOperatingSystem existing =
ctx.RemoteOperatingSystems.FirstOrDefault(c => c.Synchronized &&
@@ -673,9 +699,9 @@ public static class Statistics
ctx.RemoteOperatingSystems.Update(existing);
ctx.RemoteOperatingSystems.RemoveRange(ctx.RemoteOperatingSystems.Where(c =>
!c.Synchronized &&
c.Name == remoteOsName &&
c.Version == remoteOsVersion));
!c.Synchronized &&
c.Name == remoteOsName &&
c.Version == remoteOsVersion));
}
}
@@ -876,8 +902,10 @@ public static class Statistics
using var ctx = AaruContext.Create(Settings.Settings.LocalDbPath);
if(ctx.SeenDevices.Any(d => d.Manufacturer == dev.Manufacturer && d.Model == dev.Model &&
d.Revision == dev.FirmwareRevision && d.Bus == deviceBus))
if(ctx.SeenDevices.Any(d => d.Manufacturer == dev.Manufacturer &&
d.Model == dev.Model &&
d.Revision == dev.FirmwareRevision &&
d.Bus == deviceBus))
return;
ctx.SeenDevices.Add(new DeviceStat

View File

@@ -120,136 +120,208 @@ public sealed class AaruContext : DbContext
base.OnModelCreating(modelBuilder);
modelBuilder.Entity("Aaru.CommonTypes.Metadata.Ata",
b => b.HasOne("Aaru.CommonTypes.Metadata.TestedMedia", "ReadCapabilities").WithMany().
HasForeignKey("ReadCapabilitiesId").OnDelete(DeleteBehavior.SetNull));
b => b.HasOne("Aaru.CommonTypes.Metadata.TestedMedia", "ReadCapabilities").
WithMany().
HasForeignKey("ReadCapabilitiesId").
OnDelete(DeleteBehavior.SetNull));
modelBuilder.Entity("Aaru.CommonTypes.Metadata.BlockDescriptor",
b => b.HasOne("Aaru.CommonTypes.Metadata.ScsiMode", null).WithMany("BlockDescriptors").
HasForeignKey("ScsiModeId").OnDelete(DeleteBehavior.Cascade));
b => b.HasOne("Aaru.CommonTypes.Metadata.ScsiMode", null).
WithMany("BlockDescriptors").
HasForeignKey("ScsiModeId").
OnDelete(DeleteBehavior.Cascade));
modelBuilder.Entity("Aaru.CommonTypes.Metadata.DensityCode",
b => b.HasOne("Aaru.CommonTypes.Metadata.SscSupportedMedia", null).WithMany("DensityCodes").
HasForeignKey("SscSupportedMediaId").OnDelete(DeleteBehavior.Cascade));
b => b.HasOne("Aaru.CommonTypes.Metadata.SscSupportedMedia", null).
WithMany("DensityCodes").
HasForeignKey("SscSupportedMediaId").
OnDelete(DeleteBehavior.Cascade));
modelBuilder.Entity("Aaru.CommonTypes.Metadata.Mmc",
b => b.HasOne("Aaru.CommonTypes.Metadata.MmcFeatures", "Features").WithMany().
HasForeignKey("FeaturesId").OnDelete(DeleteBehavior.SetNull));
b => b.HasOne("Aaru.CommonTypes.Metadata.MmcFeatures", "Features").
WithMany().
HasForeignKey("FeaturesId").
OnDelete(DeleteBehavior.SetNull));
modelBuilder.Entity("Aaru.CommonTypes.Metadata.Scsi", b =>
{
b.HasOne("Aaru.CommonTypes.Metadata.ScsiMode", "ModeSense").WithMany().HasForeignKey("ModeSenseId").
b.HasOne("Aaru.CommonTypes.Metadata.ScsiMode", "ModeSense").
WithMany().
HasForeignKey("ModeSenseId").
OnDelete(DeleteBehavior.SetNull);
b.HasOne("Aaru.CommonTypes.Metadata.Mmc", "MultiMediaDevice").WithMany().
HasForeignKey("MultiMediaDeviceId").OnDelete(DeleteBehavior.SetNull);
b.HasOne("Aaru.CommonTypes.Metadata.Mmc", "MultiMediaDevice").
WithMany().
HasForeignKey("MultiMediaDeviceId").
OnDelete(DeleteBehavior.SetNull);
b.HasOne("Aaru.CommonTypes.Metadata.TestedMedia", "ReadCapabilities").WithMany().
HasForeignKey("ReadCapabilitiesId").OnDelete(DeleteBehavior.SetNull);
b.HasOne("Aaru.CommonTypes.Metadata.TestedMedia", "ReadCapabilities").
WithMany().
HasForeignKey("ReadCapabilitiesId").
OnDelete(DeleteBehavior.SetNull);
b.HasOne("Aaru.CommonTypes.Metadata.Ssc", "SequentialDevice").WithMany().
HasForeignKey("SequentialDeviceId").OnDelete(DeleteBehavior.SetNull);
b.HasOne("Aaru.CommonTypes.Metadata.Ssc", "SequentialDevice").
WithMany().
HasForeignKey("SequentialDeviceId").
OnDelete(DeleteBehavior.SetNull);
});
modelBuilder.Entity("Aaru.CommonTypes.Metadata.ScsiPage", b =>
{
b.HasOne("Aaru.CommonTypes.Metadata.Scsi", null).WithMany("EVPDPages").HasForeignKey("ScsiId").
b.HasOne("Aaru.CommonTypes.Metadata.Scsi", null).
WithMany("EVPDPages").
HasForeignKey("ScsiId").
OnDelete(DeleteBehavior.SetNull);
b.HasOne("Aaru.CommonTypes.Metadata.ScsiMode", null).WithMany("ModePages").HasForeignKey("ScsiModeId").
b.HasOne("Aaru.CommonTypes.Metadata.ScsiMode", null).
WithMany("ModePages").
HasForeignKey("ScsiModeId").
OnDelete(DeleteBehavior.SetNull);
});
modelBuilder.Entity("Aaru.CommonTypes.Metadata.SscSupportedMedia", b =>
{
b.HasOne("Aaru.CommonTypes.Metadata.Ssc", null).WithMany("SupportedMediaTypes").HasForeignKey("SscId").
b.HasOne("Aaru.CommonTypes.Metadata.Ssc", null).
WithMany("SupportedMediaTypes").
HasForeignKey("SscId").
OnDelete(DeleteBehavior.SetNull);
b.HasOne("Aaru.CommonTypes.Metadata.TestedSequentialMedia", null).WithMany("SupportedMediaTypes").
HasForeignKey("TestedSequentialMediaId").OnDelete(DeleteBehavior.SetNull);
b.HasOne("Aaru.CommonTypes.Metadata.TestedSequentialMedia", null).
WithMany("SupportedMediaTypes").
HasForeignKey("TestedSequentialMediaId").
OnDelete(DeleteBehavior.SetNull);
});
modelBuilder.Entity("Aaru.CommonTypes.Metadata.SupportedDensity", b =>
{
b.HasOne("Aaru.CommonTypes.Metadata.Ssc", null).WithMany("SupportedDensities").HasForeignKey("SscId").
b.HasOne("Aaru.CommonTypes.Metadata.Ssc", null).
WithMany("SupportedDensities").
HasForeignKey("SscId").
OnDelete(DeleteBehavior.Cascade);
b.HasOne("Aaru.CommonTypes.Metadata.TestedSequentialMedia", null).WithMany("SupportedDensities").
HasForeignKey("TestedSequentialMediaId").OnDelete(DeleteBehavior.Cascade);
b.HasOne("Aaru.CommonTypes.Metadata.TestedSequentialMedia", null).
WithMany("SupportedDensities").
HasForeignKey("TestedSequentialMediaId").
OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Aaru.CommonTypes.Metadata.TestedMedia", b =>
{
b.HasOne("Aaru.CommonTypes.Metadata.Ata", null).WithMany("RemovableMedias").HasForeignKey("AtaId").
b.HasOne("Aaru.CommonTypes.Metadata.Ata", null).
WithMany("RemovableMedias").
HasForeignKey("AtaId").
OnDelete(DeleteBehavior.SetNull);
b.HasOne("Aaru.CommonTypes.Metadata.Chs", "CHS").WithMany().HasForeignKey("CHSId").
b.HasOne("Aaru.CommonTypes.Metadata.Chs", "CHS").
WithMany().
HasForeignKey("CHSId").
OnDelete(DeleteBehavior.SetNull);
b.HasOne("Aaru.CommonTypes.Metadata.Chs", "CurrentCHS").WithMany().HasForeignKey("CurrentCHSId").
b.HasOne("Aaru.CommonTypes.Metadata.Chs", "CurrentCHS").
WithMany().
HasForeignKey("CurrentCHSId").
OnDelete(DeleteBehavior.SetNull);
b.HasOne("Aaru.CommonTypes.Metadata.Mmc", null).WithMany("TestedMedia").HasForeignKey("MmcId").
b.HasOne("Aaru.CommonTypes.Metadata.Mmc", null).
WithMany("TestedMedia").
HasForeignKey("MmcId").
OnDelete(DeleteBehavior.Cascade);
b.HasOne("Aaru.CommonTypes.Metadata.Scsi", null).WithMany("RemovableMedias").HasForeignKey("ScsiId").
b.HasOne("Aaru.CommonTypes.Metadata.Scsi", null).
WithMany("RemovableMedias").
HasForeignKey("ScsiId").
OnDelete(DeleteBehavior.SetNull);
});
modelBuilder.Entity("Aaru.CommonTypes.Metadata.TestedSequentialMedia",
b => b.HasOne("Aaru.CommonTypes.Metadata.Ssc", null).WithMany("TestedMedia").
HasForeignKey("SscId").OnDelete(DeleteBehavior.SetNull));
b => b.HasOne("Aaru.CommonTypes.Metadata.Ssc", null).
WithMany("TestedMedia").
HasForeignKey("SscId").
OnDelete(DeleteBehavior.SetNull));
modelBuilder.Entity("Aaru.Database.Models.Device", b =>
{
b.HasOne("Aaru.CommonTypes.Metadata.Ata", "ATA").WithMany().HasForeignKey("ATAId").
b.HasOne("Aaru.CommonTypes.Metadata.Ata", "ATA").
WithMany().
HasForeignKey("ATAId").
OnDelete(DeleteBehavior.SetNull);
b.HasOne("Aaru.CommonTypes.Metadata.Ata", "ATAPI").WithMany().HasForeignKey("ATAPIId").
b.HasOne("Aaru.CommonTypes.Metadata.Ata", "ATAPI").
WithMany().
HasForeignKey("ATAPIId").
OnDelete(DeleteBehavior.SetNull);
b.HasOne("Aaru.CommonTypes.Metadata.FireWire", "FireWire").WithMany().HasForeignKey("FireWireId").
b.HasOne("Aaru.CommonTypes.Metadata.FireWire", "FireWire").
WithMany().
HasForeignKey("FireWireId").
OnDelete(DeleteBehavior.SetNull);
b.HasOne("Aaru.CommonTypes.Metadata.MmcSd", "MultiMediaCard").WithMany().HasForeignKey("MultiMediaCardId").
b.HasOne("Aaru.CommonTypes.Metadata.MmcSd", "MultiMediaCard").
WithMany().
HasForeignKey("MultiMediaCardId").
OnDelete(DeleteBehavior.SetNull);
b.HasOne("Aaru.CommonTypes.Metadata.Pcmcia", "PCMCIA").WithMany().HasForeignKey("PCMCIAId").
b.HasOne("Aaru.CommonTypes.Metadata.Pcmcia", "PCMCIA").
WithMany().
HasForeignKey("PCMCIAId").
OnDelete(DeleteBehavior.SetNull);
b.HasOne("Aaru.CommonTypes.Metadata.Scsi", "SCSI").WithMany().HasForeignKey("SCSIId").
b.HasOne("Aaru.CommonTypes.Metadata.Scsi", "SCSI").
WithMany().
HasForeignKey("SCSIId").
OnDelete(DeleteBehavior.SetNull);
b.HasOne("Aaru.CommonTypes.Metadata.MmcSd", "SecureDigital").WithMany().HasForeignKey("SecureDigitalId").
b.HasOne("Aaru.CommonTypes.Metadata.MmcSd", "SecureDigital").
WithMany().
HasForeignKey("SecureDigitalId").
OnDelete(DeleteBehavior.SetNull);
b.HasOne("Aaru.CommonTypes.Metadata.Usb", "USB").WithMany().HasForeignKey("USBId").
b.HasOne("Aaru.CommonTypes.Metadata.Usb", "USB").
WithMany().
HasForeignKey("USBId").
OnDelete(DeleteBehavior.SetNull);
});
modelBuilder.Entity("Aaru.Database.Models.Report", b =>
{
b.HasOne("Aaru.CommonTypes.Metadata.Ata", "ATA").WithMany().HasForeignKey("ATAId").
b.HasOne("Aaru.CommonTypes.Metadata.Ata", "ATA").
WithMany().
HasForeignKey("ATAId").
OnDelete(DeleteBehavior.SetNull);
b.HasOne("Aaru.CommonTypes.Metadata.Ata", "ATAPI").WithMany().HasForeignKey("ATAPIId").
b.HasOne("Aaru.CommonTypes.Metadata.Ata", "ATAPI").
WithMany().
HasForeignKey("ATAPIId").
OnDelete(DeleteBehavior.SetNull);
b.HasOne("Aaru.CommonTypes.Metadata.FireWire", "FireWire").WithMany().HasForeignKey("FireWireId").
b.HasOne("Aaru.CommonTypes.Metadata.FireWire", "FireWire").
WithMany().
HasForeignKey("FireWireId").
OnDelete(DeleteBehavior.SetNull);
b.HasOne("Aaru.CommonTypes.Metadata.MmcSd", "MultiMediaCard").WithMany().HasForeignKey("MultiMediaCardId").
b.HasOne("Aaru.CommonTypes.Metadata.MmcSd", "MultiMediaCard").
WithMany().
HasForeignKey("MultiMediaCardId").
OnDelete(DeleteBehavior.SetNull);
b.HasOne("Aaru.CommonTypes.Metadata.Pcmcia", "PCMCIA").WithMany().HasForeignKey("PCMCIAId").
b.HasOne("Aaru.CommonTypes.Metadata.Pcmcia", "PCMCIA").
WithMany().
HasForeignKey("PCMCIAId").
OnDelete(DeleteBehavior.SetNull);
b.HasOne("Aaru.CommonTypes.Metadata.Scsi", "SCSI").WithMany().HasForeignKey("SCSIId").
b.HasOne("Aaru.CommonTypes.Metadata.Scsi", "SCSI").
WithMany().
HasForeignKey("SCSIId").
OnDelete(DeleteBehavior.SetNull);
b.HasOne("Aaru.CommonTypes.Metadata.MmcSd", "SecureDigital").WithMany().HasForeignKey("SecureDigitalId").
b.HasOne("Aaru.CommonTypes.Metadata.MmcSd", "SecureDigital").
WithMany().
HasForeignKey("SecureDigitalId").
OnDelete(DeleteBehavior.SetNull);
b.HasOne("Aaru.CommonTypes.Metadata.Usb", "USB").WithMany().HasForeignKey("USBId").
b.HasOne("Aaru.CommonTypes.Metadata.Usb", "USB").
WithMany().
HasForeignKey("USBId").
OnDelete(DeleteBehavior.SetNull);
});

View File

@@ -63,12 +63,14 @@ public partial class Device
if((statusRegisters.Status & 0x23) == 0)
{
lba = (ulong)((statusRegisters.LbaHighCurrent << 16) + (statusRegisters.LbaMidCurrent << 8) +
lba = (ulong)((statusRegisters.LbaHighCurrent << 16) +
(statusRegisters.LbaMidCurrent << 8) +
statusRegisters.LbaLowCurrent);
lba <<= 24;
lba += (ulong)((statusRegisters.LbaHighPrevious << 16) + (statusRegisters.LbaMidPrevious << 8) +
lba += (ulong)((statusRegisters.LbaHighPrevious << 16) +
(statusRegisters.LbaMidPrevious << 8) +
statusRegisters.LbaLowPrevious);
}
@@ -246,12 +248,14 @@ public partial class Device
if((statusRegisters.Status & 0x23) == 0)
{
lba = (ulong)((statusRegisters.LbaHighCurrent << 16) + (statusRegisters.LbaMidCurrent << 8) +
lba = (ulong)((statusRegisters.LbaHighCurrent << 16) +
(statusRegisters.LbaMidCurrent << 8) +
statusRegisters.LbaLowCurrent);
lba <<= 24;
lba += (ulong)((statusRegisters.LbaHighPrevious << 16) + (statusRegisters.LbaMidPrevious << 8) +
lba += (ulong)((statusRegisters.LbaHighPrevious << 16) +
(statusRegisters.LbaMidPrevious << 8) +
statusRegisters.LbaLowPrevious);
}

View File

@@ -225,8 +225,7 @@ public partial class Device
Features.SeparatedFeatures features = Features.Separate(featureBuffer);
if(features.Descriptors?.Length != 1 ||
features.Descriptors[0].Code != 0x0108)
if(features.Descriptors?.Length != 1 || features.Descriptors[0].Code != 0x0108)
return dev;
Feature_0108? serialFeature = Features.Decode_0108(features.Descriptors[0].Data);

View File

@@ -116,8 +116,7 @@ public partial class Device
{
var aaruUri = new Uri(aaruRemote);
if(aaruUri.Scheme != "aaru" &&
aaruUri.Scheme != "dic")
if(aaruUri.Scheme != "aaru" && aaruUri.Scheme != "dic")
{
AaruConsole.ErrorWriteLine(Localization.Invalid_remote_URI);

View File

@@ -144,10 +144,7 @@ public partial class Device
if(sense)
return true;
if(buffer[0] != 0xA5 ||
buffer[1] != 0x5A ||
buffer[2] != 0x5A ||
buffer[3] != 0xA5)
if(buffer[0] != 0xA5 || buffer[1] != 0x5A || buffer[2] != 0x5A || buffer[3] != 0xA5)
return true;
for(var i = 4; i < 26; i += 2)

View File

@@ -683,11 +683,10 @@ public partial class Device
Error = LastError != 0;
AaruConsole.DebugWriteLine(SCSI_MODULE_NAME,
Localization.READ_READ_SUB_CHANNEL_MCN_Sense_1_Last_Error_2_took_0_ms,
duration, sense, LastError);
Localization.READ_READ_SUB_CHANNEL_MCN_Sense_1_Last_Error_2_took_0_ms, duration,
sense, LastError);
if(!sense &&
(buffer[8] & 0x80) == 0x80)
if(!sense && (buffer[8] & 0x80) == 0x80)
mcn = Encoding.ASCII.GetString(buffer, 9, 13);
return sense;
@@ -729,8 +728,7 @@ public partial class Device
READ_READ_SUB_CHANNEL_ISRC_Track_Number_1_Sense_2_Last_Error_3_took_0_ms,
duration, trackNumber, sense, LastError);
if(!sense &&
(buffer[8] & 0x80) == 0x80)
if(!sense && (buffer[8] & 0x80) == 0x80)
isrc = Encoding.ASCII.GetString(buffer, 9, 12);
return sense;

View File

@@ -90,8 +90,7 @@ public partial class Device
cdb[4] = (byte)((lba & 0xFF00) >> 8);
cdb[5] = (byte)(lba & 0xFF);
if(requested > 0 ||
scanLength > 1)
if(requested > 0 || scanLength > 1)
{
buffer = new byte[8];
buffer[0] = (byte)((requested & 0xFF000000) >> 24);

View File

@@ -74,7 +74,10 @@ public partial class Device
buffer = new byte[36];
senseBuffer = new byte[64];
byte[] cdb = { (byte)ScsiCommands.Inquiry, 0, 0, 0, 36, 0 };
byte[] cdb =
{
(byte)ScsiCommands.Inquiry, 0, 0, 0, 36, 0
};
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out bool sense);
@@ -86,7 +89,10 @@ public partial class Device
var pagesLength = (byte)(buffer[4] + 5);
cdb = new byte[] { (byte)ScsiCommands.Inquiry, 0, 0, 0, pagesLength, 0 };
cdb = new byte[]
{
(byte)ScsiCommands.Inquiry, 0, 0, 0, pagesLength, 0
};
buffer = new byte[pagesLength];
senseBuffer = new byte[64];
@@ -145,7 +151,10 @@ public partial class Device
buffer = new byte[36];
senseBuffer = new byte[64];
byte[] cdb = { (byte)ScsiCommands.Inquiry, 1, page, 0, 36, 0 };
byte[] cdb =
{
(byte)ScsiCommands.Inquiry, 1, page, 0, 36, 0
};
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
out bool sense);
@@ -161,7 +170,10 @@ public partial class Device
var pagesLength = (byte)(buffer[3] + 4);
cdb = new byte[] { (byte)ScsiCommands.Inquiry, 1, page, 0, pagesLength, 0 };
cdb = new byte[]
{
(byte)ScsiCommands.Inquiry, 1, page, 0, pagesLength, 0
};
buffer = new byte[pagesLength];
senseBuffer = new byte[64];
@@ -185,7 +197,10 @@ public partial class Device
{
senseBuffer = new byte[64];
byte[] cdb = { (byte)ScsiCommands.TestUnitReady, 0, 0, 0, 0, 0 };
byte[] cdb =
{
(byte)ScsiCommands.TestUnitReady, 0, 0, 0, 0, 0
};
byte[] buffer = Array.Empty<byte>();

View File

@@ -376,7 +376,8 @@ public partial class Device
/// <param name="duration">Duration.</param>
public bool Read16(out byte[] buffer, out byte[] senseBuffer, ulong objectId, uint blocks, uint blockSize,
uint timeout, out double duration) => Read16(out buffer, out senseBuffer, false, true, 0,
objectId, blocks, blockSize, timeout, out duration);
objectId, blocks, blockSize, timeout,
out duration);
/// <summary>Reads a number of fixed-length blocks starting at specified block from the specified partition</summary>
/// <param name="buffer">Buffer.</param>

View File

@@ -91,8 +91,7 @@ public partial class Device
if(readLong)
cdb[5] += 0x40;
if(!inhibitDma &&
!readLong)
if(!inhibitDma && !readLong)
buffer = transferLength == 0 ? new byte[256 * blockSize] : new byte[transferLength * blockSize];
else if(readLong)
{
@@ -172,8 +171,7 @@ public partial class Device
if(readLong)
cdb[9] += 0x40;
if(!inhibitDma &&
!readLong)
if(!inhibitDma && !readLong)
buffer = new byte[transferLength * blockSize];
else if(readLong)
{

View File

@@ -153,8 +153,7 @@ partial class Device
cdb[0] = (byte)ScsiCommands.AtaPassThrough16;
cdb[1] = (byte)((byte)protocol << 1 & 0x1E);
if(transferRegister != AtaTransferRegister.NoTransfer &&
protocol != AtaProtocol.NonData)
if(transferRegister != AtaTransferRegister.NoTransfer && protocol != AtaProtocol.NonData)
{
switch(protocol)
{
@@ -188,8 +187,7 @@ partial class Device
int error = SendScsiCommand(cdb, ref buffer, out byte[] senseBuffer, timeout,
AtaProtocolToScsiDirection(protocol), out duration, out sense);
if(senseBuffer.Length < 22 ||
senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C)
if(senseBuffer.Length < 22 || senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C)
return error;
errorRegisters.Error = senseBuffer[11];
@@ -226,8 +224,7 @@ partial class Device
cdb[0] = (byte)ScsiCommands.AtaPassThrough16;
cdb[1] = (byte)((byte)protocol << 1 & 0x1E);
if(transferRegister != AtaTransferRegister.NoTransfer &&
protocol != AtaProtocol.NonData)
if(transferRegister != AtaTransferRegister.NoTransfer && protocol != AtaProtocol.NonData)
{
switch(protocol)
{
@@ -261,8 +258,7 @@ partial class Device
int error = SendScsiCommand(cdb, ref buffer, out byte[] senseBuffer, timeout,
AtaProtocolToScsiDirection(protocol), out duration, out sense);
if(senseBuffer.Length < 22 ||
senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C)
if(senseBuffer.Length < 22 || senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C)
return error;
errorRegisters.Error = senseBuffer[11];
@@ -300,8 +296,7 @@ partial class Device
cdb[1] = (byte)((byte)protocol << 1 & 0x1E);
cdb[1] |= 0x01;
if(transferRegister != AtaTransferRegister.NoTransfer &&
protocol != AtaProtocol.NonData)
if(transferRegister != AtaTransferRegister.NoTransfer && protocol != AtaProtocol.NonData)
{
switch(protocol)
{
@@ -340,8 +335,7 @@ partial class Device
int error = SendScsiCommand(cdb, ref buffer, out byte[] senseBuffer, timeout,
AtaProtocolToScsiDirection(protocol), out duration, out sense);
if(senseBuffer.Length < 22 ||
senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C)
if(senseBuffer.Length < 22 || senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C)
return error;
errorRegisters.Error = senseBuffer[11];
@@ -612,8 +606,7 @@ partial class Device
int error = Marshal.GetLastWin32Error();
if(error != 13 &&
error != 30)
if(error != 13 && error != 30)
{
LastError = Marshal.GetLastWin32Error();
Error = true;

View File

@@ -382,8 +382,7 @@ partial class Device : Devices.Device
string possibleDir = Path.Combine(resolvedLink, "pcmcia_socket", subdirs[0]);
if(!File.Exists(possibleDir + "/card_type") ||
!File.Exists(possibleDir + "/cis"))
if(!File.Exists(possibleDir + "/card_type") || !File.Exists(possibleDir + "/cis"))
continue;
var cisFs = new FileStream(possibleDir + "/cis", FileMode.Open, FileAccess.Read);

View File

@@ -91,8 +91,7 @@ static class ListDevices
StreamReader sr;
if(File.Exists(Path.Combine(sysdevs[i], "device/vendor")) &&
string.IsNullOrEmpty(devices[i].Vendor))
if(File.Exists(Path.Combine(sysdevs[i], "device/vendor")) && string.IsNullOrEmpty(devices[i].Vendor))
{
sr = new StreamReader(Path.Combine(sysdevs[i], "device/vendor"), Encoding.ASCII);
devices[i].Vendor = sr.ReadLine()?.Trim();
@@ -109,15 +108,13 @@ static class ListDevices
else if(devices[i].Path.StartsWith("/dev/loop", StringComparison.CurrentCulture))
devices[i].Model = "Linux";
if(File.Exists(Path.Combine(sysdevs[i], "device/serial")) &&
string.IsNullOrEmpty(devices[i].Serial))
if(File.Exists(Path.Combine(sysdevs[i], "device/serial")) && string.IsNullOrEmpty(devices[i].Serial))
{
sr = new StreamReader(Path.Combine(sysdevs[i], "device/serial"), Encoding.ASCII);
devices[i].Serial = sr.ReadLine()?.Trim();
}
if(string.IsNullOrEmpty(devices[i].Vendor) ||
devices[i].Vendor == "ATA")
if(string.IsNullOrEmpty(devices[i].Vendor) || devices[i].Vendor == "ATA")
{
if(devices[i].Model != null)
{

View File

@@ -180,8 +180,7 @@ public partial class Device
ref command.buffer, out command.response, out double cmdDuration,
out bool cmdSense, timeout);
if(error == 0 &&
singleError != 0)
if(error == 0 && singleError != 0)
error = singleError;
duration += cmdDuration;

View File

@@ -62,8 +62,7 @@ public class Remote : IDisposable
/// <exception cref="IOException">Network error.</exception>
public Remote(Uri uri)
{
if(uri.Scheme != "aaru" &&
uri.Scheme != "dic")
if(uri.Scheme != "aaru" && uri.Scheme != "dic")
throw new ArgumentException(Localization.Invalid_remote_protocol, nameof(uri.Scheme));
_host = uri.DnsSafeHost;
@@ -102,8 +101,7 @@ public class Remote : IDisposable
AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian<AaruPacketHeader>(hdrBuf);
if(hdr.remote_id != Consts.REMOTE_ID ||
hdr.packet_id != Consts.PACKET_ID)
if(hdr.remote_id != Consts.REMOTE_ID || hdr.packet_id != Consts.PACKET_ID)
{
AaruConsole.ErrorWriteLine(Localization.Received_data_is_not_an_Aaru_Remote_Packet);
@@ -253,8 +251,7 @@ public class Remote : IDisposable
AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian<AaruPacketHeader>(hdrBuf);
if(hdr.remote_id != Consts.REMOTE_ID ||
hdr.packet_id != Consts.PACKET_ID)
if(hdr.remote_id != Consts.REMOTE_ID || hdr.packet_id != Consts.PACKET_ID)
{
AaruConsole.ErrorWriteLine(Localization.Received_data_is_not_an_Aaru_Remote_Packet);
@@ -347,8 +344,7 @@ public class Remote : IDisposable
AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian<AaruPacketHeader>(hdrBuf);
if(hdr.remote_id != Consts.REMOTE_ID ||
hdr.packet_id != Consts.PACKET_ID)
if(hdr.remote_id != Consts.REMOTE_ID || hdr.packet_id != Consts.PACKET_ID)
{
AaruConsole.ErrorWriteLine(Localization.Received_data_is_not_an_Aaru_Remote_Packet);
@@ -360,9 +356,8 @@ public class Remote : IDisposable
if(hdr.packetType != AaruPacketType.Nop)
{
AaruConsole.
ErrorWriteLine(
Localization.Remote_ListDevices_Expected_List_Devices_Response_Packet_got_packet_type_0,
hdr.packetType);
ErrorWriteLine(Localization.Remote_ListDevices_Expected_List_Devices_Response_Packet_got_packet_type_0,
hdr.packetType);
return Array.Empty<DeviceInfo>();
}
@@ -470,8 +465,7 @@ public class Remote : IDisposable
AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian<AaruPacketHeader>(hdrBuf);
if(hdr.remote_id != Consts.REMOTE_ID ||
hdr.packet_id != Consts.PACKET_ID)
if(hdr.remote_id != Consts.REMOTE_ID || hdr.packet_id != Consts.PACKET_ID)
{
AaruConsole.ErrorWriteLine(Localization.Received_data_is_not_an_Aaru_Remote_Packet);
lastError = -1;
@@ -590,8 +584,7 @@ public class Remote : IDisposable
AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian<AaruPacketHeader>(hdrBuf);
if(hdr.remote_id != Consts.REMOTE_ID ||
hdr.packet_id != Consts.PACKET_ID)
if(hdr.remote_id != Consts.REMOTE_ID || hdr.packet_id != Consts.PACKET_ID)
{
AaruConsole.ErrorWriteLine(Localization.Received_data_is_not_an_Aaru_Remote_Packet);
@@ -700,8 +693,7 @@ public class Remote : IDisposable
AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian<AaruPacketHeader>(hdrBuf);
if(hdr.remote_id != Consts.REMOTE_ID ||
hdr.packet_id != Consts.PACKET_ID)
if(hdr.remote_id != Consts.REMOTE_ID || hdr.packet_id != Consts.PACKET_ID)
{
AaruConsole.ErrorWriteLine(Localization.Received_data_is_not_an_Aaru_Remote_Packet);
@@ -809,8 +801,7 @@ public class Remote : IDisposable
AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian<AaruPacketHeader>(hdrBuf);
if(hdr.remote_id != Consts.REMOTE_ID ||
hdr.packet_id != Consts.PACKET_ID)
if(hdr.remote_id != Consts.REMOTE_ID || hdr.packet_id != Consts.PACKET_ID)
{
AaruConsole.ErrorWriteLine(Localization.Received_data_is_not_an_Aaru_Remote_Packet);
@@ -919,8 +910,7 @@ public class Remote : IDisposable
AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian<AaruPacketHeader>(hdrBuf);
if(hdr.remote_id != Consts.REMOTE_ID ||
hdr.packet_id != Consts.PACKET_ID)
if(hdr.remote_id != Consts.REMOTE_ID || hdr.packet_id != Consts.PACKET_ID)
{
AaruConsole.ErrorWriteLine(Localization.Received_data_is_not_an_Aaru_Remote_Packet);
@@ -1035,8 +1025,7 @@ public class Remote : IDisposable
AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian<AaruPacketHeader>(hdrBuf);
if(hdr.remote_id != Consts.REMOTE_ID ||
hdr.packet_id != Consts.PACKET_ID)
if(hdr.remote_id != Consts.REMOTE_ID || hdr.packet_id != Consts.PACKET_ID)
{
AaruConsole.ErrorWriteLine(Localization.Received_data_is_not_an_Aaru_Remote_Packet);
@@ -1117,8 +1106,7 @@ public class Remote : IDisposable
AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian<AaruPacketHeader>(hdrBuf);
if(hdr.remote_id != Consts.REMOTE_ID ||
hdr.packet_id != Consts.PACKET_ID)
if(hdr.remote_id != Consts.REMOTE_ID || hdr.packet_id != Consts.PACKET_ID)
{
AaruConsole.ErrorWriteLine(Localization.Received_data_is_not_an_Aaru_Remote_Packet);
@@ -1197,8 +1185,7 @@ public class Remote : IDisposable
AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian<AaruPacketHeader>(hdrBuf);
if(hdr.remote_id != Consts.REMOTE_ID ||
hdr.packet_id != Consts.PACKET_ID)
if(hdr.remote_id != Consts.REMOTE_ID || hdr.packet_id != Consts.PACKET_ID)
{
AaruConsole.ErrorWriteLine(Localization.Received_data_is_not_an_Aaru_Remote_Packet);
@@ -1327,8 +1314,7 @@ public class Remote : IDisposable
AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian<AaruPacketHeader>(hdrBuf);
if(hdr.remote_id != Consts.REMOTE_ID ||
hdr.packet_id != Consts.PACKET_ID)
if(hdr.remote_id != Consts.REMOTE_ID || hdr.packet_id != Consts.PACKET_ID)
{
AaruConsole.ErrorWriteLine(Localization.Received_data_is_not_an_Aaru_Remote_Packet);
@@ -1421,8 +1407,7 @@ public class Remote : IDisposable
AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian<AaruPacketHeader>(hdrBuf);
if(hdr.remote_id != Consts.REMOTE_ID ||
hdr.packet_id != Consts.PACKET_ID)
if(hdr.remote_id != Consts.REMOTE_ID || hdr.packet_id != Consts.PACKET_ID)
{
AaruConsole.ErrorWriteLine(Localization.Received_data_is_not_an_Aaru_Remote_Packet);
@@ -1504,8 +1489,7 @@ public class Remote : IDisposable
AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian<AaruPacketHeader>(hdrBuf);
if(hdr.remote_id != Consts.REMOTE_ID ||
hdr.packet_id != Consts.PACKET_ID)
if(hdr.remote_id != Consts.REMOTE_ID || hdr.packet_id != Consts.PACKET_ID)
{
AaruConsole.ErrorWriteLine(Localization.Received_data_is_not_an_Aaru_Remote_Packet);
@@ -1635,17 +1619,17 @@ public class Remote : IDisposable
int off = tmp.Length;
foreach(AaruCmdSdhci cmd in commands.Select(command => new AaruCmdSdhci
{
application = command.isApplication,
argument = command.argument,
block_size = command.blockSize,
blocks = command.blocks,
buf_len = (uint)(command.buffer?.Length ?? 0),
command = command.command,
flags = command.flags,
timeout = timeout,
write = command.write
}))
{
application = command.isApplication,
argument = command.argument,
block_size = command.blockSize,
blocks = command.blocks,
buf_len = (uint)(command.buffer?.Length ?? 0),
command = command.command,
flags = command.flags,
timeout = timeout,
write = command.write
}))
{
tmp = Marshal.StructureToByteArrayLittleEndian(cmd);
Array.Copy(tmp, 0, buf, off, tmp.Length);
@@ -1654,7 +1638,7 @@ public class Remote : IDisposable
}
foreach(Devices.Device.MmcSingleCommand command in
commands.Where(command => (command.buffer?.Length ?? 0) != 0))
commands.Where(command => (command.buffer?.Length ?? 0) != 0))
{
Array.Copy(command.buffer, 0, buf, off, command.buffer.Length);
@@ -1683,8 +1667,7 @@ public class Remote : IDisposable
AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian<AaruPacketHeader>(hdrBuf);
if(hdr.remote_id != Consts.REMOTE_ID ||
hdr.packet_id != Consts.PACKET_ID)
if(hdr.remote_id != Consts.REMOTE_ID || hdr.packet_id != Consts.PACKET_ID)
{
AaruConsole.ErrorWriteLine(Localization.Received_data_is_not_an_Aaru_Remote_Packet);
@@ -1731,8 +1714,7 @@ public class Remote : IDisposable
command.response = cmdRes.response;
duration += cmdRes.duration;
if(cmdRes.error_no != 0 &&
error == 0)
if(cmdRes.error_no != 0 && error == 0)
error = (int)cmdRes.error_no;
if(cmdRes.sense != 0)
@@ -1827,8 +1809,7 @@ public class Remote : IDisposable
AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian<AaruPacketHeader>(hdrBuf);
if(hdr.remote_id != Consts.REMOTE_ID ||
hdr.packet_id != Consts.PACKET_ID)
if(hdr.remote_id != Consts.REMOTE_ID || hdr.packet_id != Consts.PACKET_ID)
{
AaruConsole.ErrorWriteLine(Localization.Received_data_is_not_an_Aaru_Remote_Packet);
@@ -1931,8 +1912,7 @@ public class Remote : IDisposable
AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian<AaruPacketHeader>(hdrBuf);
if(hdr.remote_id != Consts.REMOTE_ID ||
hdr.packet_id != Consts.PACKET_ID)
if(hdr.remote_id != Consts.REMOTE_ID || hdr.packet_id != Consts.PACKET_ID)
{
AaruConsole.ErrorWriteLine(Localization.Received_data_is_not_an_Aaru_Remote_Packet);

View File

@@ -525,35 +525,28 @@ partial class Device
commandDescriptor.responseType = 0;
if(flags.HasFlag(MmcFlags.ResponseR1) ||
flags.HasFlag(MmcFlags.ResponseSpiR1))
if(flags.HasFlag(MmcFlags.ResponseR1) || flags.HasFlag(MmcFlags.ResponseSpiR1))
commandDescriptor.responseType = SdResponseType.R1;
if(flags.HasFlag(MmcFlags.ResponseR1B) ||
flags.HasFlag(MmcFlags.ResponseSpiR1B))
if(flags.HasFlag(MmcFlags.ResponseR1B) || flags.HasFlag(MmcFlags.ResponseSpiR1B))
commandDescriptor.responseType = SdResponseType.R1b;
if(flags.HasFlag(MmcFlags.ResponseR2) ||
flags.HasFlag(MmcFlags.ResponseSpiR2))
if(flags.HasFlag(MmcFlags.ResponseR2) || flags.HasFlag(MmcFlags.ResponseSpiR2))
commandDescriptor.responseType = SdResponseType.R2;
if(flags.HasFlag(MmcFlags.ResponseR3) ||
flags.HasFlag(MmcFlags.ResponseSpiR3))
if(flags.HasFlag(MmcFlags.ResponseR3) || flags.HasFlag(MmcFlags.ResponseSpiR3))
commandDescriptor.responseType = SdResponseType.R3;
if(flags.HasFlag(MmcFlags.ResponseR4) ||
flags.HasFlag(MmcFlags.ResponseSpiR4))
if(flags.HasFlag(MmcFlags.ResponseR4) || flags.HasFlag(MmcFlags.ResponseSpiR4))
commandDescriptor.responseType = SdResponseType.R4;
if(flags.HasFlag(MmcFlags.ResponseR5) ||
flags.HasFlag(MmcFlags.ResponseSpiR5))
if(flags.HasFlag(MmcFlags.ResponseR5) || flags.HasFlag(MmcFlags.ResponseSpiR5))
commandDescriptor.responseType = SdResponseType.R5;
if(flags.HasFlag(MmcFlags.ResponseR6))
commandDescriptor.responseType = SdResponseType.R6;
var commandB =
new byte[commandData.size + commandData.protocolArgumentSize + commandData.deviceDataBufferSize];
var commandB = new byte[commandData.size + commandData.protocolArgumentSize + commandData.deviceDataBufferSize];
Array.Copy(buffer, 0, commandB, commandData.size + commandData.protocolArgumentSize, buffer.Length);
IntPtr hBuf = Marshal.AllocHGlobal(commandB.Length);
@@ -611,8 +604,7 @@ partial class Device
command.argument, command.blockSize, command.blocks, ref command.buffer,
out command.response, out double cmdDuration, out bool cmdSense, timeout);
if(error == 0 &&
singleError != 0)
if(error == 0 && singleError != 0)
error = singleError;
duration += cmdDuration;

View File

@@ -112,8 +112,7 @@ partial class Device : Devices.Device
Marshal.Copy(descriptorPtr, descriptorB, 0, 1000);
if(!hasError &&
error == 0)
if(!hasError && error == 0)
{
var descriptor = new StorageDeviceDescriptor
{
@@ -235,12 +234,9 @@ partial class Device : Devices.Device
sdBuffer = new byte[4];
dev.LastError =
dev.SendMmcCommand(
dev._cachedScr != null
? (MmcCommands)SecureDigitalCommands.SendOperatingCondition
: MmcCommands.SendOpCond,
false, true, MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 | MmcFlags.CommandBcr, 0,
4, 1, ref sdBuffer, out _, out _, out sense);
dev.SendMmcCommand(dev._cachedScr != null ? (MmcCommands)SecureDigitalCommands.SendOperatingCondition : MmcCommands.SendOpCond,
false, true, MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 | MmcFlags.CommandBcr, 0,
4, 1, ref sdBuffer, out _, out _, out sense);
if(!sense)
{
@@ -292,10 +288,10 @@ partial class Device : Devices.Device
// I have to search for USB disks, floppies and CD-ROMs as separate device types
foreach(string devGuid in new[]
{
Usb.GUID_DEVINTERFACE_FLOPPY, Usb.GUID_DEVINTERFACE_CDROM, Usb.GUID_DEVINTERFACE_DISK,
Usb.GUID_DEVINTERFACE_TAPE
})
{
Usb.GUID_DEVINTERFACE_FLOPPY, Usb.GUID_DEVINTERFACE_CDROM, Usb.GUID_DEVINTERFACE_DISK,
Usb.GUID_DEVINTERFACE_TAPE
})
{
usbDevice = Usb.FindDrivePath(devicePath, devGuid);

View File

@@ -104,8 +104,7 @@ static class ListDevices
string physId = devId;
// TODO: This can be done better
if(devId.Length == 2 &&
devId[1] == ':')
if(devId.Length == 2 && devId[1] == ':')
physId = "\\\\?\\" + devId;
SafeFileHandle fd = Extern.CreateFile(physId, 0, FileShare.Read | FileShare.Write, IntPtr.Zero,
@@ -182,8 +181,7 @@ static class ListDevices
info.Serial = HexStringToString(info.Serial).Trim();
}
if(string.IsNullOrEmpty(info.Vendor) ||
info.Vendor == "ATA")
if(string.IsNullOrEmpty(info.Vendor) || info.Vendor == "ATA")
{
string[] pieces = info.Model?.Split(' ');

View File

@@ -60,8 +60,7 @@ public sealed partial class AODOS
return false;
// Does AO-DOS support any other kind of disk?
if(imagePlugin.Info.Sectors != 800 &&
imagePlugin.Info.Sectors != 1600)
if(imagePlugin.Info.Sectors != 800 && imagePlugin.Info.Sectors != 1600)
return false;
ErrorNumber errno = imagePlugin.ReadSector(0, out byte[] sector);

View File

@@ -103,7 +103,8 @@ public sealed partial class APFS
sbInformation.AppendFormat(Localization._0_bytes_per_block, nxSb.blockSize).AppendLine();
sbInformation.AppendFormat(Localization.Container_has_0_bytes_in_1_blocks,
nxSb.containerBlocks * nxSb.blockSize, nxSb.containerBlocks).AppendLine();
nxSb.containerBlocks * nxSb.blockSize, nxSb.containerBlocks).
AppendLine();
information = sbInformation.ToString();

View File

@@ -82,9 +82,7 @@ public sealed partial class AcornADFS
AaruConsole.DebugWriteLine(MODULE_NAME, "oldChk0 = {0}", oldChk0);
// According to documentation map1 MUST start on sector 1. On ADFS-D it starts at 0x100, not on sector 1 (0x400)
if(oldMap0.checksum == oldChk0 &&
oldMap1.checksum != oldChk1 &&
sector.Length >= 512)
if(oldMap0.checksum == oldChk0 && oldMap1.checksum != oldChk1 && sector.Length >= 512)
{
errno = imagePlugin.ReadSector(0, out sector);
@@ -215,8 +213,7 @@ public sealed partial class AcornADFS
AaruConsole.DebugWriteLine(MODULE_NAME, "bootChk = {0}", bootChk);
AaruConsole.DebugWriteLine(MODULE_NAME, "bBlock.checksum = {0}", bootSector[0x1FF]);
if(newChk == sector[0] &&
newChk != 0)
if(newChk == sector[0] && newChk != 0)
{
NewMap nmap = Marshal.ByteArrayToStructureLittleEndian<NewMap>(sector);
drSb = nmap.discRecord;
@@ -240,8 +237,7 @@ public sealed partial class AcornADFS
if(drSb.log2secsize is < 8 or > 10)
return false;
if(drSb.idlen < drSb.log2secsize + 3 ||
drSb.idlen > 19)
if(drSb.idlen < drSb.log2secsize + 3 || drSb.idlen > 19)
return false;
if(drSb.disc_size_high >> drSb.log2secsize != 0)
@@ -295,9 +291,7 @@ public sealed partial class AcornADFS
OldMapSector1 oldMap1 = Marshal.ByteArrayToStructureLittleEndian<OldMapSector1>(sector);
// According to documentation map1 MUST start on sector 1. On ADFS-D it starts at 0x100, not on sector 1 (0x400)
if(oldMap0.checksum == oldChk0 &&
oldMap1.checksum != oldChk1 &&
sector.Length >= 512)
if(oldMap0.checksum == oldChk0 && oldMap1.checksum != oldChk1 && sector.Length >= 512)
{
errno = imagePlugin.ReadSector(0, out sector);
@@ -355,8 +349,7 @@ public sealed partial class AcornADFS
OldDirectory oldRoot = Marshal.ByteArrayToStructureLittleEndian<OldDirectory>(sector);
if(oldRoot.header.magic == OLD_DIR_MAGIC &&
oldRoot.tail.magic == OLD_DIR_MAGIC)
if(oldRoot.header.magic == OLD_DIR_MAGIC && oldRoot.tail.magic == OLD_DIR_MAGIC)
namebytes = oldRoot.tail.name;
else
{
@@ -384,8 +377,7 @@ public sealed partial class AcornADFS
oldRoot = Marshal.ByteArrayToStructureLittleEndian<OldDirectory>(sector);
if(oldRoot.header.magic == OLD_DIR_MAGIC &&
oldRoot.tail.magic == OLD_DIR_MAGIC)
if(oldRoot.header.magic == OLD_DIR_MAGIC && oldRoot.tail.magic == OLD_DIR_MAGIC)
namebytes = oldRoot.tail.name;
else
{
@@ -406,8 +398,7 @@ public sealed partial class AcornADFS
NewDirectory newRoot = Marshal.ByteArrayToStructureLittleEndian<NewDirectory>(sector);
if(newRoot.header.magic == NEW_DIR_MAGIC &&
newRoot.tail.magic == NEW_DIR_MAGIC)
if(newRoot.header.magic == NEW_DIR_MAGIC && newRoot.tail.magic == NEW_DIR_MAGIC)
namebytes = newRoot.tail.title;
}
}
@@ -467,8 +458,7 @@ public sealed partial class AcornADFS
AaruConsole.DebugWriteLine(MODULE_NAME, "bootChk = {0}", bootChk);
AaruConsole.DebugWriteLine(MODULE_NAME, "bBlock.checksum = {0}", bootSector[0x1FF]);
if(newChk == sector[0] &&
newChk != 0)
if(newChk == sector[0] && newChk != 0)
{
NewMap nmap = Marshal.ByteArrayToStructureLittleEndian<NewMap>(sector);
drSb = nmap.discRecord;
@@ -509,8 +499,7 @@ public sealed partial class AcornADFS
if(drSb.log2secsize is < 8 or > 10)
return;
if(drSb.idlen < drSb.log2secsize + 3 ||
drSb.idlen > 19)
if(drSb.idlen < drSb.log2secsize + 3 || drSb.idlen > 19)
return;
if(drSb.disc_size_high >> drSb.log2secsize != 0)

View File

@@ -80,8 +80,7 @@ public sealed partial class AmigaDOSPlugin
}
// Not FFS or MuFS?
if((bblk.diskType & FFS_MASK) != FFS_MASK &&
(bblk.diskType & MUFS_MASK) != MUFS_MASK)
if((bblk.diskType & FFS_MASK) != FFS_MASK && (bblk.diskType & MUFS_MASK) != MUFS_MASK)
return false;
// Clear checksum on sector
@@ -158,8 +157,7 @@ public sealed partial class AmigaDOSPlugin
rblk.sec_type = BigEndianBitConverter.ToUInt32(sector, sector.Length - 4);
AaruConsole.DebugWriteLine(MODULE_NAME, "rblk.sec_type = {0}", rblk.sec_type);
if(rblk.sec_type == SUBTYPE_ROOT &&
rblk.checksum == rsum)
if(rblk.sec_type == SUBTYPE_ROOT && rblk.checksum == rsum)
return true;
}
@@ -256,8 +254,7 @@ public sealed partial class AmigaDOSPlugin
rootBlk.sec_type = BigEndianBitConverter.ToUInt32(rootBlockSector, rootBlockSector.Length - 4);
AaruConsole.DebugWriteLine(MODULE_NAME, "rootBlk.sec_type = {0}", rootBlk.sec_type);
if(rootBlk.sec_type != SUBTYPE_ROOT ||
rootBlk.checksum != rsum)
if(rootBlk.sec_type != SUBTYPE_ROOT || rootBlk.checksum != rsum)
continue;
errno = imagePlugin.ReadSectors(rootPtr, sectorsPerBlock, out rootBlockSector);
@@ -339,15 +336,13 @@ public sealed partial class AmigaDOSPlugin
if(rootBlk.bitmapFlag == 0xFFFFFFFF)
sbInformation.AppendLine(Localization.Volume_bitmap_is_valid);
if(rootBlk.bitmapExtensionBlock != 0x00000000 &&
rootBlk.bitmapExtensionBlock != 0xFFFFFFFF)
if(rootBlk.bitmapExtensionBlock != 0x00000000 && rootBlk.bitmapExtensionBlock != 0xFFFFFFFF)
{
sbInformation.AppendFormat(Localization.Bitmap_extension_at_block_0, rootBlk.bitmapExtensionBlock).
AppendLine();
}
if((bootBlk.diskType & 0xFF) == 4 ||
(bootBlk.diskType & 0xFF) == 5)
if((bootBlk.diskType & 0xFF) == 4 || (bootBlk.diskType & 0xFF) == 5)
sbInformation.AppendFormat(Localization.Directory_cache_starts_at_block_0, rootBlk.extension).AppendLine();
ulong blocks = (partition.End - partition.Start + 1) * imagePlugin.Info.SectorSize / blockSize;

View File

@@ -37,8 +37,7 @@ static partial class AppleCommon
{
internal static string GetBootBlockInformation(byte[] bbSector, Encoding encoding)
{
if(bbSector is null ||
bbSector.Length < 0x100)
if(bbSector is null || bbSector.Length < 0x100)
return null;
BootBlock bb = Marshal.ByteArrayToStructureBigEndian<BootBlock>(bbSector);
@@ -60,9 +59,9 @@ static partial class AppleCommon
if((bb.bbVersion & 0x2000) > 0)
{
sb.
AppendFormat(
Localization.System_heap_will_be_extended_by_0_bytes_and_a_1_fraction_of_the_available_RAM,
bb.bbSysHeapExtra, bb.bbSysHeapFract).AppendLine();
AppendFormat(Localization.System_heap_will_be_extended_by_0_bytes_and_a_1_fraction_of_the_available_RAM,
bb.bbSysHeapExtra, bb.bbSysHeapFract).
AppendLine();
}
}
}
@@ -94,10 +93,12 @@ static partial class AppleCommon
AppendLine();
sb.AppendFormat(Localization.Startup_screen_filename_0,
StringHandlers.PascalToString(bb.bbScreenName, encoding)).AppendLine();
StringHandlers.PascalToString(bb.bbScreenName, encoding)).
AppendLine();
sb.AppendFormat(Localization.First_program_to_execute_at_boot_0,
StringHandlers.PascalToString(bb.bbHelloName, encoding)).AppendLine();
StringHandlers.PascalToString(bb.bbHelloName, encoding)).
AppendLine();
sb.AppendFormat(Localization.Clipboard_filename_0, StringHandlers.PascalToString(bb.bbScrapName, encoding)).
AppendLine();

View File

@@ -78,7 +78,9 @@ public sealed partial class AppleDOS : IReadOnlyFilesystem
static Dictionary<string, string> GetDefaultOptions() => new()
{
{ "debug", false.ToString() }
{
"debug", false.ToString()
}
};
#region Caches

View File

@@ -60,8 +60,7 @@ public sealed partial class AppleDOS
if(!_mounted)
return ErrorNumber.AccessDenied;
if(!string.IsNullOrEmpty(path) &&
string.Compare(path, "/", StringComparison.OrdinalIgnoreCase) != 0)
if(!string.IsNullOrEmpty(path) && string.Compare(path, "/", StringComparison.OrdinalIgnoreCase) != 0)
return ErrorNumber.NotSupported;
var contents = _catalogCache.Keys.ToList();
@@ -130,8 +129,7 @@ public sealed partial class AppleDOS
_fileTypeCache = new Dictionary<string, byte>();
_lockedFiles = new List<string>();
if(lba == 0 ||
lba > _device.Info.Sectors)
if(lba == 0 || lba > _device.Info.Sectors)
return ErrorNumber.InvalidArgument;
while(lba != 0)
@@ -167,8 +165,7 @@ public sealed partial class AppleDOS
_catalogCache.TryAdd(filename, ts);
_fileTypeCache.TryAdd(filename, (byte)(entry.typeAndFlags & 0x7F));
if((entry.typeAndFlags & 0x80) == 0x80 &&
!_lockedFiles.Contains(filename))
if((entry.typeAndFlags & 0x80) == 0x80 && !_lockedFiles.Contains(filename))
_lockedFiles.Add(filename);
}

View File

@@ -50,7 +50,10 @@ public sealed partial class AppleDOS
if(!_mounted)
return ErrorNumber.AccessDenied;
string[] pathElements = path.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
string[] pathElements = path.Split(new[]
{
'/'
}, StringSplitOptions.RemoveEmptyEntries);
if(pathElements.Length != 1)
return ErrorNumber.NotSupported;
@@ -66,9 +69,10 @@ public sealed partial class AppleDOS
if(_lockedFiles.Contains(filename))
attributes |= FileAttributes.ReadOnly;
if(_debug && (string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$Vtoc", StringComparison.InvariantCulture) == 0))
if(_debug &&
(string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$Vtoc", StringComparison.InvariantCulture) == 0))
attributes |= FileAttributes.System;
return ErrorNumber.NoError;
@@ -81,7 +85,10 @@ public sealed partial class AppleDOS
if(!_mounted)
return ErrorNumber.AccessDenied;
string[] pathElements = path.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
string[] pathElements = path.Split(new[]
{
'/'
}, StringSplitOptions.RemoveEmptyEntries);
if(pathElements.Length != 1)
return ErrorNumber.NotSupported;
@@ -92,9 +99,10 @@ public sealed partial class AppleDOS
if(filename.Length > 30)
return ErrorNumber.NameTooLong;
if(_debug && (string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$Vtoc", StringComparison.InvariantCulture) == 0))
if(_debug &&
(string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$Vtoc", StringComparison.InvariantCulture) == 0))
{
if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0)
file = _catalogBlocks;
@@ -150,8 +158,7 @@ public sealed partial class AppleDOS
if(!_mounted)
return ErrorNumber.AccessDenied;
if(buffer is null ||
buffer.Length < length)
if(buffer is null || buffer.Length < length)
return ErrorNumber.InvalidArgument;
if(node is not AppleDosFileNode mynode)
@@ -177,7 +184,10 @@ public sealed partial class AppleDOS
if(!_mounted)
return ErrorNumber.AccessDenied;
string[] pathElements = path.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
string[] pathElements = path.Split(new[]
{
'/'
}, StringSplitOptions.RemoveEmptyEntries);
if(pathElements.Length != 1)
return ErrorNumber.NotSupported;
@@ -195,9 +205,10 @@ public sealed partial class AppleDOS
_fileSizeCache.TryGetValue(filename, out int fileSize);
GetAttributes(path, out FileAttributes attrs);
if(_debug && (string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$Vtoc", StringComparison.InvariantCulture) == 0))
if(_debug &&
(string.Compare(path, "$", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 ||
string.Compare(path, "$Vtoc", StringComparison.InvariantCulture) == 0))
{
if(string.Compare(path, "$", StringComparison.InvariantCulture) == 0)
stat.Length = _catalogBlocks.Length;
@@ -225,7 +236,10 @@ public sealed partial class AppleDOS
ErrorNumber CacheFile(string path)
{
string[] pathElements = path.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
string[] pathElements = path.Split(new[]
{
'/'
}, StringSplitOptions.RemoveEmptyEntries);
if(pathElements.Length != 1)
return ErrorNumber.NotSupported;

Some files were not shown because too many files have changed in this diff Show More