[Refactor] Fix indentation issues.

This commit is contained in:
2025-11-24 19:38:40 +00:00
parent 5774885431
commit 8331fba1e4
43 changed files with 1700 additions and 1751 deletions

View File

@@ -51,15 +51,11 @@ public sealed partial class Symbian
if(currentFile > maxFiles) return; if(currentFile > maxFiles) return;
char[] tabulationChars = new char[conditionLevel]; var tabulationChars = new char[conditionLevel];
for(int i = 0; i < conditionLevel; i++) tabulationChars[i] = '\t'; for(var i = 0; i < conditionLevel; i++) tabulationChars[i] = '\t';
string tabulation = new(tabulationChars); string tabulation = new(tabulationChars);
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, "Seeking to {0} for parsing of file {1} of {2}", offset, currentFile, maxFiles);
"Seeking to {0} for parsing of file {1} of {2}",
offset,
currentFile,
maxFiles);
br.BaseStream.Seek(offset, SeekOrigin.Begin); br.BaseStream.Seek(offset, SeekOrigin.Begin);
var recordType = (FileRecordType)br.ReadUInt32(); var recordType = (FileRecordType)br.ReadUInt32();
@@ -119,10 +115,10 @@ public sealed partial class Symbian
} }
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"Found file for \"{0}\" with length {1} at {2}", "Found file for \"{0}\" with length {1} at {2}",
decodedFileRecord.destinationName, decodedFileRecord.destinationName,
decodedFileRecord.length, decodedFileRecord.length,
decodedFileRecord.pointer); decodedFileRecord.pointer);
_files.Add(decodedFileRecord); _files.Add(decodedFileRecord);
@@ -323,7 +319,7 @@ public sealed partial class Symbian
var decodedFileRecords = new DecodedFileRecord[languages.Count]; var decodedFileRecords = new DecodedFileRecord[languages.Count];
for(int i = 0; i < languages.Count; i++) for(var i = 0; i < languages.Count; i++)
{ {
decodedFileRecords[i].type = multipleFileRecord.record.type; decodedFileRecords[i].type = multipleFileRecord.record.type;
decodedFileRecords[i].details = multipleFileRecord.record.details; decodedFileRecords[i].details = multipleFileRecord.record.details;
@@ -488,7 +484,7 @@ public sealed partial class Symbian
optionsLineRecord.options = new OptionRecord[(int)optionsLineRecord.numberOfOptions]; optionsLineRecord.options = new OptionRecord[(int)optionsLineRecord.numberOfOptions];
for(int i = 0; i < optionsLineRecord.numberOfOptions; i++) for(var i = 0; i < optionsLineRecord.numberOfOptions; i++)
{ {
optionsLineRecord.options[i] = new OptionRecord(); optionsLineRecord.options[i] = new OptionRecord();
@@ -508,7 +504,7 @@ public sealed partial class Symbian
offset = (uint)br.BaseStream.Position; offset = (uint)br.BaseStream.Position;
for(int j = 0; j < languages.Count; j++) for(var j = 0; j < languages.Count; j++)
{ {
br.BaseStream.Seek(optionsLineRecord.options[i].pointers[j], SeekOrigin.Begin); br.BaseStream.Seek(optionsLineRecord.options[i].pointers[j], SeekOrigin.Begin);
buffer = br.ReadBytes((int)optionsLineRecord.options[i].lengths[j]); buffer = br.ReadBytes((int)optionsLineRecord.options[i].lengths[j]);
@@ -527,7 +523,7 @@ public sealed partial class Symbian
conditionLevel--; conditionLevel--;
tabulationChars = new char[conditionLevel]; tabulationChars = new char[conditionLevel];
for(int i = 0; i < conditionLevel; i++) tabulationChars[i] = '\t'; for(var i = 0; i < conditionLevel; i++) tabulationChars[i] = '\t';
tabulation = new string(tabulationChars); tabulation = new string(tabulationChars);
conditionalRecord = new ConditionalRecord conditionalRecord = new ConditionalRecord
@@ -552,7 +548,7 @@ public sealed partial class Symbian
break; break;
case FileRecordType.ElseIf: case FileRecordType.ElseIf:
tabulationChars = new char[conditionLevel - 1]; tabulationChars = new char[conditionLevel - 1];
for(int i = 0; i < conditionLevel - 1; i++) tabulationChars[i] = '\t'; for(var i = 0; i < conditionLevel - 1; i++) tabulationChars[i] = '\t';
tabulation = new string(tabulationChars); tabulation = new string(tabulationChars);
conditionalRecord = new ConditionalRecord conditionalRecord = new ConditionalRecord
@@ -577,7 +573,7 @@ public sealed partial class Symbian
break; break;
case FileRecordType.Else: case FileRecordType.Else:
tabulationChars = new char[conditionLevel - 1]; tabulationChars = new char[conditionLevel - 1];
for(int i = 0; i < conditionLevel - 1; i++) tabulationChars[i] = '\t'; for(var i = 0; i < conditionLevel - 1; i++) tabulationChars[i] = '\t';
tabulation = new string(tabulationChars); tabulation = new string(tabulationChars);
offset = (uint)(br.BaseStream.Position + Marshal.SizeOf<ConditionalEndRecord>()); offset = (uint)(br.BaseStream.Position + Marshal.SizeOf<ConditionalEndRecord>());

View File

@@ -82,8 +82,8 @@ public static class CdChecksums
{ {
case 2448: case 2448:
{ {
byte[] subchannel = new byte[96]; var subchannel = new byte[96];
byte[] channel = new byte[2352]; var channel = new byte[2352];
Array.Copy(buffer, 0, channel, 0, 2352); Array.Copy(buffer, 0, channel, 0, 2352);
Array.Copy(buffer, 2352, subchannel, 0, 96); Array.Copy(buffer, 2352, subchannel, 0, 96);
@@ -121,7 +121,7 @@ public static class CdChecksums
for(uint i = 0; i < 256; i++) for(uint i = 0; i < 256; i++)
{ {
uint edc = i; uint edc = i;
uint j = (uint)(i << 1 ^ ((i & 0x80) == 0x80 ? 0x11D : 0)); var j = (uint)(i << 1 ^ ((i & 0x80) == 0x80 ? 0x11D : 0));
_eccFTable[i] = (byte)j; _eccFTable[i] = (byte)j;
_eccBTable[i ^ j] = (byte)i; _eccBTable[i ^ j] = (byte)i;
@@ -197,15 +197,15 @@ public static class CdChecksums
{ {
//AaruLogging.DebugWriteLine(MODULE_NAME, "Mode 0 sector at address {0:X2}:{1:X2}:{2:X2}", //AaruLogging.DebugWriteLine(MODULE_NAME, "Mode 0 sector at address {0:X2}:{1:X2}:{2:X2}",
// channel[0x00C], channel[0x00D], channel[0x00E]); // channel[0x00C], channel[0x00D], channel[0x00E]);
for(int i = 0x010; i < 0x930; i++) for(var i = 0x010; i < 0x930; i++)
{ {
if(channel[i] == 0x00) continue; if(channel[i] == 0x00) continue;
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"Mode 0 sector with error at address: {0:X2}:{1:X2}:{2:X2}", "Mode 0 sector with error at address: {0:X2}:{1:X2}:{2:X2}",
channel[0x00C], channel[0x00C],
channel[0x00D], channel[0x00D],
channel[0x00E]); channel[0x00E]);
return false; return false;
} }
@@ -225,19 +225,19 @@ public static class CdChecksums
channel[0x81A] != 0x00 || channel[0x81A] != 0x00 ||
channel[0x81B] != 0x00: channel[0x81B] != 0x00:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"Mode 1 sector with data in reserved bytes at address: {0:X2}:{1:X2}:{2:X2}", "Mode 1 sector with data in reserved bytes at address: {0:X2}:{1:X2}:{2:X2}",
channel[0x00C], channel[0x00C],
channel[0x00D], channel[0x00D],
channel[0x00E]); channel[0x00E]);
return false; return false;
case 0x01: case 0x01:
{ {
byte[] address = new byte[4]; var address = new byte[4];
byte[] data = new byte[2060]; var data = new byte[2060];
byte[] data2 = new byte[2232]; var data2 = new byte[2232];
byte[] eccP = new byte[172]; var eccP = new byte[172];
byte[] eccQ = new byte[104]; var eccQ = new byte[104];
Array.Copy(channel, 0x0C, address, 0, 4); Array.Copy(channel, 0x0C, address, 0, 4);
Array.Copy(channel, 0x10, data, 0, 2060); Array.Copy(channel, 0x10, data, 0, 2060);
@@ -254,22 +254,22 @@ public static class CdChecksums
if(failedEccP) if(failedEccP)
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"Mode 1 sector at address: {0:X2}:{1:X2}:{2:X2}, fails ECC P check", "Mode 1 sector at address: {0:X2}:{1:X2}:{2:X2}, fails ECC P check",
channel[0x00C], channel[0x00C],
channel[0x00D], channel[0x00D],
channel[0x00E]); channel[0x00E]);
} }
if(failedEccQ) if(failedEccQ)
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"Mode 1 sector at address: {0:X2}:{1:X2}:{2:X2}, fails ECC Q check", "Mode 1 sector at address: {0:X2}:{1:X2}:{2:X2}, fails ECC Q check",
channel[0x00C], channel[0x00C],
channel[0x00D], channel[0x00D],
channel[0x00E]); channel[0x00E]);
} }
uint storedEdc = BitConverter.ToUInt32(channel, 0x810); var storedEdc = BitConverter.ToUInt32(channel, 0x810);
uint calculatedEdc = ComputeEdc(0, channel, 0x810); uint calculatedEdc = ComputeEdc(0, channel, 0x810);
correctEdc = calculatedEdc == storedEdc; correctEdc = calculatedEdc == storedEdc;
@@ -277,12 +277,12 @@ public static class CdChecksums
if(calculatedEdc == storedEdc) return !failedEccP && !failedEccQ; if(calculatedEdc == storedEdc) return !failedEccP && !failedEccQ;
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"Mode 1 sector at address: {0:X2}:{1:X2}:{2:X2}, got CRC 0x{3:X8} expected 0x{4:X8}", "Mode 1 sector at address: {0:X2}:{1:X2}:{2:X2}, got CRC 0x{3:X8} expected 0x{4:X8}",
channel[0x00C], channel[0x00C],
channel[0x00D], channel[0x00D],
channel[0x00E], channel[0x00E],
calculatedEdc, calculatedEdc,
storedEdc); storedEdc);
return false; return false;
} }
@@ -292,7 +292,7 @@ public static class CdChecksums
{ {
//AaruLogging.DebugWriteLine(MODULE_NAME, "Mode 2 sector at address {0:X2}:{1:X2}:{2:X2}", //AaruLogging.DebugWriteLine(MODULE_NAME, "Mode 2 sector at address {0:X2}:{1:X2}:{2:X2}",
// channel[0x00C], channel[0x00D], channel[0x00E]); // channel[0x00C], channel[0x00D], channel[0x00E]);
byte[] mode2Sector = new byte[channel.Length - 0x10]; var mode2Sector = new byte[channel.Length - 0x10];
Array.Copy(channel, 0x10, mode2Sector, 0, mode2Sector.Length); Array.Copy(channel, 0x10, mode2Sector, 0, mode2Sector.Length);
if((channel[0x012] & 0x20) == 0x20) // mode 2 form 2 if((channel[0x012] & 0x20) == 0x20) // mode 2 form 2
@@ -303,13 +303,13 @@ public static class CdChecksums
channel[0x013] != channel[0x017]) channel[0x013] != channel[0x017])
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"Subheader copies differ in mode 2 form 2 sector at address: {0:X2}:{1:X2}:{2:X2}", "Subheader copies differ in mode 2 form 2 sector at address: {0:X2}:{1:X2}:{2:X2}",
channel[0x00C], channel[0x00C],
channel[0x00D], channel[0x00D],
channel[0x00E]); channel[0x00E]);
} }
uint storedEdc = BitConverter.ToUInt32(mode2Sector, 0x91C); var storedEdc = BitConverter.ToUInt32(mode2Sector, 0x91C);
// No CRC stored! // No CRC stored!
if(storedEdc == 0x00000000) return true; if(storedEdc == 0x00000000) return true;
@@ -321,12 +321,12 @@ public static class CdChecksums
if(calculatedEdc == storedEdc) return true; if(calculatedEdc == storedEdc) return true;
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"Mode 2 form 2 sector at address: {0:X2}:{1:X2}:{2:X2}, got CRC 0x{3:X8} expected 0x{4:X8}", "Mode 2 form 2 sector at address: {0:X2}:{1:X2}:{2:X2}, got CRC 0x{3:X8} expected 0x{4:X8}",
channel[0x00C], channel[0x00C],
channel[0x00D], channel[0x00D],
channel[0x00E], channel[0x00E],
calculatedEdc, calculatedEdc,
storedEdc); storedEdc);
return false; return false;
} }
@@ -338,15 +338,15 @@ public static class CdChecksums
channel[0x013] != channel[0x017]) channel[0x013] != channel[0x017])
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"Subheader copies differ in mode 2 form 1 sector at address: {0:X2}:{1:X2}:{2:X2}", "Subheader copies differ in mode 2 form 1 sector at address: {0:X2}:{1:X2}:{2:X2}",
channel[0x00C], channel[0x00C],
channel[0x00D], channel[0x00D],
channel[0x00E]); channel[0x00E]);
} }
byte[] address = new byte[4]; var address = new byte[4];
byte[] eccP = new byte[172]; var eccP = new byte[172];
byte[] eccQ = new byte[104]; var eccQ = new byte[104];
Array.Copy(mode2Sector, 0x80C, eccP, 0, 172); Array.Copy(mode2Sector, 0x80C, eccP, 0, 172);
Array.Copy(mode2Sector, 0x8B8, eccQ, 0, 104); Array.Copy(mode2Sector, 0x8B8, eccQ, 0, 104);
@@ -360,22 +360,22 @@ public static class CdChecksums
if(failedEccP) if(failedEccP)
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"Mode 2 form 1 sector at address: {0:X2}:{1:X2}:{2:X2}, fails ECC P check", "Mode 2 form 1 sector at address: {0:X2}:{1:X2}:{2:X2}, fails ECC P check",
channel[0x00C], channel[0x00C],
channel[0x00D], channel[0x00D],
channel[0x00E]); channel[0x00E]);
} }
if(failedEccQ) if(failedEccQ)
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"Mode 2 form 1 sector at address: {0:X2}:{1:X2}:{2:X2}, fails ECC Q check", "Mode 2 form 1 sector at address: {0:X2}:{1:X2}:{2:X2}, fails ECC Q check",
channel[0x00C], channel[0x00C],
channel[0x00D], channel[0x00D],
channel[0x00E]); channel[0x00E]);
} }
uint storedEdc = BitConverter.ToUInt32(mode2Sector, 0x808); var storedEdc = BitConverter.ToUInt32(mode2Sector, 0x808);
uint calculatedEdc = ComputeEdc(0, mode2Sector, 0x808); uint calculatedEdc = ComputeEdc(0, mode2Sector, 0x808);
correctEdc = calculatedEdc == storedEdc; correctEdc = calculatedEdc == storedEdc;
@@ -383,23 +383,23 @@ public static class CdChecksums
if(calculatedEdc == storedEdc) return !failedEccP && !failedEccQ; if(calculatedEdc == storedEdc) return !failedEccP && !failedEccQ;
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"Mode 2 sector at address: {0:X2}:{1:X2}:{2:X2}, got CRC 0x{3:X8} expected 0x{4:X8}", "Mode 2 sector at address: {0:X2}:{1:X2}:{2:X2}, got CRC 0x{3:X8} expected 0x{4:X8}",
channel[0x00C], channel[0x00C],
channel[0x00D], channel[0x00D],
channel[0x00E], channel[0x00E],
calculatedEdc, calculatedEdc,
storedEdc); storedEdc);
return false; return false;
} }
} }
default: default:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"Unknown mode {0} sector at address: {1:X2}:{2:X2}:{3:X2}", "Unknown mode {0} sector at address: {1:X2}:{2:X2}:{3:X2}",
channel[0x00F], channel[0x00F],
channel[0x00C], channel[0x00C],
channel[0x00D], channel[0x00D],
channel[0x00E]); channel[0x00E]);
return null; return null;
} }
@@ -407,7 +407,7 @@ public static class CdChecksums
static uint ComputeEdc(uint edc, IReadOnlyList<byte> src, int size) static uint ComputeEdc(uint edc, IReadOnlyList<byte> src, int size)
{ {
int pos = 0; var pos = 0;
for(; size > 0; size--) edc = edc >> 8 ^ _edcTable[(edc ^ src[pos++]) & 0xFF]; for(; size > 0; size--) edc = edc >> 8 ^ _edcTable[(edc ^ src[pos++]) & 0xFF];
@@ -416,22 +416,22 @@ public static class CdChecksums
static bool? CheckCdSectorSubChannel(IReadOnlyList<byte> subchannel) static bool? CheckCdSectorSubChannel(IReadOnlyList<byte> subchannel)
{ {
bool? status = true; bool? status = true;
byte[] qSubChannel = new byte[12]; var qSubChannel = new byte[12];
byte[] cdTextPack1 = new byte[18]; var cdTextPack1 = new byte[18];
byte[] cdTextPack2 = new byte[18]; var cdTextPack2 = new byte[18];
byte[] cdTextPack3 = new byte[18]; var cdTextPack3 = new byte[18];
byte[] cdTextPack4 = new byte[18]; var cdTextPack4 = new byte[18];
byte[] cdSubRwPack1 = new byte[24]; var cdSubRwPack1 = new byte[24];
byte[] cdSubRwPack2 = new byte[24]; var cdSubRwPack2 = new byte[24];
byte[] cdSubRwPack3 = new byte[24]; var cdSubRwPack3 = new byte[24];
byte[] cdSubRwPack4 = new byte[24]; var cdSubRwPack4 = new byte[24];
int i = 0; var i = 0;
for(int j = 0; j < 12; j++) qSubChannel[j] = 0; for(var j = 0; j < 12; j++) qSubChannel[j] = 0;
for(int j = 0; j < 18; j++) for(var j = 0; j < 18; j++)
{ {
cdTextPack1[j] = 0; cdTextPack1[j] = 0;
cdTextPack2[j] = 0; cdTextPack2[j] = 0;
@@ -439,7 +439,7 @@ public static class CdChecksums
cdTextPack4[j] = 0; cdTextPack4[j] = 0;
} }
for(int j = 0; j < 24; j++) for(var j = 0; j < 24; j++)
{ {
cdSubRwPack1[j] = 0; cdSubRwPack1[j] = 0;
cdSubRwPack2[j] = 0; cdSubRwPack2[j] = 0;
@@ -447,7 +447,7 @@ public static class CdChecksums
cdSubRwPack4[j] = 0; cdSubRwPack4[j] = 0;
} }
for(int j = 0; j < 12; j++) for(var j = 0; j < 12; j++)
{ {
qSubChannel[j] = (byte)(qSubChannel[j] | (subchannel[i++] & 0x40) << 1); qSubChannel[j] = (byte)(qSubChannel[j] | (subchannel[i++] & 0x40) << 1);
qSubChannel[j] = (byte)(qSubChannel[j] | subchannel[i++] & 0x40); qSubChannel[j] = (byte)(qSubChannel[j] | subchannel[i++] & 0x40);
@@ -461,7 +461,7 @@ public static class CdChecksums
i = 0; i = 0;
for(int j = 0; j < 18; j++) for(var j = 0; j < 18; j++)
{ {
cdTextPack1[j] = (byte)(cdTextPack1[j] | (subchannel[i++] & 0x3F) << 2); cdTextPack1[j] = (byte)(cdTextPack1[j] | (subchannel[i++] & 0x3F) << 2);
@@ -476,7 +476,7 @@ public static class CdChecksums
cdTextPack1[j] = (byte)(cdTextPack1[j] | subchannel[i++] & 0x3F); cdTextPack1[j] = (byte)(cdTextPack1[j] | subchannel[i++] & 0x3F);
} }
for(int j = 0; j < 18; j++) for(var j = 0; j < 18; j++)
{ {
cdTextPack2[j] = (byte)(cdTextPack2[j] | (subchannel[i++] & 0x3F) << 2); cdTextPack2[j] = (byte)(cdTextPack2[j] | (subchannel[i++] & 0x3F) << 2);
@@ -491,7 +491,7 @@ public static class CdChecksums
cdTextPack2[j] = (byte)(cdTextPack2[j] | subchannel[i++] & 0x3F); cdTextPack2[j] = (byte)(cdTextPack2[j] | subchannel[i++] & 0x3F);
} }
for(int j = 0; j < 18; j++) for(var j = 0; j < 18; j++)
{ {
cdTextPack3[j] = (byte)(cdTextPack3[j] | (subchannel[i++] & 0x3F) << 2); cdTextPack3[j] = (byte)(cdTextPack3[j] | (subchannel[i++] & 0x3F) << 2);
@@ -506,7 +506,7 @@ public static class CdChecksums
cdTextPack3[j] = (byte)(cdTextPack3[j] | subchannel[i++] & 0x3F); cdTextPack3[j] = (byte)(cdTextPack3[j] | subchannel[i++] & 0x3F);
} }
for(int j = 0; j < 18; j++) for(var j = 0; j < 18; j++)
{ {
cdTextPack4[j] = (byte)(cdTextPack4[j] | (subchannel[i++] & 0x3F) << 2); cdTextPack4[j] = (byte)(cdTextPack4[j] | (subchannel[i++] & 0x3F) << 2);
@@ -523,13 +523,13 @@ public static class CdChecksums
i = 0; i = 0;
for(int j = 0; j < 24; j++) cdSubRwPack1[j] = (byte)(subchannel[i++] & 0x3F); for(var j = 0; j < 24; j++) cdSubRwPack1[j] = (byte)(subchannel[i++] & 0x3F);
for(int j = 0; j < 24; j++) cdSubRwPack2[j] = (byte)(subchannel[i++] & 0x3F); for(var j = 0; j < 24; j++) cdSubRwPack2[j] = (byte)(subchannel[i++] & 0x3F);
for(int j = 0; j < 24; j++) cdSubRwPack3[j] = (byte)(subchannel[i++] & 0x3F); for(var j = 0; j < 24; j++) cdSubRwPack3[j] = (byte)(subchannel[i++] & 0x3F);
for(int j = 0; j < 24; j++) cdSubRwPack4[j] = (byte)(subchannel[i++] & 0x3F); for(var j = 0; j < 24; j++) cdSubRwPack4[j] = (byte)(subchannel[i++] & 0x3F);
switch(cdSubRwPack1[0]) switch(cdSubRwPack1[0])
{ {
@@ -563,41 +563,38 @@ public static class CdChecksums
break; break;
default: default:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.Detected_unknown_Pack_type_in_subchannel_mode_0_item_1, Localization.Detected_unknown_Pack_type_in_subchannel_mode_0_item_1,
Convert.ToString(cdSubRwPack1[0] & 0x38, 2), Convert.ToString(cdSubRwPack1[0] & 0x38, 2),
Convert.ToString(cdSubRwPack1[0] & 0x07, 2)); Convert.ToString(cdSubRwPack1[0] & 0x07, 2));
break; break;
} }
ushort qSubChannelCrc = BigEndianBitConverter.ToUInt16(qSubChannel, 10); var qSubChannelCrc = BigEndianBitConverter.ToUInt16(qSubChannel, 10);
byte[] qSubChannelForCrc = new byte[10]; var qSubChannelForCrc = new byte[10];
Array.Copy(qSubChannel, 0, qSubChannelForCrc, 0, 10); Array.Copy(qSubChannel, 0, qSubChannelForCrc, 0, 10);
ushort calculatedQcrc = CRC16CcittContext.Calculate(qSubChannelForCrc); ushort calculatedQcrc = CRC16CcittContext.Calculate(qSubChannelForCrc);
if(qSubChannelCrc != calculatedQcrc) if(qSubChannelCrc != calculatedQcrc)
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, Localization.Q_subchannel_CRC_0_expected_1, calculatedQcrc, qSubChannelCrc);
Localization.Q_subchannel_CRC_0_expected_1,
calculatedQcrc,
qSubChannelCrc);
status = false; status = false;
} }
if((cdTextPack1[0] & 0x80) == 0x80) if((cdTextPack1[0] & 0x80) == 0x80)
{ {
ushort cdTextPack1Crc = BigEndianBitConverter.ToUInt16(cdTextPack1, 16); var cdTextPack1Crc = BigEndianBitConverter.ToUInt16(cdTextPack1, 16);
byte[] cdTextPack1ForCrc = new byte[16]; var cdTextPack1ForCrc = new byte[16];
Array.Copy(cdTextPack1, 0, cdTextPack1ForCrc, 0, 16); Array.Copy(cdTextPack1, 0, cdTextPack1ForCrc, 0, 16);
ushort calculatedCdtp1Crc = CRC16CcittContext.Calculate(cdTextPack1ForCrc); ushort calculatedCdtp1Crc = CRC16CcittContext.Calculate(cdTextPack1ForCrc);
if(cdTextPack1Crc != calculatedCdtp1Crc && cdTextPack1Crc != 0) if(cdTextPack1Crc != calculatedCdtp1Crc && cdTextPack1Crc != 0)
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.CD_Text_Pack_one_CRC_0_expected_1, Localization.CD_Text_Pack_one_CRC_0_expected_1,
cdTextPack1Crc, cdTextPack1Crc,
calculatedCdtp1Crc); calculatedCdtp1Crc);
status = false; status = false;
} }
@@ -605,22 +602,22 @@ public static class CdChecksums
if((cdTextPack2[0] & 0x80) == 0x80) if((cdTextPack2[0] & 0x80) == 0x80)
{ {
ushort cdTextPack2Crc = BigEndianBitConverter.ToUInt16(cdTextPack2, 16); var cdTextPack2Crc = BigEndianBitConverter.ToUInt16(cdTextPack2, 16);
byte[] cdTextPack2ForCrc = new byte[16]; var cdTextPack2ForCrc = new byte[16];
Array.Copy(cdTextPack2, 0, cdTextPack2ForCrc, 0, 16); Array.Copy(cdTextPack2, 0, cdTextPack2ForCrc, 0, 16);
ushort calculatedCdtp2Crc = CRC16CcittContext.Calculate(cdTextPack2ForCrc); ushort calculatedCdtp2Crc = CRC16CcittContext.Calculate(cdTextPack2ForCrc);
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.Cyclic_CDTP2_0_Calc_CDTP2_1, Localization.Cyclic_CDTP2_0_Calc_CDTP2_1,
cdTextPack2Crc, cdTextPack2Crc,
calculatedCdtp2Crc); calculatedCdtp2Crc);
if(cdTextPack2Crc != calculatedCdtp2Crc && cdTextPack2Crc != 0) if(cdTextPack2Crc != calculatedCdtp2Crc && cdTextPack2Crc != 0)
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.CD_Text_Pack_two_CRC_0_expected_1, Localization.CD_Text_Pack_two_CRC_0_expected_1,
cdTextPack2Crc, cdTextPack2Crc,
calculatedCdtp2Crc); calculatedCdtp2Crc);
status = false; status = false;
} }
@@ -628,22 +625,22 @@ public static class CdChecksums
if((cdTextPack3[0] & 0x80) == 0x80) if((cdTextPack3[0] & 0x80) == 0x80)
{ {
ushort cdTextPack3Crc = BigEndianBitConverter.ToUInt16(cdTextPack3, 16); var cdTextPack3Crc = BigEndianBitConverter.ToUInt16(cdTextPack3, 16);
byte[] cdTextPack3ForCrc = new byte[16]; var cdTextPack3ForCrc = new byte[16];
Array.Copy(cdTextPack3, 0, cdTextPack3ForCrc, 0, 16); Array.Copy(cdTextPack3, 0, cdTextPack3ForCrc, 0, 16);
ushort calculatedCdtp3Crc = CRC16CcittContext.Calculate(cdTextPack3ForCrc); ushort calculatedCdtp3Crc = CRC16CcittContext.Calculate(cdTextPack3ForCrc);
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.Cyclic_CDTP3_0_Calc_CDTP3_1, Localization.Cyclic_CDTP3_0_Calc_CDTP3_1,
cdTextPack3Crc, cdTextPack3Crc,
calculatedCdtp3Crc); calculatedCdtp3Crc);
if(cdTextPack3Crc != calculatedCdtp3Crc && cdTextPack3Crc != 0) if(cdTextPack3Crc != calculatedCdtp3Crc && cdTextPack3Crc != 0)
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.CD_Text_Pack_three_CRC_0_expected_1, Localization.CD_Text_Pack_three_CRC_0_expected_1,
cdTextPack3Crc, cdTextPack3Crc,
calculatedCdtp3Crc); calculatedCdtp3Crc);
status = false; status = false;
} }
@@ -651,22 +648,19 @@ public static class CdChecksums
if((cdTextPack4[0] & 0x80) != 0x80) return status; if((cdTextPack4[0] & 0x80) != 0x80) return status;
ushort cdTextPack4Crc = BigEndianBitConverter.ToUInt16(cdTextPack4, 16); var cdTextPack4Crc = BigEndianBitConverter.ToUInt16(cdTextPack4, 16);
byte[] cdTextPack4ForCrc = new byte[16]; var cdTextPack4ForCrc = new byte[16];
Array.Copy(cdTextPack4, 0, cdTextPack4ForCrc, 0, 16); Array.Copy(cdTextPack4, 0, cdTextPack4ForCrc, 0, 16);
ushort calculatedCdtp4Crc = CRC16CcittContext.Calculate(cdTextPack4ForCrc); ushort calculatedCdtp4Crc = CRC16CcittContext.Calculate(cdTextPack4ForCrc);
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, Localization.Cyclic_CDTP4_0_Calc_CDTP4_1, cdTextPack4Crc, calculatedCdtp4Crc);
Localization.Cyclic_CDTP4_0_Calc_CDTP4_1,
cdTextPack4Crc,
calculatedCdtp4Crc);
if(cdTextPack4Crc == calculatedCdtp4Crc || cdTextPack4Crc == 0) return status; if(cdTextPack4Crc == calculatedCdtp4Crc || cdTextPack4Crc == 0) return status;
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.CD_Text_Pack_four_CRC_0_expected_1, Localization.CD_Text_Pack_four_CRC_0_expected_1,
cdTextPack4Crc, cdTextPack4Crc,
calculatedCdtp4Crc); calculatedCdtp4Crc);
return false; return false;
} }

View File

@@ -194,7 +194,7 @@ public class ReedSolomon
{ {
int i; int i;
int mask = 1; var mask = 1;
_alphaTo[_mm] = 0; _alphaTo[_mm] = 0;
for(i = 0; i < _mm; i++) for(i = 0; i < _mm; i++)
@@ -299,9 +299,8 @@ public class ReedSolomon
for(i = _kk - 1; i >= 0; i--) for(i = _kk - 1; i >= 0; i--)
{ {
if(_mm != 8) if(_mm != 8)
{ if(data[i] > _nn)
if(data[i] > _nn) return -1; /* Illegal symbol */ return -1; /* Illegal symbol */
}
int feedback = _indexOf[data[i] ^ bb[_nn - _kk - 1]]; int feedback = _indexOf[data[i] ^ bb[_nn - _kk - 1]];
@@ -355,26 +354,25 @@ public class ReedSolomon
throw new UnauthorizedAccessException(Localization.Trying_to_calculate_RS_without_initializing); throw new UnauthorizedAccessException(Localization.Trying_to_calculate_RS_without_initializing);
erasPos = new int[_nn - _kk]; erasPos = new int[_nn - _kk];
int i, j; int i, j;
int q, tmp; int q, tmp;
int[] recd = new int[_nn]; var recd = new int[_nn];
int[] lambda = new int[_nn - _kk + 1]; /* Err+Eras Locator poly */ var lambda = new int[_nn - _kk + 1]; /* Err+Eras Locator poly */
int[] s = new int[_nn - _kk + 1]; /* syndrome poly */ var s = new int[_nn - _kk + 1]; /* syndrome poly */
int[] b = new int[_nn - _kk + 1]; var b = new int[_nn - _kk + 1];
int[] t = new int[_nn - _kk + 1]; var t = new int[_nn - _kk + 1];
int[] omega = new int[_nn - _kk + 1]; var omega = new int[_nn - _kk + 1];
int[] root = new int[_nn - _kk]; var root = new int[_nn - _kk];
int[] reg = new int[_nn - _kk + 1]; var reg = new int[_nn - _kk + 1];
int[] loc = new int[_nn - _kk]; var loc = new int[_nn - _kk];
int count; int count;
/* data[] is in polynomial form, copy and convert to index form */ /* data[] is in polynomial form, copy and convert to index form */
for(i = _nn - 1; i >= 0; i--) for(i = _nn - 1; i >= 0; i--)
{ {
if(_mm != 8) if(_mm != 8)
{ if(data[i] > _nn)
if(data[i] > _nn) return -1; /* Illegal symbol */ return -1; /* Illegal symbol */
}
recd[i] = _indexOf[data[i]]; recd[i] = _indexOf[data[i]];
} }
@@ -382,16 +380,15 @@ public class ReedSolomon
/* first form the syndromes; i.e., evaluate recd(x) at roots of g(x) /* first form the syndromes; i.e., evaluate recd(x) at roots of g(x)
* namely @**(B0+i), i = 0, ... ,(NN-KK-1) * namely @**(B0+i), i = 0, ... ,(NN-KK-1)
*/ */
int synError = 0; var synError = 0;
for(i = 1; i <= _nn - _kk; i++) for(i = 1; i <= _nn - _kk; i++)
{ {
tmp = 0; tmp = 0;
for(j = 0; j < _nn; j++) for(j = 0; j < _nn; j++)
{ if(recd[j] != _a0) /* recd[j] in index form */
if(recd[j] != _a0) /* recd[j] in index form */ tmp ^= _alphaTo[Modnn(recd[j] + (B0 + i - 1) * j)]; tmp ^= _alphaTo[Modnn(recd[j] + (B0 + i - 1) * j)];
}
synError |= tmp; /* set flag if non-zero syndrome => synError |= tmp; /* set flag if non-zero syndrome =>
* error */ * error */
@@ -457,8 +454,7 @@ public class ReedSolomon
return -1; return -1;
} }
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, Localization.Erasure_positions_as_determined_by_roots_of_Eras_Loc_Poly);
Localization.Erasure_positions_as_determined_by_roots_of_Eras_Loc_Poly);
for(i = 0; i < count; i++) AaruLogging.Debug(MODULE_NAME, "{0} ", loc[i]); for(i = 0; i < count; i++) AaruLogging.Debug(MODULE_NAME, "{0} ", loc[i]);
@@ -479,12 +475,11 @@ public class ReedSolomon
{ {
/* r is the step number */ /* r is the step number */
/* Compute discrepancy at the r-th step in poly-form */ /* Compute discrepancy at the r-th step in poly-form */
int discrR = 0; var discrR = 0;
for(i = 0; i < r; i++) for(i = 0; i < r; i++)
{ if(lambda[i] != 0 && s[r - i] != _a0)
if(lambda[i] != 0 && s[r - i] != _a0) discrR ^= _alphaTo[Modnn(_indexOf[lambda[i]] + s[r - i])]; discrR ^= _alphaTo[Modnn(_indexOf[lambda[i]] + s[r - i])];
}
discrR = _indexOf[discrR]; /* Index form */ discrR = _indexOf[discrR]; /* Index form */
@@ -530,7 +525,7 @@ public class ReedSolomon
} }
/* Convert lambda to index form and compute deg(lambda(x)) */ /* Convert lambda to index form and compute deg(lambda(x)) */
int degLambda = 0; var degLambda = 0;
for(i = 0; i < _nn - _kk + 1; i++) for(i = 0; i < _nn - _kk + 1; i++)
{ {
@@ -582,7 +577,7 @@ public class ReedSolomon
* Compute err+eras evaluator poly omega(x) = s(x)*lambda(x) (modulo * Compute err+eras evaluator poly omega(x) = s(x)*lambda(x) (modulo
* x**(NN-KK)). in index form. Also find deg(omega). * x**(NN-KK)). in index form. Also find deg(omega).
*/ */
int degOmega = 0; var degOmega = 0;
for(i = 0; i < _nn - _kk; i++) for(i = 0; i < _nn - _kk; i++)
{ {
@@ -590,9 +585,8 @@ public class ReedSolomon
j = degLambda < i ? degLambda : i; j = degLambda < i ? degLambda : i;
for(; j >= 0; j--) for(; j >= 0; j--)
{ if(s[i + 1 - j] != _a0 && lambda[j] != _a0)
if(s[i + 1 - j] != _a0 && lambda[j] != _a0) tmp ^= _alphaTo[Modnn(s[i + 1 - j] + lambda[j])]; tmp ^= _alphaTo[Modnn(s[i + 1 - j] + lambda[j])];
}
if(tmp != 0) degOmega = i; if(tmp != 0) degOmega = i;
@@ -607,21 +601,19 @@ public class ReedSolomon
*/ */
for(j = count - 1; j >= 0; j--) for(j = count - 1; j >= 0; j--)
{ {
int num1 = 0; var num1 = 0;
for(i = degOmega; i >= 0; i--) for(i = degOmega; i >= 0; i--)
{ if(omega[i] != _a0)
if(omega[i] != _a0) num1 ^= _alphaTo[Modnn(omega[i] + i * root[j])]; num1 ^= _alphaTo[Modnn(omega[i] + i * root[j])];
}
int num2 = _alphaTo[Modnn(root[j] * (B0 - 1) + _nn)]; int num2 = _alphaTo[Modnn(root[j] * (B0 - 1) + _nn)];
int den = 0; var den = 0;
/* lambda[i+1] for i even is the formal derivative lambda_pr of lambda[i] */ /* lambda[i+1] for i even is the formal derivative lambda_pr of lambda[i] */
for(i = Min(degLambda, _nn - _kk - 1) & ~1; i >= 0; i -= 2) for(i = Min(degLambda, _nn - _kk - 1) & ~1; i >= 0; i -= 2)
{ if(lambda[i + 1] != _a0)
if(lambda[i + 1] != _a0) den ^= _alphaTo[Modnn(lambda[i + 1] + i * root[j])]; den ^= _alphaTo[Modnn(lambda[i + 1] + i * root[j])];
}
if(den == 0) if(den == 0)
{ {

View File

@@ -63,8 +63,8 @@ public static partial class MediaTypeFromDevice
return MediaType.Unknown; return MediaType.Unknown;
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization Localization
.Drive_manufacturer_is_SyQuest_media_has_1961069_blocks_of_512_bytes_setting_media_type_to_SparQ); .Drive_manufacturer_is_SyQuest_media_has_1961069_blocks_of_512_bytes_setting_media_type_to_SparQ);
return MediaType.SparQ; return MediaType.SparQ;
} }

View File

@@ -60,56 +60,55 @@ public static partial class MediaTypeFromDevice
if(blocks == 1281856) if(blocks == 1281856)
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization Localization
.SCSI_medium_type_is_0_media_has_1_blocks_of_2_bytes_setting_media_type_to_WORM_PD_650, .SCSI_medium_type_is_0_media_has_1_blocks_of_2_bytes_setting_media_type_to_WORM_PD_650,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.PD650_WORM; return MediaType.PD650_WORM;
} }
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization Localization
.SCSI_medium_type_is_0_media_has_1_blocks_of_2_bytes_setting_media_type_to_PD_650, .SCSI_medium_type_is_0_media_has_1_blocks_of_2_bytes_setting_media_type_to_PD_650,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.PD650; return MediaType.PD650;
} }
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_medium_type_is_0_setting_media_type_to_Compact_Disc, Localization.SCSI_medium_type_is_0_setting_media_type_to_Compact_Disc,
mediumType); mediumType);
return MediaType.CD; return MediaType.CD;
case 0x01: case 0x01:
case 0x05: case 0x05:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_medium_type_is_0_setting_media_type_to_CD_ROM, Localization.SCSI_medium_type_is_0_setting_media_type_to_CD_ROM,
mediumType); mediumType);
return MediaType.CDROM; return MediaType.CDROM;
case 0x02: case 0x02:
case 0x06: case 0x06:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization Localization.SCSI_medium_type_is_0_setting_media_type_to_Compact_Disc_Digital_Audio,
.SCSI_medium_type_is_0_setting_media_type_to_Compact_Disc_Digital_Audio, mediumType);
mediumType);
return MediaType.CDDA; return MediaType.CDDA;
case 0x03: case 0x03:
case 0x07: case 0x07:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_medium_type_is_0_setting_media_type_to_CD_Plus, Localization.SCSI_medium_type_is_0_setting_media_type_to_CD_Plus,
mediumType); mediumType);
return MediaType.CDPLUS; return MediaType.CDPLUS;
case 0x04: case 0x04:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_medium_type_is_0_setting_media_type_to_Photo_CD, Localization.SCSI_medium_type_is_0_setting_media_type_to_Photo_CD,
mediumType); mediumType);
return MediaType.PCD; return MediaType.PCD;
case 0x10: case 0x10:
@@ -122,8 +121,8 @@ public static partial class MediaTypeFromDevice
case 0x17: case 0x17:
case 0x18: case 0x18:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_medium_type_is_0_setting_media_type_to_CDR, Localization.SCSI_medium_type_is_0_setting_media_type_to_CDR,
mediumType); mediumType);
return MediaType.CDR; return MediaType.CDR;
case 0x20: case 0x20:
@@ -136,17 +135,17 @@ public static partial class MediaTypeFromDevice
case 0x27: case 0x27:
case 0x28: case 0x28:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_medium_type_is_0_setting_media_type_to_CDRW, Localization.SCSI_medium_type_is_0_setting_media_type_to_CDRW,
mediumType); mediumType);
return MediaType.CDRW; return MediaType.CDRW;
case 0x40 when isUsb && !opticalDisc: case 0x40 when isUsb && !opticalDisc:
case 0x41 when isUsb && !opticalDisc: case 0x41 when isUsb && !opticalDisc:
case 0x42 when isUsb && !opticalDisc: case 0x42 when isUsb && !opticalDisc:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization Localization
.SCSI_medium_type_is_0_and_device_is_USB_setting_media_type_to_Flash_Drive, .SCSI_medium_type_is_0_and_device_is_USB_setting_media_type_to_Flash_Drive,
mediumType); mediumType);
return MediaType.FlashDrive; return MediaType.FlashDrive;
case 0x80: case 0x80:
@@ -156,34 +155,34 @@ public static partial class MediaTypeFromDevice
{ {
case 0x42: case 0x42:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization Localization
.SCSI_medium_type_is_0_density_code_is_1_drive_starts_with_ult_setting_media_type_to_LTO2, .SCSI_medium_type_is_0_density_code_is_1_drive_starts_with_ult_setting_media_type_to_LTO2,
mediumType, mediumType,
densityCode); densityCode);
return MediaType.LTO2; return MediaType.LTO2;
case 0x44: case 0x44:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization Localization
.SCSI_medium_type_is_0_density_code_is_1_drive_starts_with_ult_setting_media_type_to_LTO3, .SCSI_medium_type_is_0_density_code_is_1_drive_starts_with_ult_setting_media_type_to_LTO3,
mediumType, mediumType,
densityCode); densityCode);
return MediaType.LTO3; return MediaType.LTO3;
case 0x46: case 0x46:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization Localization
.SCSI_medium_type_is_0_density_code_is_1_drive_starts_with_ult_setting_media_type_to_LTO4, .SCSI_medium_type_is_0_density_code_is_1_drive_starts_with_ult_setting_media_type_to_LTO4,
mediumType, mediumType,
densityCode); densityCode);
return MediaType.LTO4; return MediaType.LTO4;
case 0x58: case 0x58:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization Localization
.SCSI_medium_type_is_0_density_code_is_1_drive_starts_with_ult_setting_media_type_to_LTO5, .SCSI_medium_type_is_0_density_code_is_1_drive_starts_with_ult_setting_media_type_to_LTO5,
mediumType, mediumType,
densityCode); densityCode);
return MediaType.LTO5; return MediaType.LTO5;
} }

View File

@@ -48,8 +48,8 @@ public static partial class MediaTypeFromDevice
if(mediumType != 0x01 && mediumType != 0x02 && mediumType != 0x03 && mediumType != 0x05 && mediumType != 0x07) if(mediumType != 0x01 && mediumType != 0x02 && mediumType != 0x03 && mediumType != 0x05 && mediumType != 0x07)
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_medium_type_is_0_setting_media_type_to_unknown_magneto_optical, Localization.SCSI_medium_type_is_0_setting_media_type_to_unknown_magneto_optical,
mediumType); mediumType);
return MediaType.UnknownMO; return MediaType.UnknownMO;
} }
@@ -62,102 +62,102 @@ public static partial class MediaTypeFromDevice
{ {
case 248826: case 248826:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_ECMA154, Localization.SCSI_Media_Type_Description_ECMA154,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.ECMA_154; return MediaType.ECMA_154;
case 429975: case 429975:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_ECMA201_embossed, Localization.SCSI_Media_Type_Description_ECMA201_embossed,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.ECMA_201_ROM; return MediaType.ECMA_201_ROM;
case 446325: case 446325:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_ECMA201, Localization.SCSI_Media_Type_Description_ECMA201,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.ECMA_201; return MediaType.ECMA_201;
case 694929: case 694929:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_ECMA223, Localization.SCSI_Media_Type_Description_ECMA223,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.ECMA_223_512; return MediaType.ECMA_223_512;
case 904995: case 904995:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_ECMA183, Localization.SCSI_Media_Type_Description_ECMA183,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.ECMA_183_512; return MediaType.ECMA_183_512;
case 1041500: case 1041500:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_ISO15041, Localization.SCSI_Media_Type_Description_ISO15041,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.ISO_15041_512; return MediaType.ISO_15041_512;
case 1128772: case 1128772:
case 1163337: case 1163337:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_ECMA184, Localization.SCSI_Media_Type_Description_ECMA184,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.ECMA_184_512; return MediaType.ECMA_184_512;
case 1281856: case 1281856:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization Localization
.SCSI_medium_type_is_0_media_has_1_blocks_of_2_bytes_setting_media_type_to_WORM_PD_650, .SCSI_medium_type_is_0_media_has_1_blocks_of_2_bytes_setting_media_type_to_WORM_PD_650,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.PD650_WORM; return MediaType.PD650_WORM;
case 1298496: case 1298496:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization Localization
.SCSI_medium_type_is_0_media_has_1_blocks_of_2_bytes_setting_media_type_to_PD_650, .SCSI_medium_type_is_0_media_has_1_blocks_of_2_bytes_setting_media_type_to_PD_650,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.PD650; return MediaType.PD650;
case 1644581: case 1644581:
case 1647371: case 1647371:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_ECMA195, Localization.SCSI_Media_Type_Description_ECMA195,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.ECMA_195_512; return MediaType.ECMA_195_512;
case 2244958: case 2244958:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_ISO14517, Localization.SCSI_Media_Type_Description_ISO14517,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.ISO_14517_512; return MediaType.ISO_14517_512;
default: default:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_Unknown_MO, Localization.SCSI_Media_Type_Description_Unknown_MO,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.UnknownMO; return MediaType.UnknownMO;
} }
@@ -169,100 +169,100 @@ public static partial class MediaTypeFromDevice
{ {
case 314569: case 314569:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_ISO10089, Localization.SCSI_Media_Type_Description_ISO10089,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.ISO_10089; return MediaType.ISO_10089;
case 371371: case 371371:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_ECMA223, Localization.SCSI_Media_Type_Description_ECMA223,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.ECMA_223; return MediaType.ECMA_223;
case 498526: case 498526:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_ECMA184, Localization.SCSI_Media_Type_Description_ECMA184,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.ECMA_183; return MediaType.ECMA_183;
case 603466: case 603466:
case 637041: case 637041:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_ECMA184, Localization.SCSI_Media_Type_Description_ECMA184,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.ECMA_184; return MediaType.ECMA_184;
case 936921: case 936921:
case 948770: case 948770:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_ECMA195, Localization.SCSI_Media_Type_Description_ECMA195,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.ECMA_195; return MediaType.ECMA_195;
case 1244621: case 1244621:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_ECMA238, Localization.SCSI_Media_Type_Description_ECMA238,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.ECMA_238; return MediaType.ECMA_238;
case 1273011: case 1273011:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_ISO14517, Localization.SCSI_Media_Type_Description_ISO14517,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.ISO_14517; return MediaType.ISO_14517;
case 2319786: case 2319786:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_ISO15286, Localization.SCSI_Media_Type_Description_ISO15286,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.ISO_15286_1024; return MediaType.ISO_15286_1024;
case 4383356: case 4383356:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_ECMA322, Localization.SCSI_Media_Type_Description_ECMA322,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.ECMA_322_1k; return MediaType.ECMA_322_1k;
case 14476734: case 14476734:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_ECMA260, Localization.SCSI_Media_Type_Description_ECMA260,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.ECMA_260; return MediaType.ECMA_260;
case 24445990: case 24445990:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_ECMA260, Localization.SCSI_Media_Type_Description_ECMA260,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.ECMA_260_Double; return MediaType.ECMA_260_Double;
default: default:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_Unknown_MO, Localization.SCSI_Media_Type_Description_Unknown_MO,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.UnknownMO; return MediaType.UnknownMO;
} }
@@ -277,66 +277,66 @@ public static partial class MediaTypeFromDevice
case 320332: case 320332:
case 321100: case 321100:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_ECMA239, Localization.SCSI_Media_Type_Description_ECMA239,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.ECMA_239; return MediaType.ECMA_239;
case 605846: case 605846:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_GigaMO, Localization.SCSI_Media_Type_Description_GigaMO,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.GigaMo; return MediaType.GigaMo;
case 1063146: case 1063146:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_GigaMO2, Localization.SCSI_Media_Type_Description_GigaMO2,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.GigaMo2; return MediaType.GigaMo2;
case 1128134: case 1128134:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_ECMA280, Localization.SCSI_Media_Type_Description_ECMA280,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.ECMA_280; return MediaType.ECMA_280;
case 1263472: case 1263472:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_ISO15286, Localization.SCSI_Media_Type_Description_ISO15286,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.ISO_15286; return MediaType.ISO_15286;
case 2043664: case 2043664:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_ECMA322, Localization.SCSI_Media_Type_Description_ECMA322,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.ECMA_322_2k; return MediaType.ECMA_322_2k;
case 7355716: case 7355716:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_ECMA317, Localization.SCSI_Media_Type_Description_ECMA317,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.ECMA_317; return MediaType.ECMA_317;
default: default:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_Unknown_MO, Localization.SCSI_Media_Type_Description_Unknown_MO,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.UnknownMO; return MediaType.UnknownMO;
} }
@@ -348,18 +348,18 @@ public static partial class MediaTypeFromDevice
{ {
case 1095840: case 1095840:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_ECMA322, Localization.SCSI_Media_Type_Description_ECMA322,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.ECMA_322; return MediaType.ECMA_322;
default: default:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_Unknown_MO, Localization.SCSI_Media_Type_Description_Unknown_MO,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.UnknownMO; return MediaType.UnknownMO;
} }
@@ -371,34 +371,34 @@ public static partial class MediaTypeFromDevice
{ {
case 1834348: case 1834348:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_UDO, Localization.SCSI_Media_Type_Description_UDO,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.UDO; return MediaType.UDO;
case 3668759: case 3668759:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_WORM_UDO2, Localization.SCSI_Media_Type_Description_WORM_UDO2,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.UDO2_WORM; return MediaType.UDO2_WORM;
case 3669724: case 3669724:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_UDO2, Localization.SCSI_Media_Type_Description_UDO2,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.UDO2; return MediaType.UDO2;
default: default:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_Unknown_MO, Localization.SCSI_Media_Type_Description_Unknown_MO,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.UnknownMO; return MediaType.UnknownMO;
} }
@@ -406,10 +406,10 @@ public static partial class MediaTypeFromDevice
default: default:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_Unknown_MO, Localization.SCSI_Media_Type_Description_Unknown_MO,
mediumType, mediumType,
blocks, blocks,
blockSize); blockSize);
return MediaType.UnknownMO; return MediaType.UnknownMO;
} }

File diff suppressed because it is too large Load Diff

View File

@@ -85,10 +85,10 @@ public static partial class MediaTypeFromDevice
if(blockSize == 2048) if(blockSize == 2048)
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_MDDATA, Localization.SCSI_Media_Type_Description_MDDATA,
scsiPeripheralType, scsiPeripheralType,
blocks, blocks,
blockSize); blockSize);
return MediaType.MDData; return MediaType.MDData;
} }
@@ -97,45 +97,45 @@ public static partial class MediaTypeFromDevice
{ {
case 57312: case 57312:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_MD60_MDDATA, Localization.SCSI_Media_Type_Description_MD60_MDDATA,
scsiPeripheralType, scsiPeripheralType,
blocks, blocks,
blockSize); blockSize);
return MediaType.MD60; return MediaType.MD60;
case 70464: case 70464:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_MD74_MDDATA, Localization.SCSI_Media_Type_Description_MD74_MDDATA,
scsiPeripheralType, scsiPeripheralType,
blocks, blocks,
blockSize); blockSize);
return MediaType.MD74; return MediaType.MD74;
case 76096: case 76096:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_MD80_MDDATA, Localization.SCSI_Media_Type_Description_MD80_MDDATA,
scsiPeripheralType, scsiPeripheralType,
blocks, blocks,
blockSize); blockSize);
return MediaType.MD80; return MediaType.MD80;
} }
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_MD60_MDDATA, Localization.SCSI_Media_Type_Description_MD60_MDDATA,
scsiPeripheralType, scsiPeripheralType,
blocks, blocks,
blockSize); blockSize);
return MediaType.MD; return MediaType.MD;
// Host managed zoned block device // Host managed zoned block device
case 0x14: case 0x14:
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.SCSI_Media_Type_Description_ZBC_Host_Managed, Localization.SCSI_Media_Type_Description_ZBC_Host_Managed,
scsiPeripheralType, scsiPeripheralType,
blocks, blocks,
blockSize); blockSize);
return MediaType.Zone_HDD; return MediaType.Zone_HDD;
} }

File diff suppressed because it is too large Load Diff

View File

@@ -800,8 +800,7 @@ public static class Identify
if(IdentifyDeviceResponse.Length != 512) if(IdentifyDeviceResponse.Length != 512)
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, Localization.IDENTIFY_response_is_different_than_512_bytes_not_decoding);
Localization.IDENTIFY_response_is_different_than_512_bytes_not_decoding);
return null; return null;
} }
@@ -833,8 +832,8 @@ public static class Identify
ataId.WWN = DescrambleWWN(ataId.WWN); ataId.WWN = DescrambleWWN(ataId.WWN);
ataId.WWNExtension = DescrambleWWN(ataId.WWNExtension); ataId.WWNExtension = DescrambleWWN(ataId.WWNExtension);
byte[] buf = new byte[512]; var buf = new byte[512];
nint ptr = System.Runtime.InteropServices.Marshal.AllocHGlobal(512); nint ptr = System.Runtime.InteropServices.Marshal.AllocHGlobal(512);
System.Runtime.InteropServices.Marshal.StructureToPtr(ataId, ptr, false); System.Runtime.InteropServices.Marshal.StructureToPtr(ataId, ptr, false);
System.Runtime.InteropServices.Marshal.Copy(ptr, buf, 0, 512); System.Runtime.InteropServices.Marshal.Copy(ptr, buf, 0, 512);
System.Runtime.InteropServices.Marshal.FreeHGlobal(ptr); System.Runtime.InteropServices.Marshal.FreeHGlobal(ptr);
@@ -858,7 +857,7 @@ public static class Identify
static ulong DescrambleWWN(ulong WWN) static ulong DescrambleWWN(ulong WWN)
{ {
byte[] qwb = BitConverter.GetBytes(WWN); byte[] qwb = BitConverter.GetBytes(WWN);
byte[] qword = new byte[8]; var qword = new byte[8];
qword[7] = qwb[1]; qword[7] = qwb[1];
qword[6] = qwb[0]; qword[6] = qwb[0];
@@ -876,7 +875,7 @@ public static class Identify
{ {
byte[] outbuf = buffer[offset + length - 1] != 0x00 ? new byte[length + 1] : new byte[length]; byte[] outbuf = buffer[offset + length - 1] != 0x00 ? new byte[length + 1] : new byte[length];
for(int i = 0; i < length; i += 2) for(var i = 0; i < length; i += 2)
{ {
outbuf[i] = buffer[offset + i + 1]; outbuf[i] = buffer[offset + i + 1];
outbuf[i + 1] = buffer[offset + i]; outbuf[i + 1] = buffer[offset + i];
@@ -889,9 +888,9 @@ public static class Identify
static byte[] ScrambleATAString(string str, int length) static byte[] ScrambleATAString(string str, int length)
{ {
byte[] buf = new byte[length]; var buf = new byte[length];
for(int i = 0; i < length; i++) buf[i] = 0x20; for(var i = 0; i < length; i++) buf[i] = 0x20;
if(str is null) return buf; if(str is null) return buf;
@@ -899,13 +898,13 @@ public static class Identify
if(bytes.Length % 2 != 0) if(bytes.Length % 2 != 0)
{ {
byte[] tmp = new byte[bytes.Length + 1]; var tmp = new byte[bytes.Length + 1];
tmp[^1] = 0x20; tmp[^1] = 0x20;
Array.Copy(bytes, 0, tmp, 0, bytes.Length); Array.Copy(bytes, 0, tmp, 0, bytes.Length);
bytes = tmp; bytes = tmp;
} }
for(int i = 0; i < bytes.Length; i += 2) for(var i = 0; i < bytes.Length; i += 2)
{ {
buf[i] = bytes[i + 1]; buf[i] = bytes[i + 1];
buf[i + 1] = bytes[i]; buf[i + 1] = bytes[i];

View File

@@ -38,7 +38,6 @@
using System; using System;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Aaru.Logging; using Aaru.Logging;
namespace Aaru.CommonTypes.Structs.Devices.SCSI; namespace Aaru.CommonTypes.Structs.Devices.SCSI;
@@ -276,8 +275,8 @@ public struct Inquiry
if(SCSIInquiryResponse.Length < 36 && SCSIInquiryResponse.Length != 5) if(SCSIInquiryResponse.Length < 36 && SCSIInquiryResponse.Length != 5)
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.INQUIRY_response_is_0_bytes_less_than_minimum_of_36_bytes, Localization.INQUIRY_response_is_0_bytes_less_than_minimum_of_36_bytes,
SCSIInquiryResponse.Length); SCSIInquiryResponse.Length);
return null; return null;
} }
@@ -286,10 +285,9 @@ public struct Inquiry
SCSIInquiryResponse.Length != SCSIInquiryResponse[4]) SCSIInquiryResponse.Length != SCSIInquiryResponse[4])
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization Localization.INQUIRY_response_length_0_bytes_is_different_than_specified_in_length_field,
.INQUIRY_response_length_0_bytes_is_different_than_specified_in_length_field, SCSIInquiryResponse.Length,
SCSIInquiryResponse.Length, SCSIInquiryResponse[4] + 4);
SCSIInquiryResponse[4] + 4);
return null; return null;
} }
@@ -477,7 +475,7 @@ public struct Inquiry
decoded.VersionDescriptors = new ushort[descriptorsNo]; decoded.VersionDescriptors = new ushort[descriptorsNo];
for(int i = 0; i < descriptorsNo; i++) for(var i = 0; i < descriptorsNo; i++)
decoded.VersionDescriptors[i] = BitConverter.ToUInt16(SCSIInquiryResponse, 58 + i * 2); decoded.VersionDescriptors[i] = BitConverter.ToUInt16(SCSIInquiryResponse, 58 + i * 2);
} }
@@ -528,8 +526,8 @@ public struct Inquiry
Inquiry decoded = inq.Value; Inquiry decoded = inq.Value;
byte[] buffer = new byte[512]; var buffer = new byte[512];
byte length = 0; byte length = 0;
buffer[0] = (byte)(decoded.PeripheralQualifier << 5); buffer[0] = (byte)(decoded.PeripheralQualifier << 5);
buffer[0] += decoded.PeripheralDeviceType; buffer[0] += decoded.PeripheralDeviceType;
@@ -729,7 +727,7 @@ public struct Inquiry
{ {
length = (byte)(58 + decoded.VersionDescriptors.Length * 2); length = (byte)(58 + decoded.VersionDescriptors.Length * 2);
for(int i = 0; i < decoded.VersionDescriptors.Length; i++) for(var i = 0; i < decoded.VersionDescriptors.Length; i++)
Array.Copy(BitConverter.GetBytes(decoded.VersionDescriptors[i]), 0, buffer, 56 + i * 2, 2); Array.Copy(BitConverter.GetBytes(decoded.VersionDescriptors[i]), 0, buffer, 56 + i * 2, 2);
} }
@@ -758,7 +756,7 @@ public struct Inquiry
} }
buffer[4] = length; buffer[4] = length;
byte[] dest = new byte[length]; var dest = new byte[length];
Array.Copy(buffer, 0, dest, 0, length); Array.Copy(buffer, 0, dest, 0, length);
return dest; return dest;

View File

@@ -52,10 +52,10 @@ public partial class LZFSE
public static int DecodeBuffer(byte[] source, byte[] destination) => Native.IsSupported public static int DecodeBuffer(byte[] source, byte[] destination) => Native.IsSupported
? (int) ? (int)
AARU_lzfse_decode_buffer(destination, AARU_lzfse_decode_buffer(destination,
(nuint)destination.Length, (nuint)destination.Length,
source, source,
(nuint)source.Length, (nuint)source.Length,
null) null)
: 0; : 0;
/// <summary>Compresses a buffer using BZIP2</summary> /// <summary>Compresses a buffer using BZIP2</summary>
@@ -65,9 +65,9 @@ public partial class LZFSE
public static int EncodeBuffer(byte[] source, byte[] destination) => Native.IsSupported public static int EncodeBuffer(byte[] source, byte[] destination) => Native.IsSupported
? (int) ? (int)
AARU_lzfse_encode_buffer(destination, AARU_lzfse_encode_buffer(destination,
(nuint)destination.Length, (nuint)destination.Length,
source, source,
(nuint)source.Length, (nuint)source.Length,
null) null)
: 0; : 0;
} }

View File

@@ -46,7 +46,7 @@ public sealed partial class DeviceReport
/// <returns>Media report</returns> /// <returns>Media report</returns>
public TestedMedia ReportAtaMedia() public TestedMedia ReportAtaMedia()
{ {
bool sense = true; var sense = true;
AtaErrorRegistersChs errorChs = new(); AtaErrorRegistersChs errorChs = new();
AtaErrorRegistersLba28 errorLba = new(); AtaErrorRegistersLba28 errorLba = new();
AtaErrorRegistersLba48 errorLba48 = new(); AtaErrorRegistersLba48 errorLba48 = new();
@@ -181,7 +181,7 @@ public sealed partial class DeviceReport
mediaTest.Manufacturer = ataId.MediaManufacturer; mediaTest.Manufacturer = ataId.MediaManufacturer;
} }
ulong checkCorrectRead = BitConverter.ToUInt64(buffer, 0); var checkCorrectRead = BitConverter.ToUInt64(buffer, 0);
Spectre.ProgressSingleSpinner(ctx => Spectre.ProgressSingleSpinner(ctx =>
{ {
@@ -193,11 +193,11 @@ public sealed partial class DeviceReport
!sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0; !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0;
AaruLogging.Debug(ATA_MODULE_NAME, AaruLogging.Debug(ATA_MODULE_NAME,
Localization.Core.Sense_0_Status_1_Error_2_Length_3, Localization.Core.Sense_0_Status_1_Error_2_Length_3,
sense, sense,
errorChs.Status, errorChs.Status,
errorChs.Error, errorChs.Error,
readBuf.Length); readBuf.Length);
mediaTest.ReadSectorsData = readBuf; mediaTest.ReadSectorsData = readBuf;
@@ -211,11 +211,11 @@ public sealed partial class DeviceReport
!sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0; !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0;
AaruLogging.Debug(ATA_MODULE_NAME, AaruLogging.Debug(ATA_MODULE_NAME,
Localization.Core.Sense_0_Status_1_Error_2_Length_3, Localization.Core.Sense_0_Status_1_Error_2_Length_3,
sense, sense,
errorChs.Status, errorChs.Status,
errorChs.Error, errorChs.Error,
readBuf.Length); readBuf.Length);
mediaTest.ReadSectorsRetryData = readBuf; mediaTest.ReadSectorsRetryData = readBuf;
@@ -229,11 +229,11 @@ public sealed partial class DeviceReport
!sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0; !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0;
AaruLogging.Debug(ATA_MODULE_NAME, AaruLogging.Debug(ATA_MODULE_NAME,
Localization.Core.Sense_0_Status_1_Error_2_Length_3, Localization.Core.Sense_0_Status_1_Error_2_Length_3,
sense, sense,
errorChs.Status, errorChs.Status,
errorChs.Error, errorChs.Error,
readBuf.Length); readBuf.Length);
mediaTest.ReadDmaData = readBuf; mediaTest.ReadDmaData = readBuf;
@@ -247,11 +247,11 @@ public sealed partial class DeviceReport
!sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0; !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0;
AaruLogging.Debug(ATA_MODULE_NAME, AaruLogging.Debug(ATA_MODULE_NAME,
Localization.Core.Sense_0_Status_1_Error_2_Length_3, Localization.Core.Sense_0_Status_1_Error_2_Length_3,
sense, sense,
errorChs.Status, errorChs.Status,
errorChs.Error, errorChs.Error,
readBuf.Length); readBuf.Length);
mediaTest.ReadDmaRetryData = readBuf; mediaTest.ReadDmaRetryData = readBuf;
@@ -264,10 +264,10 @@ public sealed partial class DeviceReport
mediaTest.SupportsSeek = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0; mediaTest.SupportsSeek = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0;
AaruLogging.Debug(ATA_MODULE_NAME, AaruLogging.Debug(ATA_MODULE_NAME,
Localization.Core.Sense_0_Status_1_Error_2, Localization.Core.Sense_0_Status_1_Error_2,
sense, sense,
errorChs.Status, errorChs.Status,
errorChs.Error); errorChs.Error);
Spectre.ProgressSingleSpinner(ctx => Spectre.ProgressSingleSpinner(ctx =>
{ {
@@ -279,11 +279,11 @@ public sealed partial class DeviceReport
!sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0; !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0;
AaruLogging.Debug(ATA_MODULE_NAME, AaruLogging.Debug(ATA_MODULE_NAME,
Localization.Core.Sense_0_Status_1_Error_2_Length_3, Localization.Core.Sense_0_Status_1_Error_2_Length_3,
sense, sense,
errorChs.Status, errorChs.Status,
errorChs.Error, errorChs.Error,
readBuf.Length); readBuf.Length);
mediaTest.ReadLbaData = readBuf; mediaTest.ReadLbaData = readBuf;
@@ -297,11 +297,11 @@ public sealed partial class DeviceReport
!sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0; !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0;
AaruLogging.Debug(ATA_MODULE_NAME, AaruLogging.Debug(ATA_MODULE_NAME,
Localization.Core.Sense_0_Status_1_Error_2_Length_3, Localization.Core.Sense_0_Status_1_Error_2_Length_3,
sense, sense,
errorChs.Status, errorChs.Status,
errorChs.Error, errorChs.Error,
readBuf.Length); readBuf.Length);
mediaTest.ReadRetryLbaData = readBuf; mediaTest.ReadRetryLbaData = readBuf;
@@ -315,11 +315,11 @@ public sealed partial class DeviceReport
!sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0; !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0;
AaruLogging.Debug(ATA_MODULE_NAME, AaruLogging.Debug(ATA_MODULE_NAME,
Localization.Core.Sense_0_Status_1_Error_2_Length_3, Localization.Core.Sense_0_Status_1_Error_2_Length_3,
sense, sense,
errorChs.Status, errorChs.Status,
errorChs.Error, errorChs.Error,
readBuf.Length); readBuf.Length);
mediaTest.ReadDmaLbaData = readBuf; mediaTest.ReadDmaLbaData = readBuf;
@@ -333,11 +333,11 @@ public sealed partial class DeviceReport
!sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0; !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0;
AaruLogging.Debug(ATA_MODULE_NAME, AaruLogging.Debug(ATA_MODULE_NAME,
Localization.Core.Sense_0_Status_1_Error_2_Length_3, Localization.Core.Sense_0_Status_1_Error_2_Length_3,
sense, sense,
errorChs.Status, errorChs.Status,
errorChs.Error, errorChs.Error,
readBuf.Length); readBuf.Length);
mediaTest.ReadDmaRetryLbaData = readBuf; mediaTest.ReadDmaRetryLbaData = readBuf;
@@ -350,10 +350,10 @@ public sealed partial class DeviceReport
mediaTest.SupportsSeekLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0; mediaTest.SupportsSeekLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0;
AaruLogging.Debug(ATA_MODULE_NAME, AaruLogging.Debug(ATA_MODULE_NAME,
Localization.Core.Sense_0_Status_1_Error_2, Localization.Core.Sense_0_Status_1_Error_2,
sense, sense,
errorChs.Status, errorChs.Status,
errorChs.Error); errorChs.Error);
Spectre.ProgressSingleSpinner(ctx => Spectre.ProgressSingleSpinner(ctx =>
{ {
@@ -365,11 +365,11 @@ public sealed partial class DeviceReport
!sense && (errorLba48.Status & 0x01) != 0x01 && errorLba48.Error == 0 && readBuf.Length > 0; !sense && (errorLba48.Status & 0x01) != 0x01 && errorLba48.Error == 0 && readBuf.Length > 0;
AaruLogging.Debug(ATA_MODULE_NAME, AaruLogging.Debug(ATA_MODULE_NAME,
Localization.Core.Sense_0_Status_1_Error_2_Length_3, Localization.Core.Sense_0_Status_1_Error_2_Length_3,
sense, sense,
errorChs.Status, errorChs.Status,
errorChs.Error, errorChs.Error,
readBuf.Length); readBuf.Length);
mediaTest.ReadLba48Data = readBuf; mediaTest.ReadLba48Data = readBuf;
@@ -383,11 +383,11 @@ public sealed partial class DeviceReport
!sense && (errorLba48.Status & 0x01) != 0x01 && errorLba48.Error == 0 && readBuf.Length > 0; !sense && (errorLba48.Status & 0x01) != 0x01 && errorLba48.Error == 0 && readBuf.Length > 0;
AaruLogging.Debug(ATA_MODULE_NAME, AaruLogging.Debug(ATA_MODULE_NAME,
Localization.Core.Sense_0_Status_1_Error_2_Length_3, Localization.Core.Sense_0_Status_1_Error_2_Length_3,
sense, sense,
errorChs.Status, errorChs.Status,
errorChs.Error, errorChs.Error,
readBuf.Length); readBuf.Length);
mediaTest.ReadDmaLba48Data = readBuf; mediaTest.ReadDmaLba48Data = readBuf;
@@ -432,11 +432,11 @@ public sealed partial class DeviceReport
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
AaruLogging.Debug(ATA_MODULE_NAME, AaruLogging.Debug(ATA_MODULE_NAME,
Localization.Core.Sense_0_Status_1_Error_2_Length_3, Localization.Core.Sense_0_Status_1_Error_2_Length_3,
sense, sense,
errorChs.Status, errorChs.Status,
errorChs.Error, errorChs.Error,
readBuf.Length); readBuf.Length);
mediaTest.ReadLongData = readBuf; mediaTest.ReadLongData = readBuf;
@@ -462,11 +462,11 @@ public sealed partial class DeviceReport
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
AaruLogging.Debug(ATA_MODULE_NAME, AaruLogging.Debug(ATA_MODULE_NAME,
Localization.Core.Sense_0_Status_1_Error_2_Length_3, Localization.Core.Sense_0_Status_1_Error_2_Length_3,
sense, sense,
errorChs.Status, errorChs.Status,
errorChs.Error, errorChs.Error,
readBuf.Length); readBuf.Length);
mediaTest.ReadLongRetryData = readBuf; mediaTest.ReadLongRetryData = readBuf;
@@ -490,11 +490,11 @@ public sealed partial class DeviceReport
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
AaruLogging.Debug(ATA_MODULE_NAME, AaruLogging.Debug(ATA_MODULE_NAME,
Localization.Core.Sense_0_Status_1_Error_2_Length_3, Localization.Core.Sense_0_Status_1_Error_2_Length_3,
sense, sense,
errorChs.Status, errorChs.Status,
errorChs.Error, errorChs.Error,
readBuf.Length); readBuf.Length);
mediaTest.ReadLongLbaData = readBuf; mediaTest.ReadLongLbaData = readBuf;
@@ -518,11 +518,11 @@ public sealed partial class DeviceReport
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
AaruLogging.Debug(ATA_MODULE_NAME, AaruLogging.Debug(ATA_MODULE_NAME,
Localization.Core.Sense_0_Status_1_Error_2_Length_3, Localization.Core.Sense_0_Status_1_Error_2_Length_3,
sense, sense,
errorChs.Status, errorChs.Status,
errorChs.Error, errorChs.Error,
readBuf.Length); readBuf.Length);
mediaTest.ReadLongRetryLbaData = readBuf; mediaTest.ReadLongRetryLbaData = readBuf;
} }
@@ -535,7 +535,7 @@ public sealed partial class DeviceReport
/// <summary>Creates a report of an ATA device</summary> /// <summary>Creates a report of an ATA device</summary>
public TestedMedia ReportAta(Identify.IdentifyDevice ataId) public TestedMedia ReportAta(Identify.IdentifyDevice ataId)
{ {
bool sense = true; var sense = true;
byte[] readBuf = []; byte[] readBuf = [];
AtaErrorRegistersChs errorChs = new(); AtaErrorRegistersChs errorChs = new();
AtaErrorRegistersLba28 errorLba = new(); AtaErrorRegistersLba28 errorLba = new();
@@ -657,11 +657,11 @@ public sealed partial class DeviceReport
!sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0; !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0;
AaruLogging.Debug(ATA_MODULE_NAME, AaruLogging.Debug(ATA_MODULE_NAME,
Localization.Core.Sense_0_Status_1_Error_2_Length_3, Localization.Core.Sense_0_Status_1_Error_2_Length_3,
sense, sense,
errorChs.Status, errorChs.Status,
errorChs.Error, errorChs.Error,
readBuf.Length); readBuf.Length);
capabilities.ReadSectorsData = readBuf; capabilities.ReadSectorsData = readBuf;
@@ -675,11 +675,11 @@ public sealed partial class DeviceReport
!sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0; !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0;
AaruLogging.Debug(ATA_MODULE_NAME, AaruLogging.Debug(ATA_MODULE_NAME,
Localization.Core.Sense_0_Status_1_Error_2_Length_3, Localization.Core.Sense_0_Status_1_Error_2_Length_3,
sense, sense,
errorChs.Status, errorChs.Status,
errorChs.Error, errorChs.Error,
readBuf.Length); readBuf.Length);
capabilities.ReadSectorsRetryData = readBuf; capabilities.ReadSectorsRetryData = readBuf;
@@ -693,11 +693,11 @@ public sealed partial class DeviceReport
!sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0; !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0;
AaruLogging.Debug(ATA_MODULE_NAME, AaruLogging.Debug(ATA_MODULE_NAME,
Localization.Core.Sense_0_Status_1_Error_2_Length_3, Localization.Core.Sense_0_Status_1_Error_2_Length_3,
sense, sense,
errorChs.Status, errorChs.Status,
errorChs.Error, errorChs.Error,
readBuf.Length); readBuf.Length);
capabilities.ReadDmaData = readBuf; capabilities.ReadDmaData = readBuf;
@@ -711,11 +711,11 @@ public sealed partial class DeviceReport
!sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0; !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0 && readBuf.Length > 0;
AaruLogging.Debug(ATA_MODULE_NAME, AaruLogging.Debug(ATA_MODULE_NAME,
Localization.Core.Sense_0_Status_1_Error_2_Length_3, Localization.Core.Sense_0_Status_1_Error_2_Length_3,
sense, sense,
errorChs.Status, errorChs.Status,
errorChs.Error, errorChs.Error,
readBuf.Length); readBuf.Length);
capabilities.ReadDmaRetryData = readBuf; capabilities.ReadDmaRetryData = readBuf;
@@ -728,10 +728,10 @@ public sealed partial class DeviceReport
capabilities.SupportsSeek = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0; capabilities.SupportsSeek = !sense && (errorChs.Status & 0x01) != 0x01 && errorChs.Error == 0;
AaruLogging.Debug(ATA_MODULE_NAME, AaruLogging.Debug(ATA_MODULE_NAME,
Localization.Core.Sense_0_Status_1_Error_2, Localization.Core.Sense_0_Status_1_Error_2,
sense, sense,
errorChs.Status, errorChs.Status,
errorChs.Error); errorChs.Error);
Spectre.ProgressSingleSpinner(ctx => Spectre.ProgressSingleSpinner(ctx =>
{ {
@@ -743,11 +743,11 @@ public sealed partial class DeviceReport
!sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0; !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0;
AaruLogging.Debug(ATA_MODULE_NAME, AaruLogging.Debug(ATA_MODULE_NAME,
Localization.Core.Sense_0_Status_1_Error_2_Length_3, Localization.Core.Sense_0_Status_1_Error_2_Length_3,
sense, sense,
errorLba.Status, errorLba.Status,
errorLba.Error, errorLba.Error,
readBuf.Length); readBuf.Length);
capabilities.ReadLbaData = readBuf; capabilities.ReadLbaData = readBuf;
@@ -761,11 +761,11 @@ public sealed partial class DeviceReport
!sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0; !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0;
AaruLogging.Debug(ATA_MODULE_NAME, AaruLogging.Debug(ATA_MODULE_NAME,
Localization.Core.Sense_0_Status_1_Error_2_Length_3, Localization.Core.Sense_0_Status_1_Error_2_Length_3,
sense, sense,
errorLba.Status, errorLba.Status,
errorLba.Error, errorLba.Error,
readBuf.Length); readBuf.Length);
capabilities.ReadRetryLbaData = readBuf; capabilities.ReadRetryLbaData = readBuf;
@@ -779,11 +779,11 @@ public sealed partial class DeviceReport
!sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0; !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0;
AaruLogging.Debug(ATA_MODULE_NAME, AaruLogging.Debug(ATA_MODULE_NAME,
Localization.Core.Sense_0_Status_1_Error_2_Length_3, Localization.Core.Sense_0_Status_1_Error_2_Length_3,
sense, sense,
errorLba.Status, errorLba.Status,
errorLba.Error, errorLba.Error,
readBuf.Length); readBuf.Length);
capabilities.ReadDmaLbaData = readBuf; capabilities.ReadDmaLbaData = readBuf;
@@ -797,11 +797,11 @@ public sealed partial class DeviceReport
!sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0; !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0 && readBuf.Length > 0;
AaruLogging.Debug(ATA_MODULE_NAME, AaruLogging.Debug(ATA_MODULE_NAME,
Localization.Core.Sense_0_Status_1_Error_2_Length_3, Localization.Core.Sense_0_Status_1_Error_2_Length_3,
sense, sense,
errorLba.Status, errorLba.Status,
errorLba.Error, errorLba.Error,
readBuf.Length); readBuf.Length);
capabilities.ReadDmaRetryLbaData = readBuf; capabilities.ReadDmaRetryLbaData = readBuf;
@@ -814,10 +814,10 @@ public sealed partial class DeviceReport
capabilities.SupportsSeekLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0; capabilities.SupportsSeekLba = !sense && (errorLba.Status & 0x01) != 0x01 && errorLba.Error == 0;
AaruLogging.Debug(ATA_MODULE_NAME, AaruLogging.Debug(ATA_MODULE_NAME,
Localization.Core.Sense_0_Status_1_Error_2, Localization.Core.Sense_0_Status_1_Error_2,
sense, sense,
errorLba.Status, errorLba.Status,
errorLba.Error); errorLba.Error);
Spectre.ProgressSingleSpinner(ctx => Spectre.ProgressSingleSpinner(ctx =>
{ {
@@ -829,11 +829,11 @@ public sealed partial class DeviceReport
!sense && (errorLba48.Status & 0x01) != 0x01 && errorLba48.Error == 0 && readBuf.Length > 0; !sense && (errorLba48.Status & 0x01) != 0x01 && errorLba48.Error == 0 && readBuf.Length > 0;
AaruLogging.Debug(ATA_MODULE_NAME, AaruLogging.Debug(ATA_MODULE_NAME,
Localization.Core.Sense_0_Status_1_Error_2_Length_3, Localization.Core.Sense_0_Status_1_Error_2_Length_3,
sense, sense,
errorLba48.Status, errorLba48.Status,
errorLba48.Error, errorLba48.Error,
readBuf.Length); readBuf.Length);
capabilities.ReadLba48Data = readBuf; capabilities.ReadLba48Data = readBuf;
@@ -847,11 +847,11 @@ public sealed partial class DeviceReport
!sense && (errorLba48.Status & 0x01) != 0x01 && errorLba48.Error == 0 && readBuf.Length > 0; !sense && (errorLba48.Status & 0x01) != 0x01 && errorLba48.Error == 0 && readBuf.Length > 0;
AaruLogging.Debug(ATA_MODULE_NAME, AaruLogging.Debug(ATA_MODULE_NAME,
Localization.Core.Sense_0_Status_1_Error_2_Length_3, Localization.Core.Sense_0_Status_1_Error_2_Length_3,
sense, sense,
errorLba48.Status, errorLba48.Status,
errorLba48.Error, errorLba48.Error,
readBuf.Length); readBuf.Length);
capabilities.ReadDmaLba48Data = readBuf; capabilities.ReadDmaLba48Data = readBuf;
@@ -896,11 +896,11 @@ public sealed partial class DeviceReport
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
AaruLogging.Debug(ATA_MODULE_NAME, AaruLogging.Debug(ATA_MODULE_NAME,
Localization.Core.Sense_0_Status_1_Error_2_Length_3, Localization.Core.Sense_0_Status_1_Error_2_Length_3,
sense, sense,
errorChs.Status, errorChs.Status,
errorChs.Error, errorChs.Error,
readBuf.Length); readBuf.Length);
capabilities.ReadLongData = readBuf; capabilities.ReadLongData = readBuf;
@@ -926,11 +926,11 @@ public sealed partial class DeviceReport
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
AaruLogging.Debug(ATA_MODULE_NAME, AaruLogging.Debug(ATA_MODULE_NAME,
Localization.Core.Sense_0_Status_1_Error_2_Length_3, Localization.Core.Sense_0_Status_1_Error_2_Length_3,
sense, sense,
errorChs.Status, errorChs.Status,
errorChs.Error, errorChs.Error,
readBuf.Length); readBuf.Length);
capabilities.ReadLongRetryData = readBuf; capabilities.ReadLongRetryData = readBuf;
@@ -954,11 +954,11 @@ public sealed partial class DeviceReport
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
AaruLogging.Debug(ATA_MODULE_NAME, AaruLogging.Debug(ATA_MODULE_NAME,
Localization.Core.Sense_0_Status_1_Error_2_Length_3, Localization.Core.Sense_0_Status_1_Error_2_Length_3,
sense, sense,
errorLba.Status, errorLba.Status,
errorLba.Error, errorLba.Error,
readBuf.Length); readBuf.Length);
capabilities.ReadLongLbaData = readBuf; capabilities.ReadLongLbaData = readBuf;
@@ -982,11 +982,11 @@ public sealed partial class DeviceReport
BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead; BitConverter.ToUInt64(readBuf, 0) != checkCorrectRead;
AaruLogging.Debug(ATA_MODULE_NAME, AaruLogging.Debug(ATA_MODULE_NAME,
Localization.Core.Sense_0_Status_1_Error_2_Length_3, Localization.Core.Sense_0_Status_1_Error_2_Length_3,
sense, sense,
errorLba.Status, errorLba.Status,
errorLba.Error, errorLba.Error,
readBuf.Length); readBuf.Length);
capabilities.ReadLongRetryLbaData = readBuf; capabilities.ReadLongRetryLbaData = readBuf;
@@ -998,7 +998,7 @@ public sealed partial class DeviceReport
/// <returns>IDENTIFY ATA DEVICE response without the private fields</returns> /// <returns>IDENTIFY ATA DEVICE response without the private fields</returns>
public static byte[] ClearIdentify(byte[] buffer) public static byte[] ClearIdentify(byte[] buffer)
{ {
byte[] empty = new byte[512]; var empty = new byte[512];
Array.Copy(empty, 0, buffer, 20, 20); Array.Copy(empty, 0, buffer, 20, 20);
Array.Copy(empty, 0, buffer, 216, 8); Array.Copy(empty, 0, buffer, 216, 8);

View File

@@ -624,7 +624,8 @@ public sealed partial class MediaScan
} }
if(accumulatedSpeedMs < 100) continue; if(accumulatedSpeedMs < 100) continue;
currentSpeed = accumulatedSpeedSectors * blockSize / (1048576 * (accumulatedSpeedMs / 1000.0));
currentSpeed = accumulatedSpeedSectors * blockSize / (1048576 * (accumulatedSpeedMs / 1000.0));
ScanSpeed?.Invoke(i, currentSpeed * 1024); ScanSpeed?.Invoke(i, currentSpeed * 1024);
accumulatedSpeedMs = 0; accumulatedSpeedMs = 0;
accumulatedSpeedSectors = 0; accumulatedSpeedSectors = 0;

View File

@@ -66,14 +66,11 @@ public static class MMC
const string PS2_JAPANESE_HASH = "b82bffb809070d61fe050b7e1545df53d8f3cc648257cdff7502bc0ba6b38870"; const string PS2_JAPANESE_HASH = "b82bffb809070d61fe050b7e1545df53d8f3cc648257cdff7502bc0ba6b38870";
const string MODULE_NAME = "Media detection"; const string MODULE_NAME = "Media detection";
static readonly byte[] _ps3Id = static readonly byte[] _ps3Id = "PlayStation3\0\0\0\0"u8.ToArray();
"PlayStation3\0\0\0\0"u8.ToArray();
static readonly byte[] _ps4Id = static readonly byte[] _ps4Id = "PlayStation4\0\0\0\0"u8.ToArray();
"PlayStation4\0\0\0\0"u8.ToArray();
static readonly byte[] _ps5Id = static readonly byte[] _ps5Id = "PlayStation5\0\0\0\0"u8.ToArray();
"PlayStation5\0\0\0\0"u8.ToArray();
static readonly byte[] _operaId = [0x01, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x01]; static readonly byte[] _operaId = [0x01, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x01];

View File

@@ -57,17 +57,17 @@ public sealed partial class Sidecar
static void LinearMedia(IByteAddressableImage image, Guid filterId, string imagePath, FileInfo fi, static void LinearMedia(IByteAddressableImage image, Guid filterId, string imagePath, FileInfo fi,
PluginRegister plugins, List<CommonTypes.AaruMetadata.Checksum> imgChecksums, PluginRegister plugins, List<CommonTypes.AaruMetadata.Checksum> imgChecksums,
ref Metadata sidecar, Encoding encoding) => sidecar.LinearMedias = ref Metadata sidecar, Encoding encoding) => sidecar.LinearMedias =
[ [
new LinearMedia new LinearMedia
{ {
Checksums = imgChecksums, Checksums = imgChecksums,
Image = new Image Image = new Image
{ {
Format = image.Format, Format = image.Format,
Offset = 0, Offset = 0,
Value = Path.GetFileName(imagePath) Value = Path.GetFileName(imagePath)
}, },
Size = image.Info.Sectors Size = image.Info.Sectors
} }
]; ];
} }

View File

@@ -148,7 +148,7 @@ public sealed partial class Sidecar
else else
{ {
AaruLogging.Error(Localization.Core AaruLogging.Error(Localization.Core
.The_specified_image_says_it_contains_an_optical_media_but_at_the_same_time_says_it_does_not_support_them); .The_specified_image_says_it_contains_an_optical_media_but_at_the_same_time_says_it_does_not_support_them);
AaruLogging.Error(Localization.Core.Please_open_an_issue_at_Github); AaruLogging.Error(Localization.Core.Please_open_an_issue_at_Github);
} }
@@ -160,7 +160,7 @@ public sealed partial class Sidecar
else else
{ {
AaruLogging.Error(Localization.Core AaruLogging.Error(Localization.Core
.The_specified_image_says_it_contains_a_block_addressable_media_but_at_the_same_time_says_it_does_not_support_them); .The_specified_image_says_it_contains_a_block_addressable_media_but_at_the_same_time_says_it_does_not_support_them);
AaruLogging.Error(Localization.Core.Please_open_an_issue_at_Github); AaruLogging.Error(Localization.Core.Please_open_an_issue_at_Github);
} }
@@ -181,7 +181,7 @@ public sealed partial class Sidecar
else else
{ {
AaruLogging.Error(Localization.Core AaruLogging.Error(Localization.Core
.The_specified_image_says_it_contains_a_byte_addressable_media_but_at_the_same_time_says_it_does_not_support_them); .The_specified_image_says_it_contains_a_byte_addressable_media_but_at_the_same_time_says_it_does_not_support_them);
AaruLogging.Error(Localization.Core.Please_open_an_issue_at_Github); AaruLogging.Error(Localization.Core.Please_open_an_issue_at_Github);
} }

View File

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

View File

@@ -88,9 +88,7 @@ public static class BCA
if(BCAResponse.Length != 68) if(BCAResponse.Length != 68)
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, Localization.Found_incorrect_Blu_ray_BCA_size_0_bytes, BCAResponse.Length);
Localization.Found_incorrect_Blu_ray_BCA_size_0_bytes,
BCAResponse.Length);
return null; return null;
} }
@@ -125,7 +123,7 @@ public static class BCA
#endif #endif
sb.AppendLine(Localization.Blu_ray_Burst_Cutting_Area_in_hex_follows); sb.AppendLine(Localization.Blu_ray_Burst_Cutting_Area_in_hex_follows);
sb.AppendLine(Markup.Escape(PrintHex.ByteArrayToHexArrayString(response.BCA, color:true))); sb.AppendLine(Markup.Escape(PrintHex.ByteArrayToHexArrayString(response.BCA, color: true)));
return sb.ToString(); return sb.ToString();
} }

View File

@@ -103,8 +103,8 @@ public static class Cartridge
if(CSResponse.Length != 8) if(CSResponse.Length != 8)
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.Found_incorrect_Blu_ray_Cartridge_Status_size_0_bytes, Localization.Found_incorrect_Blu_ray_Cartridge_Status_size_0_bytes,
CSResponse.Length); CSResponse.Length);
return null; return null;
} }

View File

@@ -91,9 +91,8 @@ public static class Spare
if(SAIResponse.Length != 16) if(SAIResponse.Length != 16)
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization Localization.Spare_Decode_Found_incorrect_Blu_ray_Spare_Area_Information_size_0_bytes,
.Spare_Decode_Found_incorrect_Blu_ray_Spare_Area_Information_size_0_bytes, SAIResponse.Length);
SAIResponse.Length);
return null; return null;
} }

View File

@@ -68,9 +68,8 @@ public static class ATIP
if(CDATIPResponse.Length != 32 && CDATIPResponse.Length != 28) if(CDATIPResponse.Length != 32 && CDATIPResponse.Length != 28)
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization Localization.Expected_CD_ATIP_size_32_bytes_is_not_received_size_0_bytes_not_decoding,
.Expected_CD_ATIP_size_32_bytes_is_not_received_size_0_bytes_not_decoding, CDATIPResponse.Length);
CDATIPResponse.Length);
return null; return null;
} }

View File

@@ -119,15 +119,14 @@ public static class CDTextOnLeadIn
if(decoded.DataLength + 2 != CDTextResponse.Length) if(decoded.DataLength + 2 != CDTextResponse.Length)
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization Localization.Expected_CD_TEXT_size_0_bytes_is_not_received_size_1_bytes_not_decoding,
.Expected_CD_TEXT_size_0_bytes_is_not_received_size_1_bytes_not_decoding, decoded.DataLength + 2,
decoded.DataLength + 2, CDTextResponse.Length);
CDTextResponse.Length);
return null; return null;
} }
for(int i = 0; i < (decoded.DataLength - 2) / 18; i++) for(var i = 0; i < (decoded.DataLength - 2) / 18; i++)
{ {
decoded.DataPacks[i].HeaderID1 = CDTextResponse[0 + i * 18 + 4]; decoded.DataPacks[i].HeaderID1 = CDTextResponse[0 + i * 18 + 4];
decoded.DataPacks[i].HeaderID2 = CDTextResponse[1 + i * 18 + 4]; decoded.DataPacks[i].HeaderID2 = CDTextResponse[1 + i * 18 + 4];

View File

@@ -72,15 +72,15 @@ public static class Session
if(decoded.DataLength + 2 != CDSessionInfoResponse.Length) if(decoded.DataLength + 2 != CDSessionInfoResponse.Length)
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization Localization
.Expected_CDSessionInfo_size_0_bytes_is_not_received_size_1_bytes_not_decoding, .Expected_CDSessionInfo_size_0_bytes_is_not_received_size_1_bytes_not_decoding,
decoded.DataLength + 2, decoded.DataLength + 2,
CDSessionInfoResponse.Length); CDSessionInfoResponse.Length);
return null; return null;
} }
for(int i = 0; i < (decoded.DataLength - 2) / 8; i++) for(var i = 0; i < (decoded.DataLength - 2) / 8; i++)
{ {
decoded.TrackDescriptors[i].Reserved1 = CDSessionInfoResponse[0 + i * 8 + 4]; decoded.TrackDescriptors[i].Reserved1 = CDSessionInfoResponse[0 + i * 8 + 4];
decoded.TrackDescriptors[i].ADR = (byte)((CDSessionInfoResponse[1 + i * 8 + 4] & 0xF0) >> 4); decoded.TrackDescriptors[i].ADR = (byte)((CDSessionInfoResponse[1 + i * 8 + 4] & 0xF0) >> 4);

View File

@@ -75,15 +75,14 @@ public static class TOC
if(decoded.DataLength + 2 != CDTOCResponse.Length) if(decoded.DataLength + 2 != CDTOCResponse.Length)
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization Localization.Expected_CD_TOC_size_0_bytes_is_not_received_size_1_bytes_not_decoding,
.Expected_CD_TOC_size_0_bytes_is_not_received_size_1_bytes_not_decoding, decoded.DataLength + 2,
decoded.DataLength + 2, CDTOCResponse.Length);
CDTOCResponse.Length);
return null; return null;
} }
for(int i = 0; i < (decoded.DataLength - 2) / 8; i++) for(var i = 0; i < (decoded.DataLength - 2) / 8; i++)
{ {
decoded.TrackDescriptors[i].Reserved1 = CDTOCResponse[0 + i * 8 + 4]; decoded.TrackDescriptors[i].Reserved1 = CDTOCResponse[0 + i * 8 + 4];
decoded.TrackDescriptors[i].ADR = (byte)((CDTOCResponse[1 + i * 8 + 4] & 0xF0) >> 4); decoded.TrackDescriptors[i].ADR = (byte)((CDTOCResponse[1 + i * 8 + 4] & 0xF0) >> 4);

View File

@@ -158,24 +158,24 @@ public static class Apple2
{ {
if(data is not { Length: 410 }) return null; if(data is not { Length: 410 }) return null;
byte[] buffer = new byte[data.Length]; var buffer = new byte[data.Length];
byte carry = 0; byte carry = 0;
for(int i = 0; i < data.Length; i++) for(var i = 0; i < data.Length; i++)
{ {
carry ^= ReadTable5and3[data[i]]; carry ^= ReadTable5and3[data[i]];
buffer[i] = carry; buffer[i] = carry;
} }
byte[] output = new byte[256]; var output = new byte[256];
for(int i = 0; i < 51; i++) for(var i = 0; i < 51; i++)
{ {
byte b1 = buffer[51 * 3 - i]; byte b1 = buffer[51 * 3 - i];
byte b2 = buffer[51 * 2 - i]; byte b2 = buffer[51 * 2 - i];
byte b3 = buffer[51 - i]; byte b3 = buffer[51 - i];
byte b4 = (byte)(((b1 & 2) << 1 | b2 & 2 | (b3 & 2) >> 1) & 0xFF); var b4 = (byte)(((b1 & 2) << 1 | b2 & 2 | (b3 & 2) >> 1) & 0xFF);
byte b5 = (byte)(((b1 & 1) << 2 | (b2 & 1) << 1 | b3 & 1) & 0xFF); var b5 = (byte)(((b1 & 1) << 2 | (b2 & 1) << 1 | b3 & 1) & 0xFF);
output[250 - 5 * i] = (byte)((buffer[i + 51 * 3 + 1] << 3 | b1 >> 2 & 0x7) & 0xFF); output[250 - 5 * i] = (byte)((buffer[i + 51 * 3 + 1] << 3 | b1 >> 2 & 0x7) & 0xFF);
output[251 - 5 * i] = (byte)((buffer[i + 51 * 4 + 1] << 3 | b2 >> 2 & 0x7) & 0xFF); output[251 - 5 * i] = (byte)((buffer[i + 51 * 4 + 1] << 3 | b2 >> 2 & 0x7) & 0xFF);
output[252 - 5 * i] = (byte)((buffer[i + 51 * 5 + 1] << 3 | b3 >> 2 & 0x7) & 0xFF); output[252 - 5 * i] = (byte)((buffer[i + 51 * 5 + 1] << 3 | b3 >> 2 & 0x7) & 0xFF);
@@ -194,16 +194,16 @@ public static class Apple2
{ {
if(data is not { Length: 342 }) return null; if(data is not { Length: 342 }) return null;
byte[] buffer = new byte[data.Length]; var buffer = new byte[data.Length];
byte carry = 0; byte carry = 0;
for(int i = 0; i < data.Length; i++) for(var i = 0; i < data.Length; i++)
{ {
carry ^= ReadTable6and2[data[i]]; carry ^= ReadTable6and2[data[i]];
buffer[i] = carry; buffer[i] = carry;
} }
byte[] output = new byte[256]; var output = new byte[256];
for(uint i = 0; i < 256; i++) for(uint i = 0; i < 256; i++)
{ {
@@ -284,39 +284,39 @@ public static class Apple2
}; };
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.Volume_0, Localization.Volume_0,
((sector.addressField.volume[0] & 0x55) << 1 | ((sector.addressField.volume[0] & 0x55) << 1 |
sector.addressField.volume[1] & 0x55) & sector.addressField.volume[1] & 0x55) &
0xFF); 0xFF);
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Core.Track_0, Core.Track_0,
((sector.addressField.track[0] & 0x55) << 1 | ((sector.addressField.track[0] & 0x55) << 1 |
sector.addressField.track[1] & 0x55) & sector.addressField.track[1] & 0x55) &
0xFF); 0xFF);
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.Sector_0, Localization.Sector_0,
((sector.addressField.sector[0] & 0x55) << 1 | ((sector.addressField.sector[0] & 0x55) << 1 |
sector.addressField.sector[1] & 0x55) & sector.addressField.sector[1] & 0x55) &
0xFF); 0xFF);
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.Checksum_0, Localization.Checksum_0,
((sector.addressField.checksum[0] & 0x55) << 1 | ((sector.addressField.checksum[0] & 0x55) << 1 |
sector.addressField.checksum[1] & 0x55) & sector.addressField.checksum[1] & 0x55) &
0xFF); 0xFF);
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.Epilogue_0_1_2, Localization.Epilogue_0_1_2,
sector.addressField.epilogue[0], sector.addressField.epilogue[0],
sector.addressField.epilogue[1], sector.addressField.epilogue[1],
sector.addressField.epilogue[2]); sector.addressField.epilogue[2]);
position += 14; position += 14;
int syncCount = 0; var syncCount = 0;
bool onSync = false; var onSync = false;
var gaps = new MemoryStream(); var gaps = new MemoryStream();
while(data[position] == 0xFF) while(data[position] == 0xFF)
{ {
@@ -358,9 +358,7 @@ public static class Apple2
sector.dataField.data = gaps.ToArray(); sector.dataField.data = gaps.ToArray();
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, Localization.Data_has_0_bytes, sector.dataField.data.Length);
Localization.Data_has_0_bytes,
sector.dataField.data.Length);
sector.dataField.checksum = data[position]; sector.dataField.checksum = data[position];
sector.dataField.epilogue = new byte[3]; sector.dataField.epilogue = new byte[3];
@@ -454,12 +452,12 @@ public static class Apple2
public static RawTrack MarshalTrack(byte[] data, out int endOffset, int offset = 0) public static RawTrack MarshalTrack(byte[] data, out int endOffset, int offset = 0)
{ {
int position = offset; int position = offset;
bool firstSector = true; var firstSector = true;
bool onSync = false; var onSync = false;
var gaps = new MemoryStream(); var gaps = new MemoryStream();
int count = 0; var count = 0;
List<RawSector> sectors = []; List<RawSector> sectors = [];
byte[] trackNumber = new byte[2]; var trackNumber = new byte[2];
endOffset = offset; endOffset = offset;
while(position < data.Length && data[position] == 0xFF) while(position < data.Length && data[position] == 0xFF)
@@ -496,13 +494,11 @@ public static class Apple2
} }
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.Adding_sector_0_of_track_1, Localization.Adding_sector_0_of_track_1,
((sector.addressField.sector[0] & 0x55) << 1 | ((sector.addressField.sector[0] & 0x55) << 1 | sector.addressField.sector[1] & 0x55) &
sector.addressField.sector[1] & 0x55) & 0xFF,
0xFF, ((sector.addressField.track[0] & 0x55) << 1 | sector.addressField.track[1] & 0x55) &
((sector.addressField.track[0] & 0x55) << 1 | 0xFF);
sector.addressField.track[1] & 0x55) &
0xFF);
sectors.Add(sector); sectors.Add(sector);
} }

View File

@@ -119,7 +119,8 @@ public static partial class Modes
{ {
if(header.Value.MediumType != MediumTypes.Default) if(header.Value.MediumType != MediumTypes.Default)
{ {
sb.AppendFormat($"\t[slateblue1]{Localization.Medium_is_0}[/]", $"[italic][fuchsia]{GetMediumTypeDescription(header.Value.MediumType)}[/][/]") sb.AppendFormat($"\t[slateblue1]{Localization.Medium_is_0}[/]",
$"[italic][fuchsia]{GetMediumTypeDescription(header.Value.MediumType)}[/][/]")
.AppendLine(); .AppendLine();
} }
@@ -160,18 +161,20 @@ public static partial class Modes
{ {
if(descriptor.Blocks == 0) if(descriptor.Blocks == 0)
{ {
sb.AppendFormat($"\t[slateblue1]{Localization.All_remaining_blocks_have_0_and_are_1_bytes_each}[/]", sb
$"[lime]{density}[/]", .AppendFormat($"\t[slateblue1]{Localization.All_remaining_blocks_have_0_and_are_1_bytes_each}[/]",
$"[lime]{descriptor.BlockLength}[/]") $"[lime]{density}[/]",
.AppendLine(); $"[lime]{descriptor.BlockLength}[/]")
.AppendLine();
} }
else else
{ {
sb.AppendFormat($"\t[slateblue1]{Localization._0_blocks_have_1_and_are_2_bytes_each}[/]", sb
$"[lime]{descriptor.Blocks}[/]", .AppendFormat($"\t[slateblue1]{Localization._0_blocks_have_1_and_are_2_bytes_each}[/]",
$"[lime]{density}[/]", $"[lime]{descriptor.Blocks}[/]",
$"[lime{descriptor.BlockLength}[/]") $"[lime]{density}[/]",
.AppendLine(); $"[lime{descriptor.BlockLength}[/]")
.AppendLine();
} }
} }
else if(descriptor.Blocks == 0) else if(descriptor.Blocks == 0)
@@ -211,11 +214,12 @@ public static partial class Modes
break; break;
case 2: case 2:
sb.AppendLine($"\t[green]{ sb.AppendLine($"\t[green]{
Localization.Device_uses_a_write_cache_but_doesn_t_return_until_cache_is_flushed}[/]"); Localization.Device_uses_a_write_cache_but_doesn_t_return_until_cache_is_flushed}[/]");
break; break;
default: default:
sb.AppendFormat($"\t[green]{Localization.Unknown_buffered_mode_code_0}[/]", $"[teal]{header.Value.BufferedMode}[/]") sb.AppendFormat($"\t[green]{Localization.Unknown_buffered_mode_code_0}[/]",
$"[teal]{header.Value.BufferedMode}[/]")
.AppendLine(); .AppendLine();
break; break;
@@ -224,7 +228,8 @@ public static partial class Modes
if(header.Value.Speed == 0) if(header.Value.Speed == 0)
sb.AppendLine($"\t[green]{Localization.Device_uses_default_speed}[/]"); sb.AppendLine($"\t[green]{Localization.Device_uses_default_speed}[/]");
else else
sb.AppendFormat($"\t[green]{Localization.Device_uses_speed_0}[/]", $"[teal]{header.Value.Speed}[/]").AppendLine(); sb.AppendFormat($"\t[green]{Localization.Device_uses_speed_0}[/]", $"[teal]{header.Value.Speed}[/]")
.AppendLine();
if(header.Value.WriteProtected) sb.AppendLine($"\t[red]{Localization.Medium_is_write_protected}[/]"); if(header.Value.WriteProtected) sb.AppendLine($"\t[red]{Localization.Medium_is_write_protected}[/]");
@@ -1086,15 +1091,15 @@ public static partial class Modes
if(descriptor.BlockLength == 0) if(descriptor.BlockLength == 0)
{ {
sb.AppendFormat($"\t[slateblue1]{ sb.AppendFormat($"\t[slateblue1]{
Localization Localization
.All_remaining_blocks_conform_to_0_and_have_a_variable_length}[/]", .All_remaining_blocks_conform_to_0_and_have_a_variable_length}[/]",
$"[fuchsia]{density}[/]") $"[fuchsia]{density}[/]")
.AppendLine(); .AppendLine();
} }
else else
{ {
sb.AppendFormat($"\t[slateblue1]{ sb.AppendFormat($"\t[slateblue1]{
Localization.All_remaining_blocks_conform_to_0_and_are_1_bytes_each}[/]", Localization.All_remaining_blocks_conform_to_0_and_are_1_bytes_each}[/]",
$"[fuchsia]{density}[/]", $"[fuchsia]{density}[/]",
$"[teal]{descriptor.BlockLength}[/]") $"[teal]{descriptor.BlockLength}[/]")
.AppendLine(); .AppendLine();
@@ -1102,37 +1107,42 @@ public static partial class Modes
} }
else if(descriptor.BlockLength == 0) else if(descriptor.BlockLength == 0)
{ {
sb.AppendFormat($"\t[slateblue1]{Localization._0_blocks_conform_to_1_and_have_a_variable_length}[/]", sb
$"[teal]{descriptor.Blocks}[/]", .AppendFormat($"\t[slateblue1]{Localization._0_blocks_conform_to_1_and_have_a_variable_length}[/]",
$"[fuchsia]{density}[/]") $"[teal]{descriptor.Blocks}[/]",
.AppendLine(); $"[fuchsia]{density}[/]")
.AppendLine();
} }
else else
{ {
sb.AppendFormat($"\t[slateblue1]{Localization._0_blocks_conform_to_1_and_are_2_bytes_each}[/]", sb
$"[teal]{descriptor.Blocks}[/]", .AppendFormat($"\t[slateblue1]{Localization._0_blocks_conform_to_1_and_are_2_bytes_each}[/]",
$"[fuchsia]{density}[/]", $"[teal]{descriptor.Blocks}[/]",
$"[teal]{descriptor.BlockLength}[/]") $"[fuchsia]{density}[/]",
.AppendLine(); $"[teal]{descriptor.BlockLength}[/]")
.AppendLine();
} }
} }
else if(descriptor.Blocks == 0) else if(descriptor.Blocks == 0)
{ {
if(descriptor.BlockLength == 0) if(descriptor.BlockLength == 0)
{ {
sb.AppendFormat($"\t[slateblue1]{Localization.All_remaining_blocks_have_a_variable_length}[/]") sb
.AppendLine(); .AppendFormat($"\t[slateblue1]{Localization.All_remaining_blocks_have_a_variable_length}[/]")
.AppendLine();
} }
else else
{ {
sb.AppendFormat($"\t[slateblue1]{Localization.All_remaining_blocks_are_0_bytes_each}[/]", sb
$"[teal]{descriptor.BlockLength}[/]") .AppendFormat($"\t[slateblue1]{Localization.All_remaining_blocks_are_0_bytes_each}[/]",
.AppendLine(); $"[teal]{descriptor.BlockLength}[/]")
.AppendLine();
} }
} }
else if(descriptor.BlockLength == 0) else if(descriptor.BlockLength == 0)
{ {
sb.AppendFormat($"\t[slateblue1]{Localization._0_blocks_have_a_variable_length}[/]", $"[teal]{descriptor.Blocks}[/]") sb.AppendFormat($"\t[slateblue1]{Localization._0_blocks_have_a_variable_length}[/]",
$"[teal]{descriptor.Blocks}[/]")
.AppendLine(); .AppendLine();
} }
else else
@@ -1165,7 +1175,8 @@ public static partial class Modes
break; break;
default: default:
sb.AppendFormat($"\t[red]{Localization.Unknown_buffered_mode_code_0}[/]", $"[teal]{header.Value.BufferedMode}[/]") sb.AppendFormat($"\t[red]{Localization.Unknown_buffered_mode_code_0}[/]",
$"[teal]{header.Value.BufferedMode}[/]")
.AppendLine(); .AppendLine();
break; break;
@@ -1215,7 +1226,8 @@ public static partial class Modes
break; break;
default: default:
sb.AppendFormat(Localization.an_unknown_medium_type_0, $"[teal]{(byte)header.Value.MediumType}[/]"); sb.AppendFormat(Localization.an_unknown_medium_type_0,
$"[teal]{(byte)header.Value.MediumType}[/]");
break; break;
} }
@@ -1225,7 +1237,8 @@ public static partial class Modes
if(header.Value.WriteProtected) sb.AppendLine($"\t[red]{Localization.Medium_is_write_protected}[/]"); if(header.Value.WriteProtected) sb.AppendLine($"\t[red]{Localization.Medium_is_write_protected}[/]");
if(header.Value.EBC) sb.AppendLine($"\t[green]{Localization.Blank_checking_during_write_is_enabled}[/]"); if(header.Value.EBC)
sb.AppendLine($"\t[green]{Localization.Blank_checking_during_write_is_enabled}[/]");
if(header.Value.DPOFUA) sb.AppendLine($"\t[green]{Localization.Drive_supports_DPO_and_FUA_bits}[/]"); if(header.Value.DPOFUA) sb.AppendLine($"\t[green]{Localization.Drive_supports_DPO_and_FUA_bits}[/]");
@@ -1288,24 +1301,26 @@ public static partial class Modes
if(descriptor.BlockLength == 0) if(descriptor.BlockLength == 0)
{ {
sb.AppendFormat($"\t[slateblue1]{ sb.AppendFormat($"\t[slateblue1]{
Localization.All_remaining_blocks_are_0_and_have_a_variable_length}[/]", Localization.All_remaining_blocks_are_0_and_have_a_variable_length}[/]",
$"[fuchsia]{density}[/]") $"[fuchsia]{density}[/]")
.AppendLine(); .AppendLine();
} }
else else
{ {
sb.AppendFormat($"\t[slateblue1]{Localization.All_remaining_blocks_are_0_and_are_1_bytes_each}[/]", sb
$"[fuchsia]{density}[/]", .AppendFormat($"\t[slateblue1]{Localization.All_remaining_blocks_are_0_and_are_1_bytes_each}[/]",
$"[teal]{descriptor.BlockLength}[/]") $"[fuchsia]{density}[/]",
.AppendLine(); $"[teal]{descriptor.BlockLength}[/]")
.AppendLine();
} }
} }
else if(descriptor.BlockLength == 0) else if(descriptor.BlockLength == 0)
{ {
sb.AppendFormat($"\t[slateblue1]{Localization._0_blocks_are_1_and_have_a_variable_length}[/]", sb
$"[teal]{descriptor.Blocks}[/]", .AppendFormat($"\t[slateblue1]{Localization._0_blocks_are_1_and_have_a_variable_length}[/]",
$"[fuchsia]{density}[/]") $"[teal]{descriptor.Blocks}[/]",
.AppendLine(); $"[fuchsia]{density}[/]")
.AppendLine();
} }
else else
{ {
@@ -1320,19 +1335,22 @@ public static partial class Modes
{ {
if(descriptor.BlockLength == 0) if(descriptor.BlockLength == 0)
{ {
sb.AppendFormat($"\t[slateblue1]{Localization.All_remaining_blocks_have_a_variable_length}[/]") sb
.AppendLine(); .AppendFormat($"\t[slateblue1]{Localization.All_remaining_blocks_have_a_variable_length}[/]")
.AppendLine();
} }
else else
{ {
sb.AppendFormat($"\t[slateblue1]{Localization.All_remaining_blocks_are_0_bytes_each}[/]", sb
$"[teal]{descriptor.BlockLength}[/]") .AppendFormat($"\t[slateblue1]{Localization.All_remaining_blocks_are_0_bytes_each}[/]",
.AppendLine(); $"[teal]{descriptor.BlockLength}[/]")
.AppendLine();
} }
} }
else if(descriptor.BlockLength == 0) else if(descriptor.BlockLength == 0)
{ {
sb.AppendFormat($"\t[slateblue1]{Localization._0_blocks_have_a_variable_length}[/]", $"[teal]{descriptor.Blocks}[/]") sb.AppendFormat($"\t[slateblue1]{Localization._0_blocks_have_a_variable_length}[/]",
$"[teal]{descriptor.Blocks}[/]")
.AppendLine(); .AppendLine();
} }
else else
@@ -1503,7 +1521,8 @@ public static partial class Modes
break; break;
default: default:
sb.AppendFormat(Localization.Unknown_medium_type_0, $"[teal]{(byte)header.Value.MediumType}[/]"); sb.AppendFormat(Localization.Unknown_medium_type_0,
$"[teal]{(byte)header.Value.MediumType}[/]");
break; break;
} }
@@ -1567,18 +1586,20 @@ public static partial class Modes
{ {
if(descriptor.Blocks == 0) if(descriptor.Blocks == 0)
{ {
sb.AppendFormat($"\t[slateblue1]{Localization.All_remaining_blocks_have_0_and_are_1_bytes_each}[/]", sb
$"[fuchsia]{density}[/]", .AppendFormat($"\t[slateblue1]{Localization.All_remaining_blocks_have_0_and_are_1_bytes_each}[/]",
$"[teal]{descriptor.BlockLength}[/]") $"[fuchsia]{density}[/]",
.AppendLine(); $"[teal]{descriptor.BlockLength}[/]")
.AppendLine();
} }
else else
{ {
sb.AppendFormat($"\t[slateblue1]{Localization._0_blocks_have_1_and_are_2_bytes_each}[/]", sb
$"[teal]{descriptor.Blocks}[/]", .AppendFormat($"\t[slateblue1]{Localization._0_blocks_have_1_and_are_2_bytes_each}[/]",
$"[fuchsia]{density}[/]", $"[teal]{descriptor.Blocks}[/]",
$"[teal]{descriptor.BlockLength}[/]") $"[fuchsia]{density}[/]",
.AppendLine(); $"[teal]{descriptor.BlockLength}[/]")
.AppendLine();
} }
} }
else if(descriptor.Blocks == 0) else if(descriptor.Blocks == 0)

View File

@@ -59,61 +59,55 @@ public static class Dreamcast
IPBin ipbin = Marshal.ByteArrayToStructureLittleEndian<IPBin>(ipbin_sector); IPBin ipbin = Marshal.ByteArrayToStructureLittleEndian<IPBin>(ipbin_sector);
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, "dreamcast_ipbin.maker_id = \"{0}\"", Encoding.ASCII.GetString(ipbin.maker_id));
"dreamcast_ipbin.maker_id = \"{0}\"",
Encoding.ASCII.GetString(ipbin.maker_id));
AaruLogging.Debug(MODULE_NAME, "dreamcast_ipbin.spare_space1 = \"{0}\"", (char)ipbin.spare_space1); AaruLogging.Debug(MODULE_NAME, "dreamcast_ipbin.spare_space1 = \"{0}\"", (char)ipbin.spare_space1);
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"dreamcast_ipbin.dreamcast_media = \"{0}\"", "dreamcast_ipbin.dreamcast_media = \"{0}\"",
Encoding.ASCII.GetString(ipbin.dreamcast_media)); Encoding.ASCII.GetString(ipbin.dreamcast_media));
AaruLogging.Debug(MODULE_NAME, "dreamcast_ipbin.disc_no = {0}", (char)ipbin.disc_no); AaruLogging.Debug(MODULE_NAME, "dreamcast_ipbin.disc_no = {0}", (char)ipbin.disc_no);
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, "dreamcast_ipbin.disc_no_separator = \"{0}\"", (char)ipbin.disc_no_separator);
"dreamcast_ipbin.disc_no_separator = \"{0}\"",
(char)ipbin.disc_no_separator);
AaruLogging.Debug(MODULE_NAME, "dreamcast_ipbin.disc_total_nos = \"{0}\"", (char)ipbin.disc_total_nos); AaruLogging.Debug(MODULE_NAME, "dreamcast_ipbin.disc_total_nos = \"{0}\"", (char)ipbin.disc_total_nos);
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"dreamcast_ipbin.spare_space2 = \"{0}\"", "dreamcast_ipbin.spare_space2 = \"{0}\"",
Encoding.ASCII.GetString(ipbin.spare_space2)); Encoding.ASCII.GetString(ipbin.spare_space2));
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"dreamcast_ipbin.region_codes = \"{0}\"", "dreamcast_ipbin.region_codes = \"{0}\"",
Encoding.ASCII.GetString(ipbin.region_codes)); Encoding.ASCII.GetString(ipbin.region_codes));
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"dreamcast_ipbin.peripherals = \"{0}\"", "dreamcast_ipbin.peripherals = \"{0}\"",
Encoding.ASCII.GetString(ipbin.peripherals)); Encoding.ASCII.GetString(ipbin.peripherals));
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"dreamcast_ipbin.product_no = \"{0}\"", "dreamcast_ipbin.product_no = \"{0}\"",
Encoding.ASCII.GetString(ipbin.product_no)); Encoding.ASCII.GetString(ipbin.product_no));
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"dreamcast_ipbin.product_version = \"{0}\"", "dreamcast_ipbin.product_version = \"{0}\"",
Encoding.ASCII.GetString(ipbin.product_version)); Encoding.ASCII.GetString(ipbin.product_version));
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"dreamcast_ipbin.release_date = \"{0}\"", "dreamcast_ipbin.release_date = \"{0}\"",
Encoding.ASCII.GetString(ipbin.release_date)); Encoding.ASCII.GetString(ipbin.release_date));
AaruLogging.Debug(MODULE_NAME, "dreamcast_ipbin.spare_space3 = \"{0}\"", (char)ipbin.spare_space3); AaruLogging.Debug(MODULE_NAME, "dreamcast_ipbin.spare_space3 = \"{0}\"", (char)ipbin.spare_space3);
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"dreamcast_ipbin.boot_filename = \"{0}\"", "dreamcast_ipbin.boot_filename = \"{0}\"",
Encoding.ASCII.GetString(ipbin.boot_filename)); Encoding.ASCII.GetString(ipbin.boot_filename));
AaruLogging.Debug(MODULE_NAME, "dreamcast_ipbin.producer = \"{0}\"", Encoding.ASCII.GetString(ipbin.producer));
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"dreamcast_ipbin.producer = \"{0}\"", "dreamcast_ipbin.product_name = \"{0}\"",
Encoding.ASCII.GetString(ipbin.producer)); Encoding.ASCII.GetString(ipbin.product_name));
AaruLogging.Debug(MODULE_NAME,
"dreamcast_ipbin.product_name = \"{0}\"",
Encoding.ASCII.GetString(ipbin.product_name));
return Encoding.ASCII.GetString(ipbin.SegaHardwareID) == "SEGA SEGAKATANA " ? ipbin : null; return Encoding.ASCII.GetString(ipbin.SegaHardwareID) == "SEGA SEGAKATANA " ? ipbin : null;
} }
@@ -199,7 +193,7 @@ public static class Dreamcast
} }
} }
int iPeripherals = int.Parse(Encoding.ASCII.GetString(ipbin.peripherals), NumberStyles.HexNumber); var iPeripherals = int.Parse(Encoding.ASCII.GetString(ipbin.peripherals), NumberStyles.HexNumber);
if((iPeripherals & 0x00000001) == 0x00000001) IPBinInformation.AppendLine(Localization.Game_uses_Windows_CE); if((iPeripherals & 0x00000001) == 0x00000001) IPBinInformation.AppendLine(Localization.Game_uses_Windows_CE);

View File

@@ -59,53 +59,47 @@ public static class Saturn
IPBin ipbin = Marshal.ByteArrayToStructureLittleEndian<IPBin>(ipbin_sector); IPBin ipbin = Marshal.ByteArrayToStructureLittleEndian<IPBin>(ipbin_sector);
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, "saturn_ipbin.maker_id = \"{0}\"", Encoding.ASCII.GetString(ipbin.maker_id));
"saturn_ipbin.maker_id = \"{0}\"",
Encoding.ASCII.GetString(ipbin.maker_id)); AaruLogging.Debug(MODULE_NAME, "saturn_ipbin.product_no = \"{0}\"", Encoding.ASCII.GetString(ipbin.product_no));
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"saturn_ipbin.product_no = \"{0}\"", "saturn_ipbin.product_version = \"{0}\"",
Encoding.ASCII.GetString(ipbin.product_no)); Encoding.ASCII.GetString(ipbin.product_version));
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"saturn_ipbin.product_version = \"{0}\"", "saturn_ipbin.release_date = \"{0}\"",
Encoding.ASCII.GetString(ipbin.product_version)); Encoding.ASCII.GetString(ipbin.release_date));
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"saturn_ipbin.release_date = \"{0}\"", "saturn_ipbin.saturn_media = \"{0}\"",
Encoding.ASCII.GetString(ipbin.release_date)); Encoding.ASCII.GetString(ipbin.saturn_media));
AaruLogging.Debug(MODULE_NAME,
"saturn_ipbin.saturn_media = \"{0}\"",
Encoding.ASCII.GetString(ipbin.saturn_media));
AaruLogging.Debug(MODULE_NAME, "saturn_ipbin.disc_no = {0}", (char)ipbin.disc_no); AaruLogging.Debug(MODULE_NAME, "saturn_ipbin.disc_no = {0}", (char)ipbin.disc_no);
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, "saturn_ipbin.disc_no_separator = \"{0}\"", (char)ipbin.disc_no_separator);
"saturn_ipbin.disc_no_separator = \"{0}\"",
(char)ipbin.disc_no_separator);
AaruLogging.Debug(MODULE_NAME, "saturn_ipbin.disc_total_nos = {0}", (char)ipbin.disc_total_nos); AaruLogging.Debug(MODULE_NAME, "saturn_ipbin.disc_total_nos = {0}", (char)ipbin.disc_total_nos);
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"saturn_ipbin.release_date = \"{0}\"", "saturn_ipbin.release_date = \"{0}\"",
Encoding.ASCII.GetString(ipbin.release_date)); Encoding.ASCII.GetString(ipbin.release_date));
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"saturn_ipbin.spare_space1 = \"{0}\"", "saturn_ipbin.spare_space1 = \"{0}\"",
Encoding.ASCII.GetString(ipbin.spare_space1)); Encoding.ASCII.GetString(ipbin.spare_space1));
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"saturn_ipbin.region_codes = \"{0}\"", "saturn_ipbin.region_codes = \"{0}\"",
Encoding.ASCII.GetString(ipbin.region_codes)); Encoding.ASCII.GetString(ipbin.region_codes));
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"saturn_ipbin.peripherals = \"{0}\"", "saturn_ipbin.peripherals = \"{0}\"",
Encoding.ASCII.GetString(ipbin.peripherals)); Encoding.ASCII.GetString(ipbin.peripherals));
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"saturn_ipbin.product_name = \"{0}\"", "saturn_ipbin.product_name = \"{0}\"",
Encoding.ASCII.GetString(ipbin.product_name)); Encoding.ASCII.GetString(ipbin.product_name));
return Encoding.ASCII.GetString(ipbin.SegaHardwareID) == "SEGA SEGASATURN " ? ipbin : null; return Encoding.ASCII.GetString(ipbin.SegaHardwareID) == "SEGA SEGASATURN " ? ipbin : null;
} }

View File

@@ -206,7 +206,7 @@ public partial class Device
public bool Read(out byte[] buffer, out uint[] response, uint lba, uint blockSize, ushort transferLength, public bool Read(out byte[] buffer, out uint[] response, uint lba, uint blockSize, ushort transferLength,
bool byteAddressed, uint timeout, out double duration) bool byteAddressed, uint timeout, out double duration)
{ {
bool sense = true; var sense = true;
buffer = null; buffer = null;
response = null; response = null;
duration = -1; duration = -1;
@@ -320,10 +320,10 @@ public partial class Device
Error = LastError != 0; Error = LastError != 0;
AaruLogging.Debug(MMC_MODULE_NAME, AaruLogging.Debug(MMC_MODULE_NAME,
transferLength > 1 transferLength > 1
? Localization.READ_MULTIPLE_BLOCK_took_0_ms ? Localization.READ_MULTIPLE_BLOCK_took_0_ms
: Localization.READ_SINGLE_BLOCK_took_0_ms, : Localization.READ_SINGLE_BLOCK_took_0_ms,
duration); duration);
return sense; return sense;
} }
@@ -342,9 +342,9 @@ public partial class Device
ushort transferLength, bool byteAddressed, uint timeout, out double duration) ushort transferLength, bool byteAddressed, uint timeout, out double duration)
{ {
buffer = new byte[transferLength * blockSize]; buffer = new byte[transferLength * blockSize];
byte[] blockBuffer = new byte[blockSize]; var blockBuffer = new byte[blockSize];
duration = 0; duration = 0;
bool sense = true; var sense = true;
response = null; response = null;
for(uint i = 0; i < transferLength; i++) for(uint i = 0; i < transferLength; i++)

View File

@@ -53,9 +53,7 @@ public sealed partial class ISO9660
while(off < data.Length) while(off < data.Length)
{ {
entry = Marshal.ByteArrayToStructureBigEndian<PathTableEntry>(data, entry = Marshal.ByteArrayToStructureBigEndian<PathTableEntry>(data, off, Marshal.SizeOf<PathTableEntry>());
off,
Marshal.SizeOf<PathTableEntry>());
if(entry.name_len == 0) break; if(entry.name_len == 0) break;
@@ -91,8 +89,10 @@ public sealed partial class ISO9660
{ {
HighSierraPathTableEntry entry = HighSierraPathTableEntry entry =
Marshal.ByteArrayToStructureBigEndian<HighSierraPathTableEntry>(data, Marshal.ByteArrayToStructureBigEndian<HighSierraPathTableEntry>(data,
off, off,
Marshal.SizeOf<HighSierraPathTableEntry>()); Marshal
.SizeOf<
HighSierraPathTableEntry>());
if(entry.name_len == 0) break; if(entry.name_len == 0) break;

View File

@@ -35,7 +35,6 @@ namespace Aaru.Filesystems;
[SuppressMessage("ReSharper", "UnusedType.Local")] [SuppressMessage("ReSharper", "UnusedType.Local")]
public sealed partial class QNX4 public sealed partial class QNX4
{ {
const string FS_TYPE = "qnx4"; const string FS_TYPE = "qnx4";
readonly byte[] _rootDirFname = readonly byte[] _rootDirFname = "/\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"u8.ToArray();
"/\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"u8.ToArray();
} }

View File

@@ -36,6 +36,5 @@ public sealed partial class Reiser4
const string FS_TYPE = "reiser4"; const string FS_TYPE = "reiser4";
readonly byte[] _magic = readonly byte[] _magic = "ReIsEr4\0\0\0\0\0\0\0\0\0"u8.ToArray();
"ReIsEr4\0\0\0\0\0\0\0\0\0"u8.ToArray();
} }

View File

@@ -36,7 +36,6 @@ namespace Aaru.Filesystems;
[SuppressMessage("ReSharper", "UnusedMember.Local")] [SuppressMessage("ReSharper", "UnusedMember.Local")]
public sealed partial class UDF public sealed partial class UDF
{ {
const string FS_TYPE = "udf"; const string FS_TYPE = "udf";
readonly byte[] _magic = readonly byte[] _magic = "*OSTA UDF Compliant\0\0\0\0"u8.ToArray();
"*OSTA UDF Compliant\0\0\0\0"u8.ToArray();
} }

View File

@@ -91,7 +91,7 @@ public static class DateHandlers
/// <returns>.NET DateTime</returns> /// <returns>.NET DateTime</returns>
public static DateTime HighSierraToDateTime(byte[] vdDateTime) public static DateTime HighSierraToDateTime(byte[] vdDateTime)
{ {
byte[] isoTime = new byte[17]; var isoTime = new byte[17];
Array.Copy(vdDateTime, 0, isoTime, 0, 16); Array.Copy(vdDateTime, 0, isoTime, 0, 16);
return Iso9660ToDateTime(isoTime); return Iso9660ToDateTime(isoTime);
@@ -103,8 +103,8 @@ public static class DateHandlers
/// <returns>.NET DateTime</returns> /// <returns>.NET DateTime</returns>
public static DateTime Iso9660ToDateTime(byte[] vdDateTime) public static DateTime Iso9660ToDateTime(byte[] vdDateTime)
{ {
byte[] twoCharValue = new byte[2]; var twoCharValue = new byte[2];
byte[] fourCharValue = new byte[4]; var fourCharValue = new byte[4];
fourCharValue[0] = vdDateTime[0]; fourCharValue[0] = vdDateTime[0];
fourCharValue[1] = vdDateTime[1]; fourCharValue[1] = vdDateTime[1];
@@ -112,8 +112,8 @@ public static class DateHandlers
fourCharValue[3] = vdDateTime[3]; fourCharValue[3] = vdDateTime[3];
AaruLogging.Debug(ISO9660_MODULE_NAME, AaruLogging.Debug(ISO9660_MODULE_NAME,
"year = \"{0}\"", "year = \"{0}\"",
StringHandlers.CToString(fourCharValue, Encoding.ASCII)); StringHandlers.CToString(fourCharValue, Encoding.ASCII));
if(!int.TryParse(StringHandlers.CToString(fourCharValue, Encoding.ASCII), out int year)) year = 0; if(!int.TryParse(StringHandlers.CToString(fourCharValue, Encoding.ASCII), out int year)) year = 0;
@@ -121,17 +121,15 @@ public static class DateHandlers
twoCharValue[1] = vdDateTime[5]; twoCharValue[1] = vdDateTime[5];
AaruLogging.Debug(ISO9660_MODULE_NAME, AaruLogging.Debug(ISO9660_MODULE_NAME,
"month = \"{0}\"", "month = \"{0}\"",
StringHandlers.CToString(twoCharValue, Encoding.ASCII)); StringHandlers.CToString(twoCharValue, Encoding.ASCII));
if(!int.TryParse(StringHandlers.CToString(twoCharValue, Encoding.ASCII), out int month)) month = 0; if(!int.TryParse(StringHandlers.CToString(twoCharValue, Encoding.ASCII), out int month)) month = 0;
twoCharValue[0] = vdDateTime[6]; twoCharValue[0] = vdDateTime[6];
twoCharValue[1] = vdDateTime[7]; twoCharValue[1] = vdDateTime[7];
AaruLogging.Debug(ISO9660_MODULE_NAME, AaruLogging.Debug(ISO9660_MODULE_NAME, "day = \"{0}\"", StringHandlers.CToString(twoCharValue, Encoding.ASCII));
"day = \"{0}\"",
StringHandlers.CToString(twoCharValue, Encoding.ASCII));
if(!int.TryParse(StringHandlers.CToString(twoCharValue, Encoding.ASCII), out int day)) day = 0; if(!int.TryParse(StringHandlers.CToString(twoCharValue, Encoding.ASCII), out int day)) day = 0;
@@ -139,8 +137,8 @@ public static class DateHandlers
twoCharValue[1] = vdDateTime[9]; twoCharValue[1] = vdDateTime[9];
AaruLogging.Debug(ISO9660_MODULE_NAME, AaruLogging.Debug(ISO9660_MODULE_NAME,
"hour = \"{0}\"", "hour = \"{0}\"",
StringHandlers.CToString(twoCharValue, Encoding.ASCII)); StringHandlers.CToString(twoCharValue, Encoding.ASCII));
if(!int.TryParse(StringHandlers.CToString(twoCharValue, Encoding.ASCII), out int hour)) hour = 0; if(!int.TryParse(StringHandlers.CToString(twoCharValue, Encoding.ASCII), out int hour)) hour = 0;
@@ -148,8 +146,8 @@ public static class DateHandlers
twoCharValue[1] = vdDateTime[11]; twoCharValue[1] = vdDateTime[11];
AaruLogging.Debug(ISO9660_MODULE_NAME, AaruLogging.Debug(ISO9660_MODULE_NAME,
"minute = \"{0}\"", "minute = \"{0}\"",
StringHandlers.CToString(twoCharValue, Encoding.ASCII)); StringHandlers.CToString(twoCharValue, Encoding.ASCII));
if(!int.TryParse(StringHandlers.CToString(twoCharValue, Encoding.ASCII), out int minute)) minute = 0; if(!int.TryParse(StringHandlers.CToString(twoCharValue, Encoding.ASCII), out int minute)) minute = 0;
@@ -157,8 +155,8 @@ public static class DateHandlers
twoCharValue[1] = vdDateTime[13]; twoCharValue[1] = vdDateTime[13];
AaruLogging.Debug(ISO9660_MODULE_NAME, AaruLogging.Debug(ISO9660_MODULE_NAME,
"second = \"{0}\"", "second = \"{0}\"",
StringHandlers.CToString(twoCharValue, Encoding.ASCII)); StringHandlers.CToString(twoCharValue, Encoding.ASCII));
if(!int.TryParse(StringHandlers.CToString(twoCharValue, Encoding.ASCII), out int second)) second = 0; if(!int.TryParse(StringHandlers.CToString(twoCharValue, Encoding.ASCII), out int second)) second = 0;
@@ -166,22 +164,22 @@ public static class DateHandlers
twoCharValue[1] = vdDateTime[15]; twoCharValue[1] = vdDateTime[15];
AaruLogging.Debug(ISO9660_MODULE_NAME, AaruLogging.Debug(ISO9660_MODULE_NAME,
"hundredths = \"{0}\"", "hundredths = \"{0}\"",
StringHandlers.CToString(twoCharValue, Encoding.ASCII)); StringHandlers.CToString(twoCharValue, Encoding.ASCII));
if(!int.TryParse(StringHandlers.CToString(twoCharValue, Encoding.ASCII), out int hundredths)) hundredths = 0; if(!int.TryParse(StringHandlers.CToString(twoCharValue, Encoding.ASCII), out int hundredths)) hundredths = 0;
AaruLogging.Debug(ISO9660_MODULE_NAME, AaruLogging.Debug(ISO9660_MODULE_NAME,
"decodedDT = new DateTime({0}, {1}, {2}, {3}, {4}, {5}, {6}, DateTimeKind.Unspecified);", "decodedDT = new DateTime({0}, {1}, {2}, {3}, {4}, {5}, {6}, DateTimeKind.Unspecified);",
year, year,
month, month,
day, day,
hour, hour,
minute, minute,
second, second,
hundredths * 10); hundredths * 10);
sbyte difference = (sbyte)vdDateTime[16]; var difference = (sbyte)vdDateTime[16];
var decodedDt = new DateTime(year, month, day, hour, minute, second, hundredths * 10, DateTimeKind.Utc); var decodedDt = new DateTime(year, month, day, hour, minute, second, hundredths * 10, DateTimeKind.Utc);
@@ -222,11 +220,11 @@ public static class DateHandlers
int month = dateRecord & 0x000F; int month = dateRecord & 0x000F;
AaruLogging.Debug(PASCAL_MODULE_NAME, AaruLogging.Debug(PASCAL_MODULE_NAME,
"dateRecord = 0x{0:X4}, year = {1}, month = {2}, day = {3}", "dateRecord = 0x{0:X4}, year = {1}, month = {2}, day = {3}",
dateRecord, dateRecord,
year, year,
month, month,
day); day);
return new DateTime(year, month, day); return new DateTime(year, month, day);
} }
@@ -245,18 +243,18 @@ public static class DateHandlers
int second = (time & 0x1F) * 2; int second = (time & 0x1F) * 2;
AaruLogging.Debug(DOS_MODULE_NAME, AaruLogging.Debug(DOS_MODULE_NAME,
"date = 0x{0:X4}, year = {1}, month = {2}, day = {3}", "date = 0x{0:X4}, year = {1}, month = {2}, day = {3}",
date, date,
year, year,
month, month,
day); day);
AaruLogging.Debug(DOS_MODULE_NAME, AaruLogging.Debug(DOS_MODULE_NAME,
"time = 0x{0:X4}, hour = {1}, minute = {2}, second = {3}", "time = 0x{0:X4}, hour = {1}, minute = {2}, second = {3}",
time, time,
hour, hour,
minute, minute,
second); second);
DateTime dosDate; DateTime dosDate;
@@ -277,9 +275,9 @@ public static class DateHandlers
/// <returns>.NET DateTime</returns> /// <returns>.NET DateTime</returns>
public static DateTime CpmToDateTime(byte[] timestamp) public static DateTime CpmToDateTime(byte[] timestamp)
{ {
ushort days = BitConverter.ToUInt16(timestamp, 0); var days = BitConverter.ToUInt16(timestamp, 0);
int hours = timestamp[2]; int hours = timestamp[2];
int minutes = timestamp[3]; int minutes = timestamp[3];
DateTime temp = _amigaEpoch.AddDays(days); DateTime temp = _amigaEpoch.AddDays(days);
temp = temp.AddHours(hours); temp = temp.AddHours(hours);
@@ -304,15 +302,15 @@ public static class DateHandlers
byte minute, byte second, byte centiseconds, byte hundredsOfMicroseconds, byte minute, byte second, byte centiseconds, byte hundredsOfMicroseconds,
byte microseconds) byte microseconds)
{ {
byte specification = (byte)((typeAndTimeZone & 0xF000) >> 12); var specification = (byte)((typeAndTimeZone & 0xF000) >> 12);
long ticks = (long)centiseconds * 100000 + (long)hundredsOfMicroseconds * 1000 + (long)microseconds * 10; long ticks = (long)centiseconds * 100000 + (long)hundredsOfMicroseconds * 1000 + (long)microseconds * 10;
if(specification == 0) if(specification == 0)
return new DateTime(year, month, day, hour, minute, second, DateTimeKind.Utc).AddTicks(ticks); return new DateTime(year, month, day, hour, minute, second, DateTimeKind.Utc).AddTicks(ticks);
ushort preOffset = (ushort)(typeAndTimeZone & 0xFFF); var preOffset = (ushort)(typeAndTimeZone & 0xFFF);
short offset; short offset;
if((preOffset & 0x800) == 0x800) if((preOffset & 0x800) == 0x800)
offset = (short)(preOffset | 0xF000); offset = (short)(preOffset | 0xF000);

View File

@@ -54,16 +54,14 @@ public sealed partial class D88
if(stream.Length < Marshal.SizeOf<Header>()) return false; if(stream.Length < Marshal.SizeOf<Header>()) return false;
byte[] hdrB = new byte[Marshal.SizeOf<Header>()]; var hdrB = new byte[Marshal.SizeOf<Header>()];
stream.EnsureRead(hdrB, 0, hdrB.Length); stream.EnsureRead(hdrB, 0, hdrB.Length);
Header hdr = Marshal.ByteArrayToStructureLittleEndian<Header>(hdrB); Header hdr = Marshal.ByteArrayToStructureLittleEndian<Header>(hdrB);
AaruLogging.Debug(MODULE_NAME, "d88hdr.name = \"{0}\"", StringHandlers.CToString(hdr.name, shiftjis)); AaruLogging.Debug(MODULE_NAME, "d88hdr.name = \"{0}\"", StringHandlers.CToString(hdr.name, shiftjis));
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, "d88hdr.reserved is empty? = {0}", hdr.reserved.SequenceEqual(_reservedEmpty));
"d88hdr.reserved is empty? = {0}",
hdr.reserved.SequenceEqual(_reservedEmpty));
AaruLogging.Debug(MODULE_NAME, "d88hdr.write_protect = 0x{0:X2}", hdr.write_protect); AaruLogging.Debug(MODULE_NAME, "d88hdr.write_protect = 0x{0:X2}", hdr.write_protect);
@@ -77,7 +75,7 @@ public sealed partial class D88
if(!hdr.reserved.SequenceEqual(_reservedEmpty)) return false; if(!hdr.reserved.SequenceEqual(_reservedEmpty)) return false;
int counter = 0; var counter = 0;
foreach(int t in hdr.track_table) foreach(int t in hdr.track_table)
{ {

View File

@@ -48,8 +48,8 @@ public sealed partial class DiskCopy42
{ {
Stream stream = imageFilter.GetDataForkStream(); Stream stream = imageFilter.GetDataForkStream();
stream.Seek(0, SeekOrigin.Begin); stream.Seek(0, SeekOrigin.Begin);
byte[] buffer = new byte[0x58]; var buffer = new byte[0x58];
byte[] pString = new byte[64]; var pString = new byte[64];
stream.EnsureRead(buffer, 0, 0x58); stream.EnsureRead(buffer, 0, 0x58);
// Incorrect pascal string length, not DC42 // Incorrect pascal string length, not DC42
@@ -103,9 +103,7 @@ public sealed partial class DiskCopy42
tmpHeader.Format != kSigmaFormatTwiggy && tmpHeader.Format != kSigmaFormatTwiggy &&
tmpHeader.Format != kNotStandardFormat) tmpHeader.Format != kNotStandardFormat)
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, Localization.Unknown_tmp_header_format_equals_0_value, tmpHeader.Format);
Localization.Unknown_tmp_header_format_equals_0_value,
tmpHeader.Format);
return false; return false;
} }
@@ -119,9 +117,7 @@ public sealed partial class DiskCopy42
tmpHeader.FmtByte != kFmtNotStandard && tmpHeader.FmtByte != kFmtNotStandard &&
tmpHeader.FmtByte != kMacOSXFmtByte) tmpHeader.FmtByte != kMacOSXFmtByte)
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, Localization.Unknown_tmp_header_fmtByte_equals_0_value, tmpHeader.FmtByte);
Localization.Unknown_tmp_header_fmtByte_equals_0_value,
tmpHeader.FmtByte);
return false; return false;
} }

View File

@@ -42,7 +42,7 @@ public sealed partial class DiskDupe
{ {
bool TryReadHeader(Stream stream, ref FileHeader fhdr, ref TrackInfo[] tmap, ref long[] toffsets) bool TryReadHeader(Stream stream, ref FileHeader fhdr, ref TrackInfo[] tmap, ref long[] toffsets)
{ {
byte[] buffer = new byte[6]; var buffer = new byte[6];
FileHeader fHeader; FileHeader fHeader;
stream.Seek(0, SeekOrigin.Begin); stream.Seek(0, SeekOrigin.Begin);
@@ -62,19 +62,19 @@ public sealed partial class DiskDupe
// seek to start of the trackmap // seek to start of the trackmap
stream.Seek(TRACKMAP_OFFSET, SeekOrigin.Begin); stream.Seek(TRACKMAP_OFFSET, SeekOrigin.Begin);
int numTracks = _diskTypes[fHeader.diskType].cyl * _diskTypes[fHeader.diskType].hd; int numTracks = _diskTypes[fHeader.diskType].cyl * _diskTypes[fHeader.diskType].hd;
int trackLen = 512 * _diskTypes[fHeader.diskType].spt; // the length of a single track, in bytes int trackLen = 512 * _diskTypes[fHeader.diskType].spt; // the length of a single track, in bytes
var trackMap = new TrackInfo[numTracks]; var trackMap = new TrackInfo[numTracks];
long[] trackOffsets = new long[numTracks]; var trackOffsets = new long[numTracks];
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.Identified_image_with_CHS_equals_0_1_2, Localization.Identified_image_with_CHS_equals_0_1_2,
_diskTypes[fHeader.diskType].cyl, _diskTypes[fHeader.diskType].cyl,
_diskTypes[fHeader.diskType].hd, _diskTypes[fHeader.diskType].hd,
_diskTypes[fHeader.diskType].spt); _diskTypes[fHeader.diskType].spt);
// read the trackmap and store the track offsets // read the trackmap and store the track offsets
for(int i = 0; i < numTracks; i++) for(var i = 0; i < numTracks; i++)
{ {
stream.EnsureRead(buffer, 0, 6); stream.EnsureRead(buffer, 0, 6);
trackMap[i] = Marshal.ByteArrayToStructureLittleEndian<TrackInfo>(buffer); trackMap[i] = Marshal.ByteArrayToStructureLittleEndian<TrackInfo>(buffer);

View File

@@ -34,6 +34,5 @@ namespace Aaru.Images;
public sealed partial class Nhdr0 public sealed partial class Nhdr0
{ {
readonly byte[] _signature = readonly byte[] _signature = "T98HDDIMAGE.R0\0"u8.ToArray();
"T98HDDIMAGE.R0\0"u8.ToArray();
} }

View File

@@ -54,7 +54,7 @@ public sealed partial class Nhdr0
if(stream.Length < Marshal.SizeOf<Header>()) return false; if(stream.Length < Marshal.SizeOf<Header>()) return false;
byte[] hdrB = new byte[Marshal.SizeOf<Header>()]; var hdrB = new byte[Marshal.SizeOf<Header>()];
stream.EnsureRead(hdrB, 0, hdrB.Length); stream.EnsureRead(hdrB, 0, hdrB.Length);
_nhdhdr = Marshal.ByteArrayToStructureLittleEndian<Header>(hdrB); _nhdhdr = Marshal.ByteArrayToStructureLittleEndian<Header>(hdrB);
@@ -62,14 +62,14 @@ public sealed partial class Nhdr0
if(!_nhdhdr.szFileID.SequenceEqual(_signature)) return false; if(!_nhdhdr.szFileID.SequenceEqual(_signature)) return false;
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"nhdhdr.szFileID = \"{0}\"", "nhdhdr.szFileID = \"{0}\"",
StringHandlers.CToString(_nhdhdr.szFileID, shiftjis)); StringHandlers.CToString(_nhdhdr.szFileID, shiftjis));
AaruLogging.Debug(MODULE_NAME, "nhdhdr.reserved1 = {0}", _nhdhdr.reserved1); AaruLogging.Debug(MODULE_NAME, "nhdhdr.reserved1 = {0}", _nhdhdr.reserved1);
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"nhdhdr.szComment = \"{0}\"", "nhdhdr.szComment = \"{0}\"",
StringHandlers.CToString(_nhdhdr.szComment, shiftjis)); StringHandlers.CToString(_nhdhdr.szComment, shiftjis));
AaruLogging.Debug(MODULE_NAME, "nhdhdr.dwHeadSize = {0}", _nhdhdr.dwHeadSize); AaruLogging.Debug(MODULE_NAME, "nhdhdr.dwHeadSize = {0}", _nhdhdr.dwHeadSize);
AaruLogging.Debug(MODULE_NAME, "nhdhdr.dwCylinder = {0}", _nhdhdr.dwCylinder); AaruLogging.Debug(MODULE_NAME, "nhdhdr.dwCylinder = {0}", _nhdhdr.dwCylinder);

View File

@@ -38,34 +38,33 @@ namespace Aaru.Images;
[SuppressMessage("ReSharper", "UnusedType.Global")] [SuppressMessage("ReSharper", "UnusedType.Global")]
public sealed partial class Partimage public sealed partial class Partimage
{ {
const int MAX_DESCRIPTION = 4096; const int MAX_DESCRIPTION = 4096;
const int MAX_HOSTNAMESIZE = 128; const int MAX_HOSTNAMESIZE = 128;
const int MAX_DEVICENAMELEN = 512; const int MAX_DEVICENAMELEN = 512;
const int MAX_UNAMEINFOLEN = 65; //SYS_NMLN const int MAX_UNAMEINFOLEN = 65; //SYS_NMLN
const int MBR_SIZE_WHOLE = 512; const int MBR_SIZE_WHOLE = 512;
const int MAX_DESC_MODEL = 128; const int MAX_DESC_MODEL = 128;
const int MAX_DESC_GEOMETRY = 1024; const int MAX_DESC_GEOMETRY = 1024;
const int MAX_DESC_IDENTIFY = 4096; const int MAX_DESC_IDENTIFY = 4096;
const int CHECK_FREQUENCY = 65536; const int CHECK_FREQUENCY = 65536;
const string MAGIC_BEGIN_LOCALHEADER = "MAGIC-BEGIN-LOCALHEADER"; const string MAGIC_BEGIN_LOCALHEADER = "MAGIC-BEGIN-LOCALHEADER";
const string MAGIC_BEGIN_DATABLOCKS = "MAGIC-BEGIN-DATABLOCKS"; const string MAGIC_BEGIN_DATABLOCKS = "MAGIC-BEGIN-DATABLOCKS";
const string MAGIC_BEGIN_BITMAP = "MAGIC-BEGIN-BITMAP"; const string MAGIC_BEGIN_BITMAP = "MAGIC-BEGIN-BITMAP";
const string MAGIC_BEGIN_MBRBACKUP = "MAGIC-BEGIN-MBRBACKUP"; const string MAGIC_BEGIN_MBRBACKUP = "MAGIC-BEGIN-MBRBACKUP";
const string MAGIC_BEGIN_TAIL = "MAGIC-BEGIN-TAIL"; const string MAGIC_BEGIN_TAIL = "MAGIC-BEGIN-TAIL";
const string MAGIC_BEGIN_INFO = "MAGIC-BEGIN-INFO"; const string MAGIC_BEGIN_INFO = "MAGIC-BEGIN-INFO";
const string MAGIC_BEGIN_EXT000 = "MAGIC-BEGIN-EXT000"; // reserved for future use const string MAGIC_BEGIN_EXT000 = "MAGIC-BEGIN-EXT000"; // reserved for future use
const string MAGIC_BEGIN_EXT001 = "MAGIC-BEGIN-EXT001"; // reserved for future use const string MAGIC_BEGIN_EXT001 = "MAGIC-BEGIN-EXT001"; // reserved for future use
const string MAGIC_BEGIN_EXT002 = "MAGIC-BEGIN-EXT002"; // reserved for future use const string MAGIC_BEGIN_EXT002 = "MAGIC-BEGIN-EXT002"; // reserved for future use
const string MAGIC_BEGIN_EXT003 = "MAGIC-BEGIN-EXT003"; // reserved for future use const string MAGIC_BEGIN_EXT003 = "MAGIC-BEGIN-EXT003"; // reserved for future use
const string MAGIC_BEGIN_EXT004 = "MAGIC-BEGIN-EXT004"; // reserved for future use const string MAGIC_BEGIN_EXT004 = "MAGIC-BEGIN-EXT004"; // reserved for future use
const string MAGIC_BEGIN_EXT005 = "MAGIC-BEGIN-EXT005"; // reserved for future use const string MAGIC_BEGIN_EXT005 = "MAGIC-BEGIN-EXT005"; // reserved for future use
const string MAGIC_BEGIN_EXT006 = "MAGIC-BEGIN-EXT006"; // reserved for future use const string MAGIC_BEGIN_EXT006 = "MAGIC-BEGIN-EXT006"; // reserved for future use
const string MAGIC_BEGIN_EXT007 = "MAGIC-BEGIN-EXT007"; // reserved for future use const string MAGIC_BEGIN_EXT007 = "MAGIC-BEGIN-EXT007"; // reserved for future use
const string MAGIC_BEGIN_EXT008 = "MAGIC-BEGIN-EXT008"; // reserved for future use const string MAGIC_BEGIN_EXT008 = "MAGIC-BEGIN-EXT008"; // reserved for future use
const string MAGIC_BEGIN_EXT009 = "MAGIC-BEGIN-EXT009"; // reserved for future use const string MAGIC_BEGIN_EXT009 = "MAGIC-BEGIN-EXT009"; // reserved for future use
const string MAGIC_BEGIN_VOLUME = "PaRtImAgE-VoLuMe"; const string MAGIC_BEGIN_VOLUME = "PaRtImAgE-VoLuMe";
const uint MAX_CACHE_SIZE = 16777216; const uint MAX_CACHE_SIZE = 16777216;
const uint MAX_CACHED_SECTORS = MAX_CACHE_SIZE / 512; const uint MAX_CACHED_SECTORS = MAX_CACHE_SIZE / 512;
readonly byte[] _partimageMagic = readonly byte[] _partimageMagic = "PaRtImAgE-VoLuMe\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"u8.ToArray();
"PaRtImAgE-VoLuMe\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"u8.ToArray();
} }

View File

@@ -42,22 +42,22 @@ public sealed partial class TeleDisk
{ {
(ushort cylinder, byte head, byte sector) LbaToChs(ulong lba) (ushort cylinder, byte head, byte sector) LbaToChs(ulong lba)
{ {
ushort cylinder = (ushort)(lba / (_imageInfo.Heads * _imageInfo.SectorsPerTrack)); var cylinder = (ushort)(lba / (_imageInfo.Heads * _imageInfo.SectorsPerTrack));
byte head = (byte)(lba / _imageInfo.SectorsPerTrack % _imageInfo.Heads); var head = (byte)(lba / _imageInfo.SectorsPerTrack % _imageInfo.Heads);
byte sector = (byte)(lba % _imageInfo.SectorsPerTrack + 1); var sector = (byte)(lba % _imageInfo.SectorsPerTrack + 1);
return (cylinder, head, sector); return (cylinder, head, sector);
} }
static ushort TeleDiskCrc(ushort crc, byte[] buffer) static ushort TeleDiskCrc(ushort crc, byte[] buffer)
{ {
int counter = 0; var counter = 0;
while(counter < buffer.Length) while(counter < buffer.Length)
{ {
crc ^= (ushort)((buffer[counter] & 0xFF) << 8); crc ^= (ushort)((buffer[counter] & 0xFF) << 8);
for(int i = 0; i < 8; i++) for(var i = 0; i < 8; i++)
{ {
if((crc & 0x8000) > 0) if((crc & 0x8000) > 0)
crc = (ushort)(crc << 1 ^ TELE_DISK_CRC_POLY); crc = (ushort)(crc << 1 ^ TELE_DISK_CRC_POLY);
@@ -120,16 +120,16 @@ public sealed partial class TeleDisk
break; break;
case DATA_BLOCK_PATTERN: case DATA_BLOCK_PATTERN:
{ {
int ins = 0; var ins = 0;
int outs = 0; var outs = 0;
while(ins < encodedData.Length) while(ins < encodedData.Length)
{ {
byte[] repeatValue = new byte[2]; var repeatValue = new byte[2];
ushort repeatNumber = BitConverter.ToUInt16(encodedData, ins); var repeatNumber = BitConverter.ToUInt16(encodedData, ins);
Array.Copy(encodedData, ins + 2, repeatValue, 0, 2); Array.Copy(encodedData, ins + 2, repeatValue, 0, 2);
byte[] decodedPiece = new byte[repeatNumber * 2]; var decodedPiece = new byte[repeatNumber * 2];
ArrayHelpers.ArrayFill(decodedPiece, repeatValue); ArrayHelpers.ArrayFill(decodedPiece, repeatValue);
Array.Copy(decodedPiece, 0, decodedData, outs, decodedPiece.Length); Array.Copy(decodedPiece, 0, decodedData, outs, decodedPiece.Length);
ins += 4; ins += 4;
@@ -137,27 +137,23 @@ public sealed partial class TeleDisk
} }
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.Block_pattern_decoder_Input_data_size_0_bytes, Localization.Block_pattern_decoder_Input_data_size_0_bytes,
encodedData.Length); encodedData.Length);
AaruLogging.Debug(MODULE_NAME, Localization.Block_pattern_decoder_Processed_input_0_bytes, ins);
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
Localization.Block_pattern_decoder_Processed_input_0_bytes, Localization.Block_pattern_decoder_Output_data_size_0_bytes,
ins); decodedData.Length);
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, Localization.Block_pattern_decoder_Processed_Output_0_bytes, outs);
Localization.Block_pattern_decoder_Output_data_size_0_bytes,
decodedData.Length);
AaruLogging.Debug(MODULE_NAME,
Localization.Block_pattern_decoder_Processed_Output_0_bytes,
outs);
break; break;
} }
case DATA_BLOCK_RLE: case DATA_BLOCK_RLE:
{ {
int ins = 0; var ins = 0;
int outs = 0; var outs = 0;
while(ins < encodedData.Length) while(ins < encodedData.Length)
{ {
@@ -175,10 +171,10 @@ public sealed partial class TeleDisk
else else
{ {
length = (byte)(encoding * 2); length = (byte)(encoding * 2);
byte run = encodedData[ins + 1]; byte run = encodedData[ins + 1];
byte[] part = new byte[length]; var part = new byte[length];
Array.Copy(encodedData, ins + 2, part, 0, length); Array.Copy(encodedData, ins + 2, part, 0, length);
byte[] piece = new byte[length * run]; var piece = new byte[length * run];
ArrayHelpers.ArrayFill(piece, part); ArrayHelpers.ArrayFill(piece, part);
Array.Copy(piece, 0, decodedData, outs, piece.Length); Array.Copy(piece, 0, decodedData, outs, piece.Length);
ins += 2 + length; ins += 2 + length;
@@ -186,15 +182,11 @@ public sealed partial class TeleDisk
} }
} }
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, Localization.RLE_decoder_Input_data_size_0_bytes, encodedData.Length);
Localization.RLE_decoder_Input_data_size_0_bytes,
encodedData.Length);
AaruLogging.Debug(MODULE_NAME, Localization.RLE_decoder_Processed_input_0_bytes, ins); AaruLogging.Debug(MODULE_NAME, Localization.RLE_decoder_Processed_input_0_bytes, ins);
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, Localization.RLE_decoder_Output_data_size_0_bytes, decodedData.Length);
Localization.RLE_decoder_Output_data_size_0_bytes,
decodedData.Length);
AaruLogging.Debug(MODULE_NAME, Localization.RLE_decoder_Processed_Output_0_bytes, outs); AaruLogging.Debug(MODULE_NAME, Localization.RLE_decoder_Processed_Output_0_bytes, outs);
@@ -384,9 +376,9 @@ public sealed partial class TeleDisk
default: default:
{ {
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"Unknown drive type {1} with {0} bytes", "Unknown drive type {1} with {0} bytes",
_totalDiskSize, _totalDiskSize,
_header.DriveType); _header.DriveType);
return MediaType.Unknown; return MediaType.Unknown;
} }

View File

@@ -54,7 +54,7 @@ public sealed partial class Virtual98
if(stream.Length < Marshal.SizeOf<Virtual98Header>()) return false; if(stream.Length < Marshal.SizeOf<Virtual98Header>()) return false;
byte[] hdrB = new byte[Marshal.SizeOf<Virtual98Header>()]; var hdrB = new byte[Marshal.SizeOf<Virtual98Header>()];
stream.EnsureRead(hdrB, 0, hdrB.Length); stream.EnsureRead(hdrB, 0, hdrB.Length);
_v98Hdr = Marshal.ByteArrayToStructureLittleEndian<Virtual98Header>(hdrB); _v98Hdr = Marshal.ByteArrayToStructureLittleEndian<Virtual98Header>(hdrB);
@@ -62,12 +62,10 @@ public sealed partial class Virtual98
if(!_v98Hdr.signature.SequenceEqual(_signature)) return false; if(!_v98Hdr.signature.SequenceEqual(_signature)) return false;
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME,
"v98hdr.signature = \"{0}\"", "v98hdr.signature = \"{0}\"",
StringHandlers.CToString(_v98Hdr.signature, shiftjis)); StringHandlers.CToString(_v98Hdr.signature, shiftjis));
AaruLogging.Debug(MODULE_NAME, AaruLogging.Debug(MODULE_NAME, "v98hdr.comment = \"{0}\"", StringHandlers.CToString(_v98Hdr.comment, shiftjis));
"v98hdr.comment = \"{0}\"",
StringHandlers.CToString(_v98Hdr.comment, shiftjis));
AaruLogging.Debug(MODULE_NAME, "v98hdr.padding = {0}", _v98Hdr.padding); AaruLogging.Debug(MODULE_NAME, "v98hdr.padding = {0}", _v98Hdr.padding);
AaruLogging.Debug(MODULE_NAME, "v98hdr.mbsize = {0}", _v98Hdr.mbsize); AaruLogging.Debug(MODULE_NAME, "v98hdr.mbsize = {0}", _v98Hdr.mbsize);