diff --git a/Aaru.Archives/Aaru.Archives.csproj b/Aaru.Archives/Aaru.Archives.csproj index 6b4abcb8c..55bbaeeab 100644 --- a/Aaru.Archives/Aaru.Archives.csproj +++ b/Aaru.Archives/Aaru.Archives.csproj @@ -54,7 +54,7 @@ - + diff --git a/Aaru.Archives/Amg/Info.cs b/Aaru.Archives/Amg/Info.cs index e361786ea..b8475e46a 100644 --- a/Aaru.Archives/Amg/Info.cs +++ b/Aaru.Archives/Amg/Info.cs @@ -11,10 +11,9 @@ public sealed partial class Amg #region IArchive Members /// - public bool Identify(IFilter filter) - { - return false; -/* + public bool Identify(IFilter filter) => false; + + /* if(filter.DataForkLength < Marshal.SizeOf()) return false; Stream stream = filter.GetDataForkStream(); @@ -29,8 +28,6 @@ public sealed partial class Amg // Not a valid magic return header.magic == ARC_MAGIC; */ - } - /// public void GetInformation(IFilter filter, Encoding encoding, out string information) { @@ -42,7 +39,7 @@ public sealed partial class Amg Stream stream = filter.GetDataForkStream(); stream.Position = 0; - byte[] hdr = new byte[Marshal.SizeOf()]; + var hdr = new byte[Marshal.SizeOf()]; stream.ReadExactly(hdr, 0, hdr.Length); @@ -61,7 +58,7 @@ public sealed partial class Amg if(header.commentLength > 0) { - byte[] buffer = new byte[header.commentLength]; + var buffer = new byte[header.commentLength]; stream.ReadExactly(buffer, 0, buffer.Length); sb.AppendLine(Localization.Archive_comment); sb.AppendLine(Markup.Escape(StringHandlers.CToString(buffer, encoding))); diff --git a/Aaru.Archives/Amg/Open.cs b/Aaru.Archives/Amg/Open.cs index b0207a982..1fcc00774 100644 --- a/Aaru.Archives/Amg/Open.cs +++ b/Aaru.Archives/Amg/Open.cs @@ -20,7 +20,7 @@ public sealed partial class Amg _stream = filter.GetDataForkStream(); _stream.Position = 0; - byte[] hdr = new byte[Marshal.SizeOf()]; + var hdr = new byte[Marshal.SizeOf()]; _stream.ReadExactly(hdr, 0, hdr.Length); @@ -39,7 +39,7 @@ public sealed partial class Amg while(_stream.Position + fileHeaderLen < _stream.Length) { - byte[] fileHdr = new byte[fileHeaderLen]; + var fileHdr = new byte[fileHeaderLen]; _stream.ReadExactly(fileHdr, 0, fileHdr.Length); @@ -65,7 +65,7 @@ public sealed partial class Amg if(fh.pathLength > 0) { - byte[] buffer = new byte[fh.pathLength]; + var buffer = new byte[fh.pathLength]; _stream.ReadExactly(buffer, 0, buffer.Length); string path = StringHandlers.CToString(buffer, encoding); path = path.Replace('\\', Path.DirectorySeparatorChar); @@ -74,7 +74,7 @@ public sealed partial class Amg if(fh.commentLength > 0) { - byte[] buffer = new byte[fh.commentLength]; + var buffer = new byte[fh.commentLength]; _stream.ReadExactly(buffer, 0, buffer.Length); entry.Comment = StringHandlers.CToString(buffer, encoding); } diff --git a/Aaru.Archives/Arc/Info.cs b/Aaru.Archives/Arc/Info.cs index 39418c5de..eafb6f33f 100644 --- a/Aaru.Archives/Arc/Info.cs +++ b/Aaru.Archives/Arc/Info.cs @@ -18,7 +18,7 @@ public sealed partial class Arc Stream stream = filter.GetDataForkStream(); stream.Position = 0; - byte[] hdr = new byte[Marshal.SizeOf
()]; + var hdr = new byte[Marshal.SizeOf
()]; stream.ReadExactly(hdr, 0, hdr.Length); @@ -53,7 +53,7 @@ public sealed partial class Arc Stream stream = filter.GetDataForkStream(); stream.Position = 0; - byte[] hdr = new byte[Marshal.SizeOf
()]; + var hdr = new byte[Marshal.SizeOf
()]; stream.ReadExactly(hdr, 0, hdr.Length); diff --git a/Aaru.Archives/Arc/Open.cs b/Aaru.Archives/Arc/Open.cs index b3c04b4e5..fc656861e 100644 --- a/Aaru.Archives/Arc/Open.cs +++ b/Aaru.Archives/Arc/Open.cs @@ -22,7 +22,7 @@ public sealed partial class Arc _stream = filter.GetDataForkStream(); _stream.Position = 0; - byte[] hdr = new byte[Marshal.SizeOf
()]; + var hdr = new byte[Marshal.SizeOf
()]; _stream.ReadExactly(hdr, 0, hdr.Length); @@ -55,7 +55,7 @@ public sealed partial class Arc ArchiveSupportedFeature.SupportsFilenames | ArchiveSupportedFeature.HasEntryTimestamp; - string path = ""; + var path = ""; string longname = null; string comment = null; string attributes = null; @@ -104,7 +104,7 @@ public sealed partial class Arc if(header.method == Method.FileInformation) { int recordsSize = header.compressed; - int recordsRead = 0; + var recordsRead = 0; while(recordsRead < recordsSize) { diff --git a/Aaru.Archives/Ha/Info.cs b/Aaru.Archives/Ha/Info.cs index 3153d628c..ca4847e6e 100644 --- a/Aaru.Archives/Ha/Info.cs +++ b/Aaru.Archives/Ha/Info.cs @@ -17,7 +17,7 @@ public sealed partial class Ha Stream stream = filter.GetDataForkStream(); stream.Position = 0; - byte[] hdr = new byte[Marshal.SizeOf()]; + var hdr = new byte[Marshal.SizeOf()]; stream.ReadExactly(hdr, 0, hdr.Length); @@ -37,7 +37,7 @@ public sealed partial class Ha Stream stream = filter.GetDataForkStream(); stream.Position = 0; - byte[] hdr = new byte[Marshal.SizeOf()]; + var hdr = new byte[Marshal.SizeOf()]; stream.ReadExactly(hdr, 0, hdr.Length); diff --git a/Aaru.Archives/Ha/Open.cs b/Aaru.Archives/Ha/Open.cs index 5a2fe8567..98c038d3e 100644 --- a/Aaru.Archives/Ha/Open.cs +++ b/Aaru.Archives/Ha/Open.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using System.IO; using System.Text; using Aaru.CommonTypes.Enums; @@ -21,7 +20,7 @@ public sealed partial class Ha _stream = filter.GetDataForkStream(); _stream.Position = 0; - byte[] hdr = new byte[Marshal.SizeOf()]; + var hdr = new byte[Marshal.SizeOf()]; _stream.ReadExactly(hdr, 0, hdr.Length); @@ -32,11 +31,11 @@ public sealed partial class Ha _entries = []; - int fhLen = Marshal.SizeOf(); - byte[] fhBuf = new byte[fhLen]; - byte[] pathBuf = new byte[16384]; - byte[] nameBuf = new byte[256]; - int i; // Guard + int fhLen = Marshal.SizeOf(); + var fhBuf = new byte[fhLen]; + var pathBuf = new byte[16384]; + var nameBuf = new byte[256]; + int i; // Guard while(_stream.Position + fhLen < _stream.Length) { @@ -88,7 +87,7 @@ public sealed partial class Ha int mdiLen = _stream.ReadByte(); - byte[] mdi = new byte[mdiLen]; + var mdi = new byte[mdiLen]; _stream.ReadExactly(mdi, 0, mdiLen); string path = StringHandlers.CToString(pathBuf, encoding); diff --git a/Aaru.Archives/Stfs/Open.cs b/Aaru.Archives/Stfs/Open.cs index 679850ed0..ccf65b492 100644 --- a/Aaru.Archives/Stfs/Open.cs +++ b/Aaru.Archives/Stfs/Open.cs @@ -19,7 +19,7 @@ public sealed partial class Stfs _stream = filter.GetDataForkStream(); _stream.Position = 0; - byte[] hdr = new byte[Marshal.SizeOf()]; + var hdr = new byte[Marshal.SizeOf()]; _stream.ReadExactly(hdr, 0, hdr.Length); @@ -46,13 +46,13 @@ public sealed partial class Stfs int fileTablePosition = BlockToPosition(fileTableBlockNumber, (int)header.Metadata.HeaderSize); - byte[] buffer = new byte[4096 * vd.FileTableBlockCount]; + var buffer = new byte[4096 * vd.FileTableBlockCount]; _stream.Position = fileTablePosition; _stream.ReadExactly(buffer, 0, buffer.Length); List entries = []; int entrySize = Marshal.SizeOf(); - int in_pos = 0; + var in_pos = 0; do { @@ -67,11 +67,11 @@ public sealed partial class Stfs _entries = new FileEntry[entries.Count]; - for(int i = 0; i < entries.Count; i++) + for(var i = 0; i < entries.Count; i++) { // While entries[i].PathIndicator > 0 recursively inversely prepend entries[PathIndicator].Filename to entries[i].Filename - int pathIndicator = entries[i].PathIndicator; - string path = ""; + int pathIndicator = entries[i].PathIndicator; + var path = ""; while(pathIndicator > 0) { diff --git a/Aaru.Archives/Stfs/StfsStream.cs b/Aaru.Archives/Stfs/StfsStream.cs index fcba0c256..5162026dc 100644 --- a/Aaru.Archives/Stfs/StfsStream.cs +++ b/Aaru.Archives/Stfs/StfsStream.cs @@ -54,7 +54,7 @@ public sealed partial class Stfs /// public override int Read(byte[] buffer, int offset, int count) { - int totalRead = 0; + var totalRead = 0; // Validate parameters ArgumentNullException.ThrowIfNull(buffer); @@ -73,7 +73,7 @@ public sealed partial class Stfs _isConsole); // Calculate position within block - int blockOffset = (int)(_position % 0x1000); + var blockOffset = (int)(_position % 0x1000); // Calculate absolute position in the stream long absolutePosition = BlockToPosition(currentBlock, _headerSize) + blockOffset; @@ -138,7 +138,7 @@ public sealed partial class Stfs _baseStream.Position = absolutePosition + leftInBlock; // Read remaining bytes - int toRead = (int)Math.Min(count, _length - _position); + var toRead = (int)Math.Min(count, _length - _position); _baseStream.ReadExactly(buffer, offset, toRead); _position += toRead; totalRead += toRead; diff --git a/Aaru.Archives/Zoo/Info.cs b/Aaru.Archives/Zoo/Info.cs index acd0aa588..4802327f7 100644 --- a/Aaru.Archives/Zoo/Info.cs +++ b/Aaru.Archives/Zoo/Info.cs @@ -48,7 +48,7 @@ public sealed partial class Zoo Stream stream = filter.GetDataForkStream(); stream.Position = 0; - byte[] hdr = new byte[Marshal.SizeOf()]; + var hdr = new byte[Marshal.SizeOf()]; stream.ReadExactly(hdr, 0, hdr.Length); @@ -67,7 +67,7 @@ public sealed partial class Zoo Stream stream = filter.GetDataForkStream(); stream.Position = 0; - byte[] hdr = new byte[Marshal.SizeOf()]; + var hdr = new byte[Marshal.SizeOf()]; stream.ReadExactly(hdr, 0, hdr.Length); @@ -105,7 +105,7 @@ public sealed partial class Zoo if(header.acmt_len > 0) { - byte[] buffer = new byte[header.acmt_len]; + var buffer = new byte[header.acmt_len]; stream.Position = header.acmt_pos; encoding ??= Encoding.UTF8; stream.ReadExactly(buffer, 0, buffer.Length); diff --git a/Aaru.Archives/Zoo/Open.cs b/Aaru.Archives/Zoo/Open.cs index 32873b080..48e7353ea 100644 --- a/Aaru.Archives/Zoo/Open.cs +++ b/Aaru.Archives/Zoo/Open.cs @@ -56,7 +56,7 @@ public sealed partial class Zoo ArchiveSupportedFeature.SupportsFilenames | ArchiveSupportedFeature.SupportsSubdirectories; - byte[] hdr = new byte[Marshal.SizeOf()]; + var hdr = new byte[Marshal.SizeOf()]; _stream.ReadExactly(hdr, 0, hdr.Length); @@ -86,7 +86,7 @@ public sealed partial class Zoo do { - byte[] buf = new byte[Marshal.SizeOf()]; + var buf = new byte[Marshal.SizeOf()]; if(_stream.Position + buf.Length >= _stream.Length) break; @@ -94,7 +94,7 @@ public sealed partial class Zoo entry = Marshal.ByteArrayToStructureLittleEndian(buf); - int pos = 56; // dir_crc + var pos = 56; // dir_crc if(entry.namlen > 0) { diff --git a/Aaru.Checksums/Aaru.Checksums.csproj b/Aaru.Checksums/Aaru.Checksums.csproj index 8f0f1f52f..07be7a328 100644 --- a/Aaru.Checksums/Aaru.Checksums.csproj +++ b/Aaru.Checksums/Aaru.Checksums.csproj @@ -50,7 +50,7 @@ - + diff --git a/Aaru.Checksums/CRC16Context.cs b/Aaru.Checksums/CRC16Context.cs index e56ee0c27..42cff1b58 100644 --- a/Aaru.Checksums/CRC16Context.cs +++ b/Aaru.Checksums/CRC16Context.cs @@ -83,121 +83,6 @@ public partial class Crc16Context : IChecksum if(!_useNative) _table = table ?? GenerateTable(polynomial, inverse); } -#region IChecksum Members - - /// - public string Name => "Adler-32"; - - /// - public Guid Id => new("D69CF1E7-4A7B-4605-9291-3A1BE4C2951F"); - - /// - public string Author => Authors.NataliaPortillo; - - /// - /// Updates the hash with data. - /// Data buffer. - /// Length of buffer to hash. - public void Update(byte[] data, uint len) - { - switch(_useNative) - { - case true when _useCcitt: - crc16_ccitt_update(_nativeContext, data, len); - - break; - case true when _useIbm: - crc16_update(_nativeContext, data, len); - - break; - default: - { - if(_inverse) - StepInverse(ref _hashInt, _table, data, len); - else - Step(ref _hashInt, _table, data, len); - - break; - } - } - } - - /// - /// Updates the hash with data. - /// Data buffer. - public void Update(byte[] data) => Update(data, (uint)data.Length); - - /// - /// Returns a byte array of the hash value. - public byte[] Final() - { - ushort crc = 0; - - switch(_useNative) - { - case true when _useCcitt: - crc16_ccitt_final(_nativeContext, ref crc); - crc16_ccitt_free(_nativeContext); - - break; - case true when _useIbm: - crc16_final(_nativeContext, ref crc); - crc16_free(_nativeContext); - - break; - default: - { - if(_inverse) - crc = (ushort)~(_hashInt ^ _finalSeed); - else - crc = (ushort)(_hashInt ^ _finalSeed); - - break; - } - } - - return BigEndianBitConverter.GetBytes(crc); - } - - /// - /// Returns a hexadecimal representation of the hash value. - public string End() - { - var crc16Output = new StringBuilder(); - ushort final = 0; - - switch(_useNative) - { - case true when _useCcitt: - crc16_ccitt_final(_nativeContext, ref final); - crc16_ccitt_free(_nativeContext); - - break; - case true when _useIbm: - crc16_final(_nativeContext, ref final); - crc16_free(_nativeContext); - - break; - default: - { - if(_inverse) - final = (ushort)~(_hashInt ^ _finalSeed); - else - final = (ushort)(_hashInt ^ _finalSeed); - - break; - } - } - - byte[] finalBytes = BigEndianBitConverter.GetBytes(final); - - foreach(byte t in finalBytes) crc16Output.Append(t.ToString("x2")); - - return crc16Output.ToString(); - } - -#endregion - [LibraryImport("libAaru.Checksums.Native", SetLastError = true)] private static partial IntPtr crc16_init(); @@ -632,4 +517,119 @@ public partial class Crc16Context : IChecksum return localHashInt; } + +#region IChecksum Members + + /// + public string Name => "Adler-32"; + + /// + public Guid Id => new("D69CF1E7-4A7B-4605-9291-3A1BE4C2951F"); + + /// + public string Author => Authors.NataliaPortillo; + + /// + /// Updates the hash with data. + /// Data buffer. + /// Length of buffer to hash. + public void Update(byte[] data, uint len) + { + switch(_useNative) + { + case true when _useCcitt: + crc16_ccitt_update(_nativeContext, data, len); + + break; + case true when _useIbm: + crc16_update(_nativeContext, data, len); + + break; + default: + { + if(_inverse) + StepInverse(ref _hashInt, _table, data, len); + else + Step(ref _hashInt, _table, data, len); + + break; + } + } + } + + /// + /// Updates the hash with data. + /// Data buffer. + public void Update(byte[] data) => Update(data, (uint)data.Length); + + /// + /// Returns a byte array of the hash value. + public byte[] Final() + { + ushort crc = 0; + + switch(_useNative) + { + case true when _useCcitt: + crc16_ccitt_final(_nativeContext, ref crc); + crc16_ccitt_free(_nativeContext); + + break; + case true when _useIbm: + crc16_final(_nativeContext, ref crc); + crc16_free(_nativeContext); + + break; + default: + { + if(_inverse) + crc = (ushort)~(_hashInt ^ _finalSeed); + else + crc = (ushort)(_hashInt ^ _finalSeed); + + break; + } + } + + return BigEndianBitConverter.GetBytes(crc); + } + + /// + /// Returns a hexadecimal representation of the hash value. + public string End() + { + var crc16Output = new StringBuilder(); + ushort final = 0; + + switch(_useNative) + { + case true when _useCcitt: + crc16_ccitt_final(_nativeContext, ref final); + crc16_ccitt_free(_nativeContext); + + break; + case true when _useIbm: + crc16_final(_nativeContext, ref final); + crc16_free(_nativeContext); + + break; + default: + { + if(_inverse) + final = (ushort)~(_hashInt ^ _finalSeed); + else + final = (ushort)(_hashInt ^ _finalSeed); + + break; + } + } + + byte[] finalBytes = BigEndianBitConverter.GetBytes(final); + + foreach(byte t in finalBytes) crc16Output.Append(t.ToString("x2")); + + return crc16Output.ToString(); + } + +#endregion } \ No newline at end of file diff --git a/Aaru.Checksums/MD5Context.cs b/Aaru.Checksums/MD5Context.cs index 9dc7be5f5..28ee57afc 100644 --- a/Aaru.Checksums/MD5Context.cs +++ b/Aaru.Checksums/MD5Context.cs @@ -47,53 +47,6 @@ public sealed class Md5Context : IChecksum /// Initializes the MD5 hash provider public Md5Context() => _provider = MD5.Create(); -#region IChecksum Members - - /// - public string Name => Localization.MD5_Name; - - /// - public Guid Id => new("C78674C4-F699-4FAB-A618-1661AF659A7C"); - - /// - public string Author => Authors.NataliaPortillo; - - /// - /// Updates the hash with data. - /// Data buffer. - /// Length of buffer to hash. - public void Update(byte[] data, uint len) => _provider.TransformBlock(data, 0, (int)len, data, 0); - - /// - /// Updates the hash with data. - /// Data buffer. - public void Update(byte[] data) => Update(data, (uint)data.Length); - - /// - /// Returns a byte array of the hash value. - public byte[] Final() - { - _provider.TransformFinalBlock([], 0, 0); - - return _provider.Hash; - } - - /// - /// Returns a hexadecimal representation of the hash value. - public string End() - { - _provider.TransformFinalBlock([], 0, 0); - var md5Output = new StringBuilder(); - - if(_provider.Hash is null) return null; - - foreach(byte h in _provider.Hash) md5Output.Append(h.ToString("x2")); - - return md5Output.ToString(); - } - -#endregion - /// Gets the hash of a file /// File path. public static byte[] File(string filename) @@ -142,4 +95,51 @@ public sealed class Md5Context : IChecksum /// Data buffer. /// Byte array of the hash value. public static string Data(byte[] data, out byte[] hash) => Data(data, (uint)data.Length, out hash); + +#region IChecksum Members + + /// + public string Name => Localization.MD5_Name; + + /// + public Guid Id => new("C78674C4-F699-4FAB-A618-1661AF659A7C"); + + /// + public string Author => Authors.NataliaPortillo; + + /// + /// Updates the hash with data. + /// Data buffer. + /// Length of buffer to hash. + public void Update(byte[] data, uint len) => _provider.TransformBlock(data, 0, (int)len, data, 0); + + /// + /// Updates the hash with data. + /// Data buffer. + public void Update(byte[] data) => Update(data, (uint)data.Length); + + /// + /// Returns a byte array of the hash value. + public byte[] Final() + { + _provider.TransformFinalBlock([], 0, 0); + + return _provider.Hash; + } + + /// + /// Returns a hexadecimal representation of the hash value. + public string End() + { + _provider.TransformFinalBlock([], 0, 0); + var md5Output = new StringBuilder(); + + if(_provider.Hash is null) return null; + + foreach(byte h in _provider.Hash) md5Output.Append(h.ToString("x2")); + + return md5Output.ToString(); + } + +#endregion } \ No newline at end of file diff --git a/Aaru.Checksums/ReedSolomon.cs b/Aaru.Checksums/ReedSolomon.cs index 732adf762..168e77796 100644 --- a/Aaru.Checksums/ReedSolomon.cs +++ b/Aaru.Checksums/ReedSolomon.cs @@ -299,8 +299,10 @@ public class ReedSolomon for(i = _kk - 1; i >= 0; i--) { if(_mm != 8) - if(data[i] > _nn) - return -1; /* Illegal symbol */ + { + if(data[i] > _nn) return -1; + } + /* Illegal symbol */ int feedback = _indexOf[data[i] ^ bb[_nn - _kk - 1]]; @@ -371,8 +373,10 @@ public class ReedSolomon for(i = _nn - 1; i >= 0; i--) { if(_mm != 8) - if(data[i] > _nn) - return -1; /* Illegal symbol */ + { + if(data[i] > _nn) return -1; + } + /* Illegal symbol */ recd[i] = _indexOf[data[i]]; } @@ -387,8 +391,9 @@ public class ReedSolomon tmp = 0; for(j = 0; j < _nn; j++) - if(recd[j] != _a0) /* recd[j] in index form */ - tmp ^= _alphaTo[Modnn(recd[j] + (B0 + i - 1) * j)]; + { + if(recd[j] != _a0) /* recd[j] in index form */ tmp ^= _alphaTo[Modnn(recd[j] + (B0 + i - 1) * j)]; + } synError |= tmp; /* set flag if non-zero syndrome => * error */ @@ -478,8 +483,9 @@ public class ReedSolomon var discrR = 0; for(i = 0; i < r; i++) - if(lambda[i] != 0 && s[r - i] != _a0) - discrR ^= _alphaTo[Modnn(_indexOf[lambda[i]] + s[r - i])]; + { + if(lambda[i] != 0 && s[r - i] != _a0) discrR ^= _alphaTo[Modnn(_indexOf[lambda[i]] + s[r - i])]; + } discrR = _indexOf[discrR]; /* Index form */ @@ -585,8 +591,9 @@ public class ReedSolomon j = degLambda < i ? degLambda : i; for(; j >= 0; j--) - if(s[i + 1 - j] != _a0 && lambda[j] != _a0) - tmp ^= _alphaTo[Modnn(s[i + 1 - j] + lambda[j])]; + { + if(s[i + 1 - j] != _a0 && lambda[j] != _a0) tmp ^= _alphaTo[Modnn(s[i + 1 - j] + lambda[j])]; + } if(tmp != 0) degOmega = i; @@ -604,16 +611,18 @@ public class ReedSolomon var num1 = 0; for(i = degOmega; i >= 0; i--) - if(omega[i] != _a0) - num1 ^= _alphaTo[Modnn(omega[i] + i * root[j])]; + { + if(omega[i] != _a0) num1 ^= _alphaTo[Modnn(omega[i] + i * root[j])]; + } int num2 = _alphaTo[Modnn(root[j] * (B0 - 1) + _nn)]; var den = 0; /* 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) - if(lambda[i + 1] != _a0) - den ^= _alphaTo[Modnn(lambda[i + 1] + i * root[j])]; + { + if(lambda[i + 1] != _a0) den ^= _alphaTo[Modnn(lambda[i + 1] + i * root[j])]; + } if(den == 0) { diff --git a/Aaru.CommonTypes/Aaru.CommonTypes.csproj b/Aaru.CommonTypes/Aaru.CommonTypes.csproj index efdb29dcb..8ed504be7 100644 --- a/Aaru.CommonTypes/Aaru.CommonTypes.csproj +++ b/Aaru.CommonTypes/Aaru.CommonTypes.csproj @@ -34,7 +34,7 @@ - + diff --git a/Aaru.CommonTypes/Interop/DetectOS.cs b/Aaru.CommonTypes/Interop/DetectOS.cs index e7af75151..03e1ad00d 100644 --- a/Aaru.CommonTypes/Interop/DetectOS.cs +++ b/Aaru.CommonTypes/Interop/DetectOS.cs @@ -240,7 +240,7 @@ public static partial class DetectOS /// Current operating system version public static string GetVersion() { - string environ = Environment.OSVersion.Version.ToString(); + var environ = Environment.OSVersion.Version.ToString(); switch(GetRealPlatformID()) { diff --git a/Aaru.Compression/Arc/CrunchStream.cs b/Aaru.Compression/Arc/CrunchStream.cs index 8fe4398a9..e73f1959f 100644 --- a/Aaru.Compression/Arc/CrunchStream.cs +++ b/Aaru.Compression/Arc/CrunchStream.cs @@ -18,12 +18,12 @@ public partial class CrunchStream : Stream // Read full compressed data into memory compressedStream.Position = 0; - byte[] inBuf = new byte[compressedStream.Length]; + var inBuf = new byte[compressedStream.Length]; compressedStream.ReadExactly(inBuf, 0, inBuf.Length); // Allocate output buffer _decoded = new byte[decompressedLength]; - nint outLen = (nint)decompressedLength; + var outLen = (nint)decompressedLength; int err = rle switch { @@ -83,7 +83,7 @@ public partial class CrunchStream : Stream if(remaining <= 0) return 0; - int toRead = (int)Math.Min(count, remaining); + var toRead = (int)Math.Min(count, remaining); Array.Copy(_decoded, _position, buffer, offset, toRead); _position += toRead; diff --git a/Aaru.Compression/Arc/LzwStream.cs b/Aaru.Compression/Arc/LzwStream.cs index 96db0e7c2..766fe0eeb 100644 --- a/Aaru.Compression/Arc/LzwStream.cs +++ b/Aaru.Compression/Arc/LzwStream.cs @@ -18,12 +18,12 @@ public partial class LzwStream : Stream // Read full compressed data into memory compressedStream.Position = 0; - byte[] inBuf = new byte[compressedStream.Length]; + var inBuf = new byte[compressedStream.Length]; compressedStream.ReadExactly(inBuf, 0, inBuf.Length); // Allocate output buffer _decoded = new byte[decompressedLength]; - nint outLen = (nint)decompressedLength; + var outLen = (nint)decompressedLength; int err; @@ -77,7 +77,7 @@ public partial class LzwStream : Stream if(remaining <= 0) return 0; - int toRead = (int)Math.Min(count, remaining); + var toRead = (int)Math.Min(count, remaining); Array.Copy(_decoded, _position, buffer, offset, toRead); _position += toRead; diff --git a/Aaru.Compression/Arc/PackStream.cs b/Aaru.Compression/Arc/PackStream.cs index 36c4a774a..b215125f3 100644 --- a/Aaru.Compression/Arc/PackStream.cs +++ b/Aaru.Compression/Arc/PackStream.cs @@ -18,12 +18,12 @@ public partial class PackStream : Stream // Read full compressed data into memory compressedStream.Position = 0; - byte[] inBuf = new byte[compressedStream.Length]; + var inBuf = new byte[compressedStream.Length]; compressedStream.ReadExactly(inBuf, 0, inBuf.Length); // Allocate output buffer _decoded = new byte[decompressedLength]; - nint outLen = (nint)decompressedLength; + var outLen = (nint)decompressedLength; // Call native decompressor int err = arc_decompress_pack(inBuf, inBuf.Length, _decoded, ref outLen); @@ -69,7 +69,7 @@ public partial class PackStream : Stream if(remaining <= 0) return 0; - int toRead = (int)Math.Min(count, remaining); + var toRead = (int)Math.Min(count, remaining); Array.Copy(_decoded, _position, buffer, offset, toRead); _position += toRead; diff --git a/Aaru.Compression/Arc/SqueezeStream.cs b/Aaru.Compression/Arc/SqueezeStream.cs index 81c677b88..75057b3fb 100644 --- a/Aaru.Compression/Arc/SqueezeStream.cs +++ b/Aaru.Compression/Arc/SqueezeStream.cs @@ -18,12 +18,12 @@ public partial class SqueezeStream : Stream // Read full compressed data into memory compressedStream.Position = 0; - byte[] inBuf = new byte[compressedStream.Length]; + var inBuf = new byte[compressedStream.Length]; compressedStream.ReadExactly(inBuf, 0, inBuf.Length); // Allocate output buffer _decoded = new byte[decompressedLength]; - nint outLen = (nint)decompressedLength; + var outLen = (nint)decompressedLength; // Call native decompressor int err = arc_decompress_squeeze(inBuf, inBuf.Length, _decoded, ref outLen); @@ -69,7 +69,7 @@ public partial class SqueezeStream : Stream if(remaining <= 0) return 0; - int toRead = (int)Math.Min(count, remaining); + var toRead = (int)Math.Min(count, remaining); Array.Copy(_decoded, _position, buffer, offset, toRead); _position += toRead; diff --git a/Aaru.Compression/FLAC.cs b/Aaru.Compression/FLAC.cs index ad22692fc..4c3b3f0cc 100644 --- a/Aaru.Compression/FLAC.cs +++ b/Aaru.Compression/FLAC.cs @@ -27,9 +27,7 @@ // ****************************************************************************/ using System; -using System.IO; using System.Runtime.InteropServices; -using Aaru.Helpers.IO; namespace Aaru.Compression; diff --git a/Aaru.Compression/HaStream.cs b/Aaru.Compression/HaStream.cs index f3792a3f4..00702dec8 100644 --- a/Aaru.Compression/HaStream.cs +++ b/Aaru.Compression/HaStream.cs @@ -28,12 +28,12 @@ public partial class HaStream : Stream // Read full compressed data into memory compressedStream.Position = 0; - byte[] inBuf = new byte[compressedStream.Length]; + var inBuf = new byte[compressedStream.Length]; compressedStream.ReadExactly(inBuf, 0, inBuf.Length); // Allocate output buffer _decoded = new byte[decompressedLength]; - nint outLen = (nint)decompressedLength; + var outLen = (nint)decompressedLength; // Call native decompressor int err; @@ -96,7 +96,7 @@ public partial class HaStream : Stream if(remaining <= 0) return 0; - int toRead = (int)Math.Min(count, remaining); + var toRead = (int)Math.Min(count, remaining); Array.Copy(_decoded, _position, buffer, offset, toRead); _position += toRead; diff --git a/Aaru.Compression/Lh5Stream.cs b/Aaru.Compression/Lh5Stream.cs index e5d251fb5..d28c61067 100644 --- a/Aaru.Compression/Lh5Stream.cs +++ b/Aaru.Compression/Lh5Stream.cs @@ -18,12 +18,12 @@ public partial class Lh5Stream : Stream // Read full compressed data into memory compressedStream.Position = 0; - byte[] inBuf = new byte[compressedStream.Length]; + var inBuf = new byte[compressedStream.Length]; compressedStream.ReadExactly(inBuf, 0, inBuf.Length); // Allocate output buffer _decoded = new byte[decompressedLength]; - nint outLen = (nint)decompressedLength; + var outLen = (nint)decompressedLength; // Call native decompressor int err = lh5_decompress(inBuf, inBuf.Length, _decoded, ref outLen); @@ -69,7 +69,7 @@ public partial class Lh5Stream : Stream if(remaining <= 0) return 0; - int toRead = (int)Math.Min(count, remaining); + var toRead = (int)Math.Min(count, remaining); Array.Copy(_decoded, _position, buffer, offset, toRead); _position += toRead; diff --git a/Aaru.Compression/Pak/CrushStream.cs b/Aaru.Compression/Pak/CrushStream.cs index 5721d54b3..fab07b3f4 100644 --- a/Aaru.Compression/Pak/CrushStream.cs +++ b/Aaru.Compression/Pak/CrushStream.cs @@ -18,12 +18,12 @@ public partial class CrushStream : Stream // Read full compressed data into memory compressedStream.Position = 0; - byte[] inBuf = new byte[compressedStream.Length]; + var inBuf = new byte[compressedStream.Length]; compressedStream.ReadExactly(inBuf, 0, inBuf.Length); // Allocate output buffer _decoded = new byte[decompressedLength]; - nint outLen = (nint)decompressedLength; + var outLen = (nint)decompressedLength; // Call native decompressor int err = pak_decompress_crush(inBuf, inBuf.Length, _decoded, ref outLen); @@ -69,7 +69,7 @@ public partial class CrushStream : Stream if(remaining <= 0) return 0; - int toRead = (int)Math.Min(count, remaining); + var toRead = (int)Math.Min(count, remaining); Array.Copy(_decoded, _position, buffer, offset, toRead); _position += toRead; diff --git a/Aaru.Compression/Pak/DistillStream.cs b/Aaru.Compression/Pak/DistillStream.cs index 6af7f84f7..1cc596751 100644 --- a/Aaru.Compression/Pak/DistillStream.cs +++ b/Aaru.Compression/Pak/DistillStream.cs @@ -18,12 +18,12 @@ public partial class DistillStream : Stream // Read full compressed data into memory compressedStream.Position = 0; - byte[] inBuf = new byte[compressedStream.Length]; + var inBuf = new byte[compressedStream.Length]; compressedStream.ReadExactly(inBuf, 0, inBuf.Length); // Allocate output buffer _decoded = new byte[decompressedLength]; - nint outLen = (nint)decompressedLength; + var outLen = (nint)decompressedLength; // Call native decompressor int err = pak_decompress_distill(inBuf, inBuf.Length, _decoded, ref outLen); @@ -69,7 +69,7 @@ public partial class DistillStream : Stream if(remaining <= 0) return 0; - int toRead = (int)Math.Min(count, remaining); + var toRead = (int)Math.Min(count, remaining); Array.Copy(_decoded, _position, buffer, offset, toRead); _position += toRead; diff --git a/Aaru.Core/Aaru.Core.csproj b/Aaru.Core/Aaru.Core.csproj index 28b3d64a0..ad961f92a 100644 --- a/Aaru.Core/Aaru.Core.csproj +++ b/Aaru.Core/Aaru.Core.csproj @@ -63,11 +63,11 @@ - + - + - + diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs index ae852ece6..c9f1d4142 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs @@ -1083,8 +1083,9 @@ sealed partial class Dump foreach(int sub in _resume.BadSubchannels) subchannelExtents.Add(sub); if(_resume.NextBlock < blocks) - for(ulong i = _resume.NextBlock; i < blocks; i++) - subchannelExtents.Add((int)i); + { + for(ulong i = _resume.NextBlock; i < blocks; i++) subchannelExtents.Add((int)i); + } } if(_resume.NextBlock > 0) @@ -1510,8 +1511,9 @@ sealed partial class Dump supportsLongSectors); foreach(Tuple leadoutExtent in leadOutExtents.ToArray()) - for(ulong e = leadoutExtent.Item1; e <= leadoutExtent.Item2; e++) - subchannelExtents.Remove((int)e); + { + for(ulong e = leadoutExtent.Item1; e <= leadoutExtent.Item2; e++) subchannelExtents.Remove((int)e); + } if(subchannelExtents.Count > 0 && _retryPasses > 0 && _retrySubchannel) { diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Error.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Error.cs index e7156dd1f..cf534d567 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Error.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Error.cs @@ -465,8 +465,9 @@ partial class Dump // MEDIUM ERROR, retry with ignore error below if(decSense is { ASC: 0x11 }) - if(!sectorsNotEvenPartial.Contains(badSector)) - sectorsNotEvenPartial.Add(badSector); + { + if(!sectorsNotEvenPartial.Contains(badSector)) sectorsNotEvenPartial.Add(badSector); + } } // Because one block has been partially used to fix the offset diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Plextor.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Plextor.cs index 5531de406..4ca02ff3d 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Plextor.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Plextor.cs @@ -140,7 +140,7 @@ partial class Dump cmdBuf = new byte[2352 * blocksToRead + subSize * blocksToRead]; - for(int b = 0; b < blocksToRead; b++) + for(var b = 0; b < blocksToRead; b++) { Array.Copy(dataBuf, 2352 * b, cmdBuf, (2352 + subSize) * b, 2352); Array.Copy(subBuf, subSize * b, cmdBuf, (2352 + subSize) * b + 2352, subSize); diff --git a/Aaru.Core/Devices/Dumping/MMC.cs b/Aaru.Core/Devices/Dumping/MMC.cs index 89dc3d1e6..c956ff441 100644 --- a/Aaru.Core/Devices/Dumping/MMC.cs +++ b/Aaru.Core/Devices/Dumping/MMC.cs @@ -64,9 +64,9 @@ partial class Dump MediaType dskType = MediaType.Unknown; bool sense; byte[] tmpBuf; - bool compactDisc = true; - bool gotConfiguration = false; - bool isXbox = false; + var compactDisc = true; + var gotConfiguration = false; + var isXbox = false; DVDDecryption dvdDecrypt = null; _speedMultiplier = 1; @@ -1020,7 +1020,7 @@ partial class Dump Checksums = Checksum.GetChecksums(tag) }; - byte[] tmp = new byte[tag.Length + 4]; + var tmp = new byte[tag.Length + 4]; Array.Copy(tag, 0, tmp, 4, tag.Length); tmp[0] = (byte)((tag.Length & 0xFF00) >> 8); tmp[1] = (byte)(tag.Length & 0xFF); diff --git a/Aaru.Core/Devices/Dumping/PlayStationPortable/PlayStationPortable.cs b/Aaru.Core/Devices/Dumping/PlayStationPortable/PlayStationPortable.cs index 6b41b06e9..95659678d 100644 --- a/Aaru.Core/Devices/Dumping/PlayStationPortable/PlayStationPortable.cs +++ b/Aaru.Core/Devices/Dumping/PlayStationPortable/PlayStationPortable.cs @@ -102,7 +102,7 @@ public partial class Dump return; } - byte[] tmp = new byte[8]; + var tmp = new byte[8]; Array.Copy(buffer, 0x36, tmp, 0, 8); @@ -114,9 +114,9 @@ public partial class Dump return; } - ushort fatStart = (ushort)((buffer[0x0F] << 8) + buffer[0x0E]); - ushort sectorsPerFat = (ushort)((buffer[0x17] << 8) + buffer[0x16]); - ushort rootStart = (ushort)(sectorsPerFat * 2 + fatStart); + var fatStart = (ushort)((buffer[0x0F] << 8) + buffer[0x0E]); + var sectorsPerFat = (ushort)((buffer[0x17] << 8) + buffer[0x16]); + var rootStart = (ushort)(sectorsPerFat * 2 + fatStart); UpdateStatus?.Invoke(string.Format(Localization.Core.Reading_root_directory_in_sector_0, rootStart)); @@ -160,7 +160,7 @@ public partial class Dump UpdateStatus?.Invoke(Localization.Core.Reading_FAT); - byte[] fat = new byte[sectorsPerFat * 512]; + var fat = new byte[sectorsPerFat * 512]; uint position = 0; @@ -199,11 +199,11 @@ public partial class Dump UpdateStatus?.Invoke(Localization.Core.Traversing_FAT); - ushort previousCluster = BitConverter.ToUInt16(fat, 4); + var previousCluster = BitConverter.ToUInt16(fat, 4); - for(int i = 3; i < fat.Length / 2; i++) + for(var i = 3; i < fat.Length / 2; i++) { - ushort nextCluster = BitConverter.ToUInt16(fat, i * 2); + var nextCluster = BitConverter.ToUInt16(fat, i * 2); if(nextCluster == previousCluster + 1) { diff --git a/Aaru.Core/Devices/Dumping/SCSI.cs b/Aaru.Core/Devices/Dumping/SCSI.cs index 8ca449f00..08c51969b 100644 --- a/Aaru.Core/Devices/Dumping/SCSI.cs +++ b/Aaru.Core/Devices/Dumping/SCSI.cs @@ -46,7 +46,7 @@ public partial class Dump /// Dumps a SCSI Block Commands device or a Reduced Block Commands devices void Scsi() { - int resets = 0; + var resets = 0; if(_dev.IsRemovable) { @@ -78,7 +78,7 @@ public partial class Dump { case 0x3A: { - int leftRetries = 5; + var leftRetries = 5; while(leftRetries > 0) { @@ -112,7 +112,7 @@ public partial class Dump } case 0x04 when decSense.Value.ASCQ == 0x01: { - int leftRetries = 50; + var leftRetries = 50; while(leftRetries > 0) { @@ -162,7 +162,7 @@ public partial class Dump // These should be trapped by the OS but seems in some cases they're not case 0x28: { - int leftRetries = 10; + var leftRetries = 10; while(leftRetries > 0) { diff --git a/Aaru.Core/Devices/Dumping/SSC.cs b/Aaru.Core/Devices/Dumping/SSC.cs index 22f9058de..27455569e 100644 --- a/Aaru.Core/Devices/Dumping/SSC.cs +++ b/Aaru.Core/Devices/Dumping/SSC.cs @@ -283,8 +283,9 @@ partial class Dump Modes.DecodedMode? decMode = null; if(!sense && !_dev.Error) - if(Modes.DecodeMode10(cmdBuf, _dev.ScsiType).HasValue) - decMode = Modes.DecodeMode10(cmdBuf, _dev.ScsiType); + { + if(Modes.DecodeMode10(cmdBuf, _dev.ScsiType).HasValue) decMode = Modes.DecodeMode10(cmdBuf, _dev.ScsiType); + } UpdateStatus?.Invoke(Localization.Core.Requesting_MODE_SENSE_6); @@ -312,8 +313,9 @@ partial class Dump if(sense || _dev.Error) sense = _dev.ModeSense(out cmdBuf, out senseBuf, 5, out duration); if(!sense && !_dev.Error) - if(Modes.DecodeMode6(cmdBuf, _dev.ScsiType).HasValue) - decMode = Modes.DecodeMode6(cmdBuf, _dev.ScsiType); + { + if(Modes.DecodeMode6(cmdBuf, _dev.ScsiType).HasValue) decMode = Modes.DecodeMode6(cmdBuf, _dev.ScsiType); + } // TODO: Check partitions page if(decMode.HasValue) diff --git a/Aaru.Core/Devices/Dumping/Sbc/Optical.cs b/Aaru.Core/Devices/Dumping/Sbc/Optical.cs index 32ad1db49..455396b4f 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Optical.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Optical.cs @@ -179,9 +179,8 @@ partial class Dump writtenExtents.Add(0, blocks - 1); foreach(Tuple blank in blankExtents.ToArray()) - { - for(ulong b = blank.Item1; b <= blank.Item2; b++) writtenExtents.Remove(b); - } + for(ulong b = blank.Item1; b <= blank.Item2; b++) + writtenExtents.Remove(b); } if(writtenExtents.Count == 0) diff --git a/Aaru.Core/Devices/Dumping/SecureDigital.cs b/Aaru.Core/Devices/Dumping/SecureDigital.cs index 2cdd7b9ae..3d50e7ef5 100644 --- a/Aaru.Core/Devices/Dumping/SecureDigital.cs +++ b/Aaru.Core/Devices/Dumping/SecureDigital.cs @@ -623,9 +623,7 @@ public partial class Dump _speedStopwatch.Restart(); if(blocksToRead == 1) - { error = _dev.ReadSingleBlock(out cmdBuf, out _, (uint)i, blockSize, byteAddressed, timeout, out _); - } else if(supportsCmd23) { error = _dev.ReadWithBlockCount(out cmdBuf, diff --git a/Aaru.Core/Devices/Dumping/XGD.cs b/Aaru.Core/Devices/Dumping/XGD.cs index caf33ede9..86c10b6d3 100644 --- a/Aaru.Core/Devices/Dumping/XGD.cs +++ b/Aaru.Core/Devices/Dumping/XGD.cs @@ -1088,8 +1088,9 @@ partial class Dump List tmpList = []; foreach(ulong ur in _resume.BadBlocks) - for(ulong i = ur; i < ur + blocksToRead; i++) - tmpList.Add(i); + { + for(ulong i = ur; i < ur + blocksToRead; i++) tmpList.Add(i); + } tmpList.Sort(); diff --git a/Aaru.Core/Devices/Info/DeviceInfo.cs b/Aaru.Core/Devices/Info/DeviceInfo.cs index 8ff5d7dd4..07afb926a 100644 --- a/Aaru.Core/Devices/Info/DeviceInfo.cs +++ b/Aaru.Core/Devices/Info/DeviceInfo.cs @@ -330,8 +330,8 @@ public partial class DeviceInfo if(dev.Manufacturer == "PLEXTOR") { - bool plxtSense = true; - bool plxtDvd = false; + var plxtSense = true; + var plxtDvd = false; byte[] plxtBuf = null; switch(dev.Model) diff --git a/Aaru.Core/Devices/ReaderATA.cs b/Aaru.Core/Devices/ReaderATA.cs index 11d012a77..c0ba424a1 100644 --- a/Aaru.Core/Devices/ReaderATA.cs +++ b/Aaru.Core/Devices/ReaderATA.cs @@ -106,7 +106,7 @@ sealed partial class Reader if(Blocks == 0) GetDeviceBlocks(); bool sense; - int tries = 0; + var tries = 0; uint lba = 0; ushort cyl = 0; byte head = 0; @@ -264,7 +264,7 @@ sealed partial class Reader return false; } - bool error = true; + var error = true; while(IsLba) { @@ -325,7 +325,7 @@ sealed partial class Reader bool AtaReadBlocks(out byte[] buffer, ulong block, uint count, out double duration, out bool recoveredError) { - bool error = true; + var error = true; bool sense; AtaErrorRegistersLba28 errorLba; AtaErrorRegistersLba48 errorLba48; @@ -403,7 +403,7 @@ sealed partial class Reader bool AtaReadChs(out byte[] buffer, ushort cylinder, byte head, byte sector, out double duration, out bool recoveredError) { - bool error = true; + var error = true; bool sense; AtaErrorRegistersChs errorChs; byte status = 0, errorByte = 0; diff --git a/Aaru.Core/Devices/ReaderSCSI.cs b/Aaru.Core/Devices/ReaderSCSI.cs index de03608f9..938860675 100644 --- a/Aaru.Core/Devices/ReaderSCSI.cs +++ b/Aaru.Core/Devices/ReaderSCSI.cs @@ -67,9 +67,9 @@ sealed partial class Reader if(Blocks == 0) return true; ReadOnlySpan senseBuf; - int tries = 0; + var tries = 0; uint lba = 0; - bool mediumScan = false; + var mediumScan = false; if(_dev.ScsiType == PeripheralDeviceTypes.OpticalDevice) { @@ -662,7 +662,7 @@ sealed partial class Reader return true; case false: { - byte[] temp = new byte[8]; + var temp = new byte[8]; Array.Copy(cmdBuf, 0, temp, 0, 8); Array.Reverse(temp); @@ -928,7 +928,7 @@ sealed partial class Reader bool ScsiSeek(ulong block, out double duration) { - bool sense = true; + var sense = true; duration = 0; if(_seek6) diff --git a/Aaru.Core/Devices/Report/SecureDigital.cs b/Aaru.Core/Devices/Report/SecureDigital.cs index 3749012cf..09e0c650b 100644 --- a/Aaru.Core/Devices/Report/SecureDigital.cs +++ b/Aaru.Core/Devices/Report/SecureDigital.cs @@ -44,7 +44,7 @@ public sealed partial class DeviceReport public MmcSd MmcSdReport() { var report = new MmcSd(); - bool sense = true; + var sense = true; byte[] cid = []; byte[] csd = []; byte[] ecsd = []; diff --git a/Aaru.Core/FileAttributesExtensions.cs b/Aaru.Core/FileAttributesExtensions.cs index 7709b8100..e5bc6b373 100644 --- a/Aaru.Core/FileAttributesExtensions.cs +++ b/Aaru.Core/FileAttributesExtensions.cs @@ -37,8 +37,8 @@ public static class FileAttributesExtensions /// public static string ToAttributeChars(this FileAttributes flags) { - char[] attr = new char[19]; - for(int i = 0; i < attr.Length; i++) attr[i] = '.'; + var attr = new char[19]; + for(var i = 0; i < attr.Length; i++) attr[i] = '.'; (FileAttributes Flag, int Slot, char Symbol)[] attrs = [ @@ -63,8 +63,9 @@ public static class FileAttributesExtensions // 4) Post-process extras: only overwrite slots still ‘.’ foreach((FileAttributes flag, int slot, char symbol) in attrs) - if(slot >= 0 && slot < attr.Length && attr[slot] == '.' && flags.HasFlag(flag)) - attr[slot] = symbol; + { + if(slot >= 0 && slot < attr.Length && attr[slot] == '.' && flags.HasFlag(flag)) attr[slot] = symbol; + } return new string(attr); } diff --git a/Aaru.Core/Graphics/BlockMap.cs b/Aaru.Core/Graphics/BlockMap.cs index 9a58c56f4..80ecc961b 100644 --- a/Aaru.Core/Graphics/BlockMap.cs +++ b/Aaru.Core/Graphics/BlockMap.cs @@ -183,6 +183,64 @@ public class BlockMap : IMediaGraph } } + void PaintSector(ulong sector, SKColor color) + { + SKRect rect = + GetSquareRectangle(_sectorsPerSquare == 0 ? (int)sector : (int)(sector / (ulong)_sectorsPerSquare)); + + _canvas.DrawRect(rect, + new SKPaint + { + Style = SKPaintStyle.StrokeAndFill, + Color = color + }); + } + + void PaintSectors(ulong startingSector, uint length, SKColor color) + { + for(ulong sector = startingSector; sector < startingSector + length; sector++) + { + SKRect rect = + GetSquareRectangle(_sectorsPerSquare == 0 ? (int)sector : (int)(sector / (ulong)_sectorsPerSquare)); + + _canvas.DrawRect(rect, + new SKPaint + { + Style = SKPaintStyle.StrokeAndFill, + Color = color + }); + } + } + + void PaintSectors(IEnumerable sectors, SKColor color) + { + foreach(SKRect rect in sectors.Select(sector => GetSquareRectangle(_sectorsPerSquare == 0 + ? (int)sector + : (int)(sector / + (ulong)_sectorsPerSquare)))) + { + _canvas.DrawRect(rect, + new SKPaint + { + Style = SKPaintStyle.StrokeAndFill, + Color = color + }); + } + } + + SKRect GetSquareRectangle(int square) + { + int row = square / _columns; + int column = square % _columns; + + float x = 1 + column * (_squareSize + 1); + float y = 1 + row * (_squareSize + 1); + float xp = x + _squareSize; + float yp = y + _squareSize; + + return new SKRect(x, y, xp, yp); + } + #region IMediaGraph Members /// @@ -260,62 +318,4 @@ public class BlockMap : IMediaGraph } #endregion - - void PaintSector(ulong sector, SKColor color) - { - SKRect rect = - GetSquareRectangle(_sectorsPerSquare == 0 ? (int)sector : (int)(sector / (ulong)_sectorsPerSquare)); - - _canvas.DrawRect(rect, - new SKPaint - { - Style = SKPaintStyle.StrokeAndFill, - Color = color - }); - } - - void PaintSectors(ulong startingSector, uint length, SKColor color) - { - for(ulong sector = startingSector; sector < startingSector + length; sector++) - { - SKRect rect = - GetSquareRectangle(_sectorsPerSquare == 0 ? (int)sector : (int)(sector / (ulong)_sectorsPerSquare)); - - _canvas.DrawRect(rect, - new SKPaint - { - Style = SKPaintStyle.StrokeAndFill, - Color = color - }); - } - } - - void PaintSectors(IEnumerable sectors, SKColor color) - { - foreach(SKRect rect in sectors.Select(sector => GetSquareRectangle(_sectorsPerSquare == 0 - ? (int)sector - : (int)(sector / - (ulong)_sectorsPerSquare)))) - { - _canvas.DrawRect(rect, - new SKPaint - { - Style = SKPaintStyle.StrokeAndFill, - Color = color - }); - } - } - - SKRect GetSquareRectangle(int square) - { - int row = square / _columns; - int column = square % _columns; - - float x = 1 + column * (_squareSize + 1); - float y = 1 + row * (_squareSize + 1); - float xp = x + _squareSize; - float yp = y + _squareSize; - - return new SKRect(x, y, xp, yp); - } } \ No newline at end of file diff --git a/Aaru.Core/Logging/DeviceLog.cs b/Aaru.Core/Logging/DeviceLog.cs index a775a4e1d..fbbef10f9 100644 --- a/Aaru.Core/Logging/DeviceLog.cs +++ b/Aaru.Core/Logging/DeviceLog.cs @@ -51,7 +51,7 @@ public static class DeviceLog { string[] args = Environment.GetCommandLineArgs(); - for(int i = 0; i < args.Length; i++) + for(var i = 0; i < args.Length; i++) { if(args[i].StartsWith("/dev", StringComparison.OrdinalIgnoreCase) || args[i].StartsWith("aaru://", StringComparison.OrdinalIgnoreCase)) diff --git a/Aaru.Core/Logging/IBGLog.cs b/Aaru.Core/Logging/IBGLog.cs index 5c204ba5e..0c32504b2 100644 --- a/Aaru.Core/Logging/IBGLog.cs +++ b/Aaru.Core/Logging/IBGLog.cs @@ -252,7 +252,8 @@ sealed class IbgLog _ibgStartSet = true; } - _ibgSb.Append(_ibgCulture, $"{_ibgIntSpeed / _ibgSnaps / _ibgDivider:0.00},{_ibgIntSector},{_ibgSampleRate:0},0") + _ibgSb.Append(_ibgCulture, + $"{_ibgIntSpeed / _ibgSnaps / _ibgDivider:0.00},{_ibgIntSector},{_ibgSampleRate:0},0") .AppendLine(); if(_ibgIntSpeed / _ibgSnaps / _ibgDivider > _ibgMaxSpeed) _ibgMaxSpeed = _ibgIntSpeed / _ibgDivider; diff --git a/Aaru.Core/Media/CompactDisc.cs b/Aaru.Core/Media/CompactDisc.cs index 13f89dddf..d3bdb4eeb 100644 --- a/Aaru.Core/Media/CompactDisc.cs +++ b/Aaru.Core/Media/CompactDisc.cs @@ -131,9 +131,8 @@ public static class CompactDisc if(deSub[p] != 0 && deSub[p] != 255) pOk = false; for(var w = 0; w < 8; w++) - { - if((deSub[p] >> w & 1) > 0) pWeight++; - } + if((deSub[p] >> w & 1) > 0) + pWeight++; } // This seems to be a somewhat common pattern @@ -177,13 +176,11 @@ public static class CompactDisc if(!pOk && fixSubchannel) { if(pWeight >= 48) - { - for(int p = subPos; p < subPos + 12; p++) deSub[p] = 255; - } + for(int p = subPos; p < subPos + 12; p++) + deSub[p] = 255; else - { - for(int p = subPos; p < subPos + 12; p++) deSub[p] = 0; - } + for(int p = subPos; p < subPos + 12; p++) + deSub[p] = 0; pOk = true; @fixed = true; diff --git a/Aaru.Decoders/Aaru.Decoders.csproj b/Aaru.Decoders/Aaru.Decoders.csproj index 9350cd8c4..f37bdd76c 100644 --- a/Aaru.Decoders/Aaru.Decoders.csproj +++ b/Aaru.Decoders/Aaru.Decoders.csproj @@ -60,8 +60,8 @@ - - + + \ No newline at end of file diff --git a/Aaru.Decoders/CD/Sector.cs b/Aaru.Decoders/CD/Sector.cs index 7250065b8..e92208e55 100644 --- a/Aaru.Decoders/CD/Sector.cs +++ b/Aaru.Decoders/CD/Sector.cs @@ -32,7 +32,6 @@ using System; using System.Diagnostics.CodeAnalysis; -using System.Linq; using System.Runtime.CompilerServices; using System.Text; using Aaru.Checksums; diff --git a/Aaru.Decoders/DVD/PRI.cs b/Aaru.Decoders/DVD/PRI.cs index aa1d37e1e..ef0b06d88 100644 --- a/Aaru.Decoders/DVD/PRI.cs +++ b/Aaru.Decoders/DVD/PRI.cs @@ -103,7 +103,7 @@ public static class PRI Array.Copy(response, 37, pri.ManufacturerId3, 0, 6); Array.Copy(response, 44, pri.Reserved8, 0, pri.Reserved8.Length); - byte[] tmp = new byte[18]; + var tmp = new byte[18]; Array.Copy(response, 21, tmp, 0, 6); Array.Copy(response, 29, tmp, 6, 6); @@ -309,7 +309,7 @@ public static class PRI [SuppressMessage("ReSharper", "StringLiteralTypo")] public static string ManufacturerFromPrePit(string manufacturerId) { - string manufacturer = ""; + var manufacturer = ""; // Bad thing is that it also includes a media code... if(manufacturerId.StartsWith("RITEK", StringComparison.Ordinal)) diff --git a/Aaru.Decoders/MMC/CSD.cs b/Aaru.Decoders/MMC/CSD.cs index fc80a0f89..1ba677698 100644 --- a/Aaru.Decoders/MMC/CSD.cs +++ b/Aaru.Decoders/MMC/CSD.cs @@ -300,8 +300,9 @@ public static partial class Decoders unit = ""; for(int cl = 0, mask = 1; cl <= 11; cl++, mask <<= 1) - if((csd.Classes & mask) == mask) - unit += $" {cl}"; + { + if((csd.Classes & mask) == mask) unit += $" {cl}"; + } sb.AppendFormat("\t" + Localization.Device_support_command_classes_0, unit).AppendLine(); diff --git a/Aaru.Decoders/SCSI/Inquiry.cs b/Aaru.Decoders/SCSI/Inquiry.cs index ee216b3af..76205801e 100644 --- a/Aaru.Decoders/SCSI/Inquiry.cs +++ b/Aaru.Decoders/SCSI/Inquiry.cs @@ -32,7 +32,6 @@ using System; using System.Diagnostics.CodeAnalysis; -using System.Linq; using System.Text; using Aaru.CommonTypes.Structs.Devices.SCSI; using Aaru.Helpers; @@ -2512,7 +2511,7 @@ public static class Inquiry { if(response.KreonPresent) { - byte[] vendor = new byte[7]; + var vendor = new byte[7]; Array.Copy(response.VendorSpecific, 11, vendor, 0, 7); sb.AppendLine($"[bold][blue]{Localization.Vendor_specific_bytes_47_to_55}[/][/]"); sb.AppendLine("============================================================"); diff --git a/Aaru.Decoders/SCSI/MMC/Features.cs b/Aaru.Decoders/SCSI/MMC/Features.cs index 7700d991f..43e68fdbe 100644 --- a/Aaru.Decoders/SCSI/MMC/Features.cs +++ b/Aaru.Decoders/SCSI/MMC/Features.cs @@ -1193,7 +1193,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0000) return null; @@ -1205,7 +1205,7 @@ public static class Features decoded.Persistent |= (feature[2] & 0x02) == 0x02; decoded.Version = (byte)((feature[2] & 0x3C) >> 2); - int offset = 4; + var offset = 4; List listProfiles = []; while(offset < feature.Length) @@ -1231,7 +1231,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0001) return null; @@ -1259,7 +1259,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0002) return null; @@ -1284,7 +1284,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0003) return null; @@ -1315,7 +1315,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0004) return null; @@ -1343,7 +1343,7 @@ public static class Features if(feature.Length < 12) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0010) return null; @@ -1370,7 +1370,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x001D) return null; @@ -1391,7 +1391,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x001E) return null; @@ -1420,7 +1420,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x001F) return null; @@ -1450,7 +1450,7 @@ public static class Features if(feature.Length < 16) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0020) return null; @@ -1480,7 +1480,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0021) return null; @@ -1515,7 +1515,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0022) return null; @@ -1536,7 +1536,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0023) return null; @@ -1568,7 +1568,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0024) return null; @@ -1591,7 +1591,7 @@ public static class Features if(feature.Length < 12) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0025) return null; @@ -1618,7 +1618,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0026) return null; @@ -1639,7 +1639,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0027) return null; @@ -1660,7 +1660,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0028) return null; @@ -1688,7 +1688,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0029) return null; @@ -1713,7 +1713,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x002A) return null; @@ -1739,7 +1739,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x002B) return null; @@ -1762,7 +1762,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x002C) return null; @@ -1788,7 +1788,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x002D) return null; @@ -1820,7 +1820,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x002E) return null; @@ -1851,7 +1851,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x002F) return null; @@ -1879,7 +1879,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0030) return null; @@ -1900,7 +1900,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0031) return null; @@ -1923,7 +1923,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0032) return null; @@ -1947,7 +1947,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0033) return null; @@ -1973,7 +1973,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0035) return null; @@ -1994,7 +1994,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0037) return null; @@ -2017,7 +2017,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0038) return null; @@ -2038,7 +2038,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x003A) return null; @@ -2063,7 +2063,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x003B) return null; @@ -2086,7 +2086,7 @@ public static class Features if(feature.Length < 32) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0040) return null; @@ -2119,7 +2119,7 @@ public static class Features if(feature.Length < 24) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0041) return null; @@ -2150,7 +2150,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0042) return null; @@ -2171,7 +2171,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0050) return null; @@ -2195,7 +2195,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0051) return null; @@ -2219,7 +2219,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0080) return null; @@ -2242,7 +2242,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0100) return null; @@ -2263,7 +2263,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0101) return null; @@ -2286,7 +2286,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0102) return null; @@ -2311,7 +2311,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0103) return null; @@ -2337,7 +2337,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0104) return null; @@ -2360,7 +2360,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0105) return null; @@ -2386,7 +2386,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0106) return null; @@ -2409,7 +2409,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0107) return null; @@ -2444,7 +2444,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0108) return null; @@ -2456,7 +2456,7 @@ public static class Features decoded.Persistent |= (feature[2] & 0x02) == 0x02; decoded.Version = (byte)((feature[2] & 0x3C) >> 2); - byte[] serial = new byte[feature.Length]; + var serial = new byte[feature.Length]; Array.Copy(feature, 4, serial, 0, feature.Length - 4); decoded.Serial = StringHandlers.CToString(serial).Trim(); @@ -2469,7 +2469,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0109) return null; @@ -2490,7 +2490,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x010A) return null; @@ -2504,7 +2504,7 @@ public static class Features decoded.DCBs = new uint[feature[3] / 4]; - for(int i = 0; i < decoded.DCBs.Length; i++) + for(var i = 0; i < decoded.DCBs.Length; i++) { decoded.DCBs[i] = (uint)((feature[0 + 4 + i * 4] << 24) + (feature[1 + 4 + i * 4] << 16) + @@ -2521,7 +2521,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x010B) return null; @@ -2544,7 +2544,7 @@ public static class Features if(feature.Length < 20) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x010C) return null; @@ -2573,7 +2573,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x010D) return null; @@ -2606,7 +2606,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x010E) return null; @@ -2629,7 +2629,7 @@ public static class Features if(feature.Length < 8) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0110) return null; @@ -2650,7 +2650,7 @@ public static class Features if(feature.Length < 4) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0113) return null; @@ -2671,7 +2671,7 @@ public static class Features if(feature.Length < 6) return null; - ushort number = (ushort)((feature[0] << 8) + feature[1]); + var number = (ushort)((feature[0] << 8) + feature[1]); if(number != 0x0142) return null; @@ -2690,7 +2690,7 @@ public static class Features if(feature[5] * 2 + 6 != feature.Length) return decoded; - for(int i = 0; i < feature[5]; i++) + for(var i = 0; i < feature[5]; i++) decoded.Profiles[i] = (ushort)((feature[0 + 6 + 2 * i] << 8) + feature[1 + 6 + 2 * i]); return decoded; @@ -4170,7 +4170,7 @@ public static class Features Feature_010C ftr = feature.Value; var sb = new StringBuilder(); - byte[] temp = new byte[4]; + var temp = new byte[4]; temp[0] = (byte)((ftr.Century & 0xFF00) >> 8); temp[1] = (byte)(ftr.Century & 0xFF); temp[2] = (byte)((ftr.Year & 0xFF00) >> 8); @@ -4339,7 +4339,7 @@ public static class Features if(ftr.Profiles == null) return sb.ToString(); - for(int i = 0; i < ftr.Profiles.Length; i++) + for(var i = 0; i < ftr.Profiles.Length; i++) sb.AppendFormat($"\t[slateblue1]{Localization.Profile_0_1}[/]", i, ftr.Profiles[i]).AppendLine(); return sb.ToString(); diff --git a/Aaru.Decoders/SCSI/Modes/01.cs b/Aaru.Decoders/SCSI/Modes/01.cs index a0830c177..81e55481e 100644 --- a/Aaru.Decoders/SCSI/Modes/01.cs +++ b/Aaru.Decoders/SCSI/Modes/01.cs @@ -42,7 +42,7 @@ public static partial class Modes { public static byte[] EncodeModePage_01(ModePage_01 page) { - byte[] pg = new byte[8]; + var pg = new byte[8]; pg[0] = 0x01; pg[1] = 6; diff --git a/Aaru.Decoders/SCSI/Modes/01_MMC.cs b/Aaru.Decoders/SCSI/Modes/01_MMC.cs index e49fbdd99..c3fae1840 100644 --- a/Aaru.Decoders/SCSI/Modes/01_MMC.cs +++ b/Aaru.Decoders/SCSI/Modes/01_MMC.cs @@ -42,7 +42,7 @@ public static partial class Modes { public static byte[] EncodeModePage_01_MMC(ModePage_01_MMC page) { - byte[] pg = new byte[12]; + var pg = new byte[12]; pg[0] = 0x01; pg[1] = 10; @@ -126,24 +126,24 @@ public static partial class Modes .AppendLine(); } - string AllUsed = $"\t[green]{Localization.All_available_recovery_procedures_will_be_used}[/]\n"; - string CIRCRetriesUsed = $"\t[olive]{Localization.Only_retries_and_CIRC_are_used}[/]\n"; - string RetriesUsed = $"\t[olive]{Localization.Only_retries_are_used}[/]\n"; - string RecoveredNotReported = $"\t[red]{Localization.Recovered_errors_will_not_be_reported}[/]\n"; - string RecoveredReported = $"\t[green]{Localization.Recovered_errors_will_be_reported}[/]\n"; + var AllUsed = $"\t[green]{Localization.All_available_recovery_procedures_will_be_used}[/]\n"; + var CIRCRetriesUsed = $"\t[olive]{Localization.Only_retries_and_CIRC_are_used}[/]\n"; + var RetriesUsed = $"\t[olive]{Localization.Only_retries_are_used}[/]\n"; + var RecoveredNotReported = $"\t[red]{Localization.Recovered_errors_will_not_be_reported}[/]\n"; + var RecoveredReported = $"\t[green]{Localization.Recovered_errors_will_be_reported}[/]\n"; - string RecoveredAbort = + var RecoveredAbort = $"\t[red]{Localization.Recovered_errors_will_be_reported_and_aborted_with_CHECK_CONDITION}[/]\n"; - string UnrecECCAbort = $"\t[red]{Localization.Unrecovered_ECC_errors_will_return_CHECK_CONDITION}[/]"; - string UnrecCIRCAbort = $"\t[red]{Localization.Unrecovered_CIRC_errors_will_return_CHECK_CONDITION}[/]"; - string UnrecECCNotAbort = $"\t[red]{Localization.Unrecovered_ECC_errors_will_not_abort_the_transfer}[/]"; - string UnrecCIRCNotAbort = $"\t[red]{Localization.Unrecovered_CIRC_errors_will_not_abort_the_transfer}[/]"; + var UnrecECCAbort = $"\t[red]{Localization.Unrecovered_ECC_errors_will_return_CHECK_CONDITION}[/]"; + var UnrecCIRCAbort = $"\t[red]{Localization.Unrecovered_CIRC_errors_will_return_CHECK_CONDITION}[/]"; + var UnrecECCNotAbort = $"\t[red]{Localization.Unrecovered_ECC_errors_will_not_abort_the_transfer}[/]"; + var UnrecCIRCNotAbort = $"\t[red]{Localization.Unrecovered_CIRC_errors_will_not_abort_the_transfer}[/]"; - string UnrecECCAbortData = + var UnrecECCAbortData = $"\t[red]{Localization.Unrecovered_ECC_errors_will_return_CHECK_CONDITION_and_the_uncorrected_data}[/]"; - string UnrecCIRCAbortData = + var UnrecCIRCAbortData = $"\t[red]{Localization.Unrecovered_CIRC_errors_will_return_CHECK_CONDITION_and_the_uncorrected_data}[/]"; switch(page.Parameter) diff --git a/Aaru.Decoders/SCSI/Modes/05.cs b/Aaru.Decoders/SCSI/Modes/05.cs index 8607fd409..3c3877c6c 100644 --- a/Aaru.Decoders/SCSI/Modes/05.cs +++ b/Aaru.Decoders/SCSI/Modes/05.cs @@ -185,19 +185,25 @@ public static partial class Modes } if(page.DriveStepRate > 0) + { sb.AppendFormat($"\t[slateblue1]{Localization.Drive_steps_in_0_μs}[/]", $"[lime]{(uint)page.DriveStepRate * 100}[/]") .AppendLine(); + } if(page.DriveStepPulse > 0) + { sb.AppendFormat($"\t[slateblue1]{Localization.Each_step_pulse_is_0_ms}[/]", $"[lime]{page.DriveStepPulse}[/]") .AppendLine(); + } if(page.HeadSettleDelay > 0) + { sb.AppendFormat($"\t[slateblue1]{Localization.Heads_settles_in_0_μs}[/]", $"[lime]{(uint)page.HeadSettleDelay * 100}[/]") .AppendLine(); + } if(!page.TRDY) { @@ -238,24 +244,32 @@ public static partial class Modes .AppendLine(); if(page.WriteCompensation > 0) + { sb.AppendFormat($"\t[slateblue1]{Localization.Write_pre_compensation_is_0}[/]", $"[lime]{page.WriteCompensation}[/]") .AppendLine(); + } if(page.HeadLoadDelay > 0) + { sb.AppendFormat($"\t[slateblue1]{Localization.Head_takes_0_ms_to_load}[/]", $"[lime]{page.HeadLoadDelay}[/]") .AppendLine(); + } if(page.HeadUnloadDelay > 0) + { sb.AppendFormat($"\t[slateblue1]{Localization.Head_takes_0_ms_to_unload}[/]", $"[lime]{page.HeadUnloadDelay}[/]") .AppendLine(); + } if(page.MediumRotationRate > 0) + { sb.AppendFormat($"\t[slateblue1]{Localization.Medium_rotates_at_0_rpm}[/]", $"[lime]{page.MediumRotationRate}[/]") .AppendLine(); + } switch(page.Pin34 & 0x07) { diff --git a/Aaru.Decoders/SCSI/Modes/0D.cs b/Aaru.Decoders/SCSI/Modes/0D.cs index 5444bbbfc..2265e3b1b 100644 --- a/Aaru.Decoders/SCSI/Modes/0D.cs +++ b/Aaru.Decoders/SCSI/Modes/0D.cs @@ -162,14 +162,18 @@ public static partial class Modes } if(page.SecondsPerMinute > 0) + { sb.AppendFormat($"\t[slateblue1]{Localization.Each_minute_has_0_seconds}[/]", $"[lime]{page.SecondsPerMinute}[/]") .AppendLine(); + } if(page.FramesPerSecond > 0) + { sb.AppendFormat($"\t[slateblue1]{Localization.Each_second_has_0_frames}[/]", $"[lime]{page.FramesPerSecond}[/]") .AppendLine(); + } return sb.ToString(); } diff --git a/Aaru.Decoders/SCSI/Modes/1A.cs b/Aaru.Decoders/SCSI/Modes/1A.cs index ef29b97c4..cc401928b 100644 --- a/Aaru.Decoders/SCSI/Modes/1A.cs +++ b/Aaru.Decoders/SCSI/Modes/1A.cs @@ -148,14 +148,18 @@ public static partial class Modes if(page is { Standby: true, StandbyTimer: > 0 } or { Standby_Y: true, StandbyTimer_Y: > 0 }) { if(page is { Standby: true, StandbyTimer: > 0 }) + { sb.AppendFormat($"\t[slateblue1]{Localization.Standby_timer_Z_is_set_to_0_ms}[/]", $"[teal]{page.StandbyTimer * 100}[/]") .AppendLine(); + } if(page is { Standby_Y: true, StandbyTimer_Y: > 0 }) + { sb.AppendFormat($"\t[slateblue1]{Localization.Standby_timer_Y_is_set_to_0_ms}[/]", $"[teal]{page.StandbyTimer_Y * 100}[/]") .AppendLine(); + } } else sb.AppendLine($"\t[red]{Localization.Drive_will_not_enter_standby_mode}[/]"); @@ -165,19 +169,25 @@ public static partial class Modes or { Idle_C: true, IdleTimer_C: > 0 }) { if(page is { Idle: true, IdleTimer: > 0 }) + { sb.AppendFormat($"\t[slateblue1]{Localization.Idle_timer_A_is_set_to_0_ms}[/]", $"[teal]{page.IdleTimer * 100}[/]") .AppendLine(); + } if(page is { Idle_B: true, IdleTimer_B: > 0 }) + { sb.AppendFormat($"\t[slateblue1]{Localization.Idle_timer_B_is_set_to_0_ms}[/]", $"[teal]{page.IdleTimer_B * 100}[/]") .AppendLine(); + } if(page is { Idle_C: true, IdleTimer_C: > 0 }) + { sb.AppendFormat($"\t[slateblue1]{Localization.Idle_timer_C_is_set_to_0_ms}[/]", $"[teal]{page.IdleTimer_C * 100}[/]") .AppendLine(); + } } else sb.AppendLine($"\t[red]{Localization.Drive_will_not_enter_idle_mode}[/]"); diff --git a/Aaru.Decoders/SCSI/Modes/1C.cs b/Aaru.Decoders/SCSI/Modes/1C.cs index 1cccbca36..323f33208 100644 --- a/Aaru.Decoders/SCSI/Modes/1C.cs +++ b/Aaru.Decoders/SCSI/Modes/1C.cs @@ -188,9 +188,11 @@ public static partial class Modes if(page.IntervalTimer == 0xFFFFFFFF) sb.AppendLine($"\t[slateblue1]{Localization.Timer_interval_is_vendor_specific}[/]"); else + { sb.AppendFormat($"\t[slateblue1]{Localization.Timer_interval_is_0_ms}[/]", $"[teal]{page.IntervalTimer * 100}[/]") .AppendLine(); + } } if(page.ReportCount > 0) diff --git a/Aaru.Decoders/SCSI/Modes/30_Apple.cs b/Aaru.Decoders/SCSI/Modes/30_Apple.cs index 972b6d5af..d3f6cb37a 100644 --- a/Aaru.Decoders/SCSI/Modes/30_Apple.cs +++ b/Aaru.Decoders/SCSI/Modes/30_Apple.cs @@ -32,7 +32,6 @@ using System; using System.Diagnostics.CodeAnalysis; -using System.Linq; namespace Aaru.Decoders.SCSI; diff --git a/Aaru.Decoders/SCSI/Modes/Headers.cs b/Aaru.Decoders/SCSI/Modes/Headers.cs index 331016611..e6ff267bd 100644 --- a/Aaru.Decoders/SCSI/Modes/Headers.cs +++ b/Aaru.Decoders/SCSI/Modes/Headers.cs @@ -228,8 +228,10 @@ public static partial class Modes if(header.Value.Speed == 0) sb.AppendLine($"\t[green]{Localization.Device_uses_default_speed}[/]"); else + { 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}[/]"); diff --git a/Aaru.Decoders/SCSI/Sense.cs b/Aaru.Decoders/SCSI/Sense.cs index 10c3c8129..fc3507166 100644 --- a/Aaru.Decoders/SCSI/Sense.cs +++ b/Aaru.Decoders/SCSI/Sense.cs @@ -57,11 +57,11 @@ public struct DecodedSense public DescriptorSense? Descriptor; // ReSharper disable once InconsistentNaming - public readonly byte ASC => Descriptor?.ASC ?? (Fixed?.ASC ?? 0); + public readonly byte ASC => Descriptor?.ASC ?? Fixed?.ASC ?? 0; // ReSharper disable once InconsistentNaming - public readonly byte ASCQ => Descriptor?.ASCQ ?? (Fixed?.ASCQ ?? 0); - public readonly SenseKeys SenseKey => Descriptor?.SenseKey ?? (Fixed?.SenseKey ?? SenseKeys.NoSense); + public readonly byte ASCQ => Descriptor?.ASCQ ?? Fixed?.ASCQ ?? 0; + public readonly SenseKeys SenseKey => Descriptor?.SenseKey ?? Fixed?.SenseKey ?? SenseKeys.NoSense; public readonly string Description => Sense.GetSenseDescription(ASC, ASCQ); } @@ -310,7 +310,7 @@ public static class Sense senseDescription = GetSenseDescription(decoded.ASC, decoded.ASCQ); - int offset = 8; + var offset = 8; while(offset < sense.Length) { @@ -319,7 +319,7 @@ public static class Sense byte descType = sense[offset]; int descLen = sense[offset + 1] + 2; - byte[] desc = new byte[descLen]; + var desc = new byte[descLen]; if(offset + descLen >= sense.Length) descLen = sense.Length - offset; @@ -466,7 +466,7 @@ public static class Sense { if(descriptor.Length != 12 || descriptor[0] != 0x00) return 0; - byte[] temp = new byte[8]; + var temp = new byte[8]; temp[0] = descriptor[11]; temp[1] = descriptor[10]; @@ -487,7 +487,7 @@ public static class Sense { if(descriptor.Length != 12 || descriptor[0] != 0x01) return 0; - byte[] temp = new byte[8]; + var temp = new byte[8]; temp[0] = descriptor[11]; temp[1] = descriptor[10]; @@ -508,7 +508,7 @@ public static class Sense { if(descriptor.Length != 8 || descriptor[0] != 0x02) return null; - byte[] temp = new byte[3]; + var temp = new byte[3]; Array.Copy(descriptor, 4, temp, 0, 3); return temp; diff --git a/Aaru.Decoders/SecureDigital/CSD.cs b/Aaru.Decoders/SecureDigital/CSD.cs index a4d3ab308..d60584bc9 100644 --- a/Aaru.Decoders/SecureDigital/CSD.cs +++ b/Aaru.Decoders/SecureDigital/CSD.cs @@ -290,8 +290,9 @@ public static partial class Decoders unit = ""; for(int cl = 0, mask = 1; cl <= 11; cl++, mask <<= 1) - if((csd.Classes & mask) == mask) - unit += $" {cl}"; + { + if((csd.Classes & mask) == mask) unit += $" {cl}"; + } sb.AppendFormat("\t" + Localization.Device_support_command_classes_0, unit).AppendLine(); diff --git a/Aaru.Decoders/Xbox/DMI.cs b/Aaru.Decoders/Xbox/DMI.cs index 9e4f68778..01672f000 100644 --- a/Aaru.Decoders/Xbox/DMI.cs +++ b/Aaru.Decoders/Xbox/DMI.cs @@ -52,12 +52,14 @@ public static class DMI // Catalogue number is two letters, five numbers, one letter for(var i = 12; i < 14; i++) - if(dmi[i] < 0x41 || dmi[i] > 0x5A) - return false; + { + if(dmi[i] < 0x41 || dmi[i] > 0x5A) return false; + } for(var i = 14; i < 19; i++) - if(dmi[i] < 0x30 || dmi[i] > 0x39) - return false; + { + if(dmi[i] < 0x30 || dmi[i] > 0x39) return false; + } if(dmi[19] < 0x41 || dmi[19] > 0x5A) return false; diff --git a/Aaru.Decryption/DVD/Dump.cs b/Aaru.Decryption/DVD/Dump.cs index 12b0f905a..64fa0c97d 100644 --- a/Aaru.Decryption/DVD/Dump.cs +++ b/Aaru.Decryption/DVD/Dump.cs @@ -35,7 +35,6 @@ // ****************************************************************************/ using System; -using System.Linq; using Aaru.Decoders.DVD; using Aaru.Devices; using Aaru.Logging; @@ -378,10 +377,10 @@ public sealed class Dump(Device dev) buffer = []; senseBuffer = dev.SenseBuffer; - bool sense = false; - byte[] challenge = new byte[CHALLENGE_SIZE]; - byte[] key1 = new byte[KEY_SIZE]; - byte variant = 0; + var sense = false; + var challenge = new byte[CHALLENGE_SIZE]; + var key1 = new byte[KEY_SIZE]; + byte variant = 0; for(byte i = 0; i < 4; i++) { diff --git a/Aaru.Decryption/DVD/MPEG.cs b/Aaru.Decryption/DVD/MPEG.cs index 87e61492c..c2f7061c3 100644 --- a/Aaru.Decryption/DVD/MPEG.cs +++ b/Aaru.Decryption/DVD/MPEG.cs @@ -136,8 +136,9 @@ public class Mpeg public static bool ContainsMpegPackets(byte[] sectorData, uint blocks = 1, uint blockSize = 2048) { for(uint i = 0; i < blocks; i++) - if(IsMpegPacket(sectorData.Skip((int)(i * blockSize)))) - return true; + { + if(IsMpegPacket(sectorData.Skip((int)(i * blockSize)))) return true; + } return false; } diff --git a/Aaru.Devices/Aaru.Devices.csproj b/Aaru.Devices/Aaru.Devices.csproj index de6eb023e..8c8b7c15f 100644 --- a/Aaru.Devices/Aaru.Devices.csproj +++ b/Aaru.Devices/Aaru.Devices.csproj @@ -32,7 +32,7 @@ - + diff --git a/Aaru.Devices/Device/Constructor.cs b/Aaru.Devices/Device/Constructor.cs index c41b227d1..0f5caf2fc 100644 --- a/Aaru.Devices/Device/Constructor.cs +++ b/Aaru.Devices/Device/Constructor.cs @@ -215,9 +215,8 @@ public partial class Device : IDisposable if(string.IsNullOrEmpty(dev.Serial)) dev.Serial = dev.UsbSerialString; else - { - foreach(char c in dev.Serial.Where(static c => !char.IsControl(c))) dev.Serial = $"{dev.Serial}{c:X2}"; - } + foreach(char c in dev.Serial.Where(static c => !char.IsControl(c))) + dev.Serial = $"{dev.Serial}{c:X2}"; } if(dev.IsFireWire) @@ -229,9 +228,8 @@ public partial class Device : IDisposable if(string.IsNullOrEmpty(dev.Serial)) dev.Serial = $"{dev.FirewireGuid:X16}"; else - { - foreach(char c in dev.Serial.Where(static c => !char.IsControl(c))) dev.Serial = $"{dev.Serial}{c:X2}"; - } + foreach(char c in dev.Serial.Where(static c => !char.IsControl(c))) + dev.Serial = $"{dev.Serial}{c:X2}"; } // Some optical drives are not getting the correct serial, and IDENTIFY PACKET DEVICE is blocked without diff --git a/Aaru.Devices/Device/ScsiCommands/Adaptec.cs b/Aaru.Devices/Device/ScsiCommands/Adaptec.cs index 6af338b44..e542a9acb 100644 --- a/Aaru.Devices/Device/ScsiCommands/Adaptec.cs +++ b/Aaru.Devices/Device/ScsiCommands/Adaptec.cs @@ -101,7 +101,7 @@ public partial class Device public bool AdaptecSetErrorThreshold(byte threshold, out ReadOnlySpan senseBuffer, bool drive1, uint timeout, out double duration) { - byte[] buffer = new byte[1]; + var buffer = new byte[1]; buffer[0] = threshold; Span cdb = CdbBuffer[..6]; cdb.Clear(); @@ -167,7 +167,7 @@ public partial class Device /// Duration. public bool AdaptecWriteBuffer(byte[] buffer, out ReadOnlySpan senseBuffer, uint timeout, out double duration) { - byte[] oneKBuffer = new byte[1024]; + var oneKBuffer = new byte[1024]; Array.Copy(buffer, 0, oneKBuffer, 0, buffer.Length < 1024 ? buffer.Length : 1024); Span cdb = CdbBuffer[..6]; diff --git a/Aaru.Devices/Device/ScsiCommands/Fujitsu.cs b/Aaru.Devices/Device/ScsiCommands/Fujitsu.cs index 57c955fe1..155039288 100644 --- a/Aaru.Devices/Device/ScsiCommands/Fujitsu.cs +++ b/Aaru.Devices/Device/ScsiCommands/Fujitsu.cs @@ -52,11 +52,11 @@ public partial class Device string firstHalf, string secondHalf, uint timeout, out double duration) { byte[] tmp; - byte[] firstHalfBytes = new byte[8]; - byte[] secondHalfBytes = new byte[8]; - byte[] buffer = new byte[17]; - bool displayLen = false; - bool halfMsg = false; + var firstHalfBytes = new byte[8]; + var secondHalfBytes = new byte[8]; + var buffer = new byte[17]; + var displayLen = false; + var halfMsg = false; Span cdb = CdbBuffer[..10]; senseBuffer = SenseBuffer; cdb.Clear(); diff --git a/Aaru.Devices/Device/ScsiCommands/HL-DT-ST.cs b/Aaru.Devices/Device/ScsiCommands/HL-DT-ST.cs index 3d371707d..57625b2b7 100644 --- a/Aaru.Devices/Device/ScsiCommands/HL-DT-ST.cs +++ b/Aaru.Devices/Device/ScsiCommands/HL-DT-ST.cs @@ -106,12 +106,12 @@ public partial class Device static bool CheckSectorNumber(IReadOnlyList buffer, uint firstLba, uint transferLength, uint layerbreak, bool otp) { - for(int i = 0; i < transferLength; i++) + for(var i = 0; i < transferLength; i++) { - byte layer = (byte)(buffer[0 + 2064 * i] & 0x1); + var layer = (byte)(buffer[0 + 2064 * i] & 0x1); byte[] sectorBuffer = [0x0, buffer[1 + 2064 * i], buffer[2 + 2064 * i], buffer[3 + 2064 * i]]; - uint sectorNumber = BigEndianBitConverter.ToUInt32(sectorBuffer, 0); + var sectorNumber = BigEndianBitConverter.ToUInt32(sectorBuffer, 0); if(otp) diff --git a/Aaru.Devices/Device/ScsiCommands/Kreon.cs b/Aaru.Devices/Device/ScsiCommands/Kreon.cs index 9b87e351d..31e28c453 100644 --- a/Aaru.Devices/Device/ScsiCommands/Kreon.cs +++ b/Aaru.Devices/Device/ScsiCommands/Kreon.cs @@ -128,7 +128,7 @@ public partial class Device senseBuffer = SenseBuffer; Span cdb = CdbBuffer[..10]; cdb.Clear(); - byte[] buffer = new byte[26]; + var buffer = new byte[26]; features = 0; cdb[0] = (byte)ScsiCommands.KreonCommand; @@ -146,9 +146,9 @@ public partial class Device if(buffer[0] != 0xA5 || buffer[1] != 0x5A || buffer[2] != 0x5A || buffer[3] != 0xA5) return true; - for(int i = 4; i < 26; i += 2) + for(var i = 4; i < 26; i += 2) { - ushort feature = BitConverter.ToUInt16(buffer, i); + var feature = BitConverter.ToUInt16(buffer, i); if(feature == 0x0000) break; diff --git a/Aaru.Devices/Device/ScsiCommands/LiteOn.cs b/Aaru.Devices/Device/ScsiCommands/LiteOn.cs index 0ab66046d..84346d9f0 100644 --- a/Aaru.Devices/Device/ScsiCommands/LiteOn.cs +++ b/Aaru.Devices/Device/ScsiCommands/LiteOn.cs @@ -281,11 +281,11 @@ public partial class Device { // TODO: Save ECC instead of just throwing it away - byte[] deinterleaved = new byte[2064 * transferLength]; + var deinterleaved = new byte[2064 * transferLength]; - for(int j = 0; j < transferLength; j++) + for(var j = 0; j < transferLength; j++) { - for(int i = 0; i < 12; i++) Array.Copy(buffer, j * 2384 + i * 182, deinterleaved, j * 2064 + i * 172, 172); + for(var i = 0; i < 12; i++) Array.Copy(buffer, j * 2384 + i * 182, deinterleaved, j * 2064 + i * 172, 172); } return deinterleaved; diff --git a/Aaru.Devices/Device/ScsiCommands/MMC.cs b/Aaru.Devices/Device/ScsiCommands/MMC.cs index 8b676deb9..d2e6c0cf1 100644 --- a/Aaru.Devices/Device/ScsiCommands/MMC.cs +++ b/Aaru.Devices/Device/ScsiCommands/MMC.cs @@ -98,7 +98,7 @@ public partial class Device if(sense) return true; - ushort confLength = (ushort)((buffer[2] << 8) + buffer[3] + 4); + var confLength = (ushort)((buffer[2] << 8) + buffer[3] + 4); buffer = new byte[confLength]; cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8); cdb[8] = (byte)(buffer.Length & 0xFF); @@ -158,7 +158,7 @@ public partial class Device if(sense) return true; - ushort strctLength = (ushort)((buffer[0] << 8) + buffer[1] + 2); + var strctLength = (ushort)((buffer[0] << 8) + buffer[1] + 2); // WORKAROUND: Some drives return incorrect length information. As these structures are fixed length just apply known length. if(mediaType == MmcDiscStructureMediaType.Bd) @@ -312,7 +312,7 @@ public partial class Device Error = LastError != 0; - uint strctLength = (uint)((tmpBuffer[0] << 8) + tmpBuffer[1] + 2); + var strctLength = (uint)((tmpBuffer[0] << 8) + tmpBuffer[1] + 2); buffer = new byte[strctLength]; if(buffer.Length <= tmpBuffer.Length) @@ -380,7 +380,7 @@ public partial class Device senseBuffer = SenseBuffer; Span cdb = CdbBuffer[..10]; cdb.Clear(); - byte[] tmpBuffer = new byte[804]; + var tmpBuffer = new byte[804]; cdb[0] = (byte)ScsiCommands.ReadDiscInformation; cdb[1] = (byte)dataType; @@ -391,7 +391,7 @@ public partial class Device Error = LastError != 0; - uint strctLength = (uint)((tmpBuffer[0] << 8) + tmpBuffer[1] + 2); + var strctLength = (uint)((tmpBuffer[0] << 8) + tmpBuffer[1] + 2); if(strctLength > tmpBuffer.Length) strctLength = (uint)tmpBuffer.Length; @@ -536,7 +536,7 @@ public partial class Device cdb[10] = (byte)subchannel; - uint transferLength = (uint)((cdb[6] - cdb[3]) * 60 * 75 + (cdb[7] - cdb[4]) * 75 + (cdb[8] - cdb[5])); + var transferLength = (uint)((cdb[6] - cdb[3]) * 60 * 75 + (cdb[7] - cdb[4]) * 75 + (cdb[8] - cdb[5])); buffer = new byte[blockSize * transferLength]; diff --git a/Aaru.Devices/Device/ScsiCommands/Pioneer.cs b/Aaru.Devices/Device/ScsiCommands/Pioneer.cs index 6fcd1da85..5f0cbd7ae 100644 --- a/Aaru.Devices/Device/ScsiCommands/Pioneer.cs +++ b/Aaru.Devices/Device/ScsiCommands/Pioneer.cs @@ -101,7 +101,7 @@ public partial class Device cdb[9] = (byte)(endMsf & 0xFF); cdb[10] = (byte)subchannel; - uint transferLength = (uint)((cdb[7] - cdb[3]) * 60 * 75 + (cdb[8] - cdb[4]) * 75 + (cdb[9] - cdb[5])); + var transferLength = (uint)((cdb[7] - cdb[3]) * 60 * 75 + (cdb[8] - cdb[4]) * 75 + (cdb[9] - cdb[5])); buffer = new byte[blockSize * transferLength]; LastError = SendScsiCommand(cdb, ref buffer, timeout, ScsiDirection.In, out duration, out bool sense); diff --git a/Aaru.Devices/Device/ScsiCommands/Plextor.cs b/Aaru.Devices/Device/ScsiCommands/Plextor.cs index 4881325b8..c869295ba 100644 --- a/Aaru.Devices/Device/ScsiCommands/Plextor.cs +++ b/Aaru.Devices/Device/ScsiCommands/Plextor.cs @@ -214,7 +214,7 @@ public partial class Device public bool PlextorGetSpeeds(out ReadOnlySpan senseBuffer, out ushort selected, out ushort max, out ushort last, uint timeout, out double duration) { - byte[] buf = new byte[10]; + var buf = new byte[10]; senseBuffer = SenseBuffer; Span cdb = CdbBuffer[..12]; cdb.Clear(); @@ -251,7 +251,7 @@ public partial class Device public bool PlextorGetPoweRec(out ReadOnlySpan senseBuffer, out bool enabled, out ushort speed, uint timeout, out double duration) { - byte[] buf = new byte[8]; + var buf = new byte[8]; senseBuffer = SenseBuffer; Span cdb = CdbBuffer[..12]; cdb.Clear(); diff --git a/Aaru.Devices/Device/ScsiCommands/SMC.cs b/Aaru.Devices/Device/ScsiCommands/SMC.cs index 69d80db1e..f7ca0c40f 100644 --- a/Aaru.Devices/Device/ScsiCommands/SMC.cs +++ b/Aaru.Devices/Device/ScsiCommands/SMC.cs @@ -80,7 +80,7 @@ public partial class Device if(sense) return true; - uint attrLen = (uint)((buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) + buffer[3] + 4); + var attrLen = (uint)((buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) + buffer[3] + 4); buffer = new byte[attrLen]; cdb[10] = (byte)((buffer.Length & 0xFF000000) >> 24); cdb[11] = (byte)((buffer.Length & 0xFF0000) >> 16); diff --git a/Aaru.Devices/Device/ScsiCommands/SPC.cs b/Aaru.Devices/Device/ScsiCommands/SPC.cs index 1f4a321ef..aa5da7d03 100644 --- a/Aaru.Devices/Device/ScsiCommands/SPC.cs +++ b/Aaru.Devices/Device/ScsiCommands/SPC.cs @@ -93,7 +93,7 @@ public partial class Device if(sense) return true; - byte pagesLength = (byte)(buffer[4] + 5); + var pagesLength = (byte)(buffer[4] + 5); cdb[0] = (byte)ScsiCommands.Inquiry; cdb[1] = 0; @@ -177,7 +177,7 @@ public partial class Device // This is because INQ was returned instead of EVPD if(buffer[1] != page) return true; - byte pagesLength = (byte)(buffer[3] + 4); + var pagesLength = (byte)(buffer[3] + 4); cdb[0] = (byte)ScsiCommands.Inquiry; cdb[1] = 1; @@ -281,7 +281,7 @@ public partial class Device if(sense) return true; - byte modeLength = (byte)(buffer[0] + 1); + var modeLength = (byte)(buffer[0] + 1); if(modeLength % 2 != 0) modeLength++; buffer = new byte[modeLength]; @@ -363,7 +363,7 @@ public partial class Device if(sense) return true; - ushort modeLength = (ushort)((buffer[0] << 8) + buffer[1] + 2); + var modeLength = (ushort)((buffer[0] << 8) + buffer[1] + 2); if(modeLength % 2 != 0) modeLength++; buffer = new byte[modeLength]; @@ -568,7 +568,7 @@ public partial class Device if(sense) return true; - uint strctLength = (uint)((buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) + buffer[3] + 4); + var strctLength = (uint)((buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) + buffer[3] + 4); buffer = new byte[strctLength]; cdb[6] = (byte)((buffer.Length & 0xFF000000) >> 24); cdb[7] = (byte)((buffer.Length & 0xFF0000) >> 16); diff --git a/Aaru.Devices/Device/ScsiCommands/SSC.cs b/Aaru.Devices/Device/ScsiCommands/SSC.cs index b85ab339c..6a3984978 100644 --- a/Aaru.Devices/Device/ScsiCommands/SSC.cs +++ b/Aaru.Devices/Device/ScsiCommands/SSC.cs @@ -908,7 +908,7 @@ public partial class Device if(sense) return true; - ushort availableLength = (ushort)((buffer[0] << 8) + buffer[1] + 2); + var availableLength = (ushort)((buffer[0] << 8) + buffer[1] + 2); buffer = new byte[availableLength]; cdb[7] = (byte)((buffer.Length & 0xFF00) >> 8); cdb[8] = (byte)(buffer.Length & 0xFF); diff --git a/Aaru.Devices/Linux/Command.cs b/Aaru.Devices/Linux/Command.cs index 9121e4c38..6333aba25 100644 --- a/Aaru.Devices/Linux/Command.cs +++ b/Aaru.Devices/Linux/Command.cs @@ -193,7 +193,7 @@ partial class Device if(buffer == null) return -1; - byte[] cdb = new byte[16]; + var cdb = new byte[16]; cdb[0] = (byte)ScsiCommands.AtaPassThrough16; cdb[1] = (byte)((byte)protocol << 1 & 0x1E); @@ -257,7 +257,7 @@ partial class Device if(buffer == null) return -1; - byte[] cdb = new byte[16]; + var cdb = new byte[16]; cdb[0] = (byte)ScsiCommands.AtaPassThrough16; cdb[1] = (byte)((byte)protocol << 1 & 0x1E); @@ -321,7 +321,7 @@ partial class Device if(buffer == null) return -1; - byte[] cdb = new byte[16]; + var cdb = new byte[16]; cdb[0] = (byte)ScsiCommands.AtaPassThrough16; cdb[1] = (byte)((byte)protocol << 1 & 0x1E); cdb[1] |= 0x01; @@ -503,17 +503,17 @@ partial class Device sense = false; // Create array for buffers - IntPtr[] bufferPointers = new nint[commands.Length]; + var bufferPointers = new nint[commands.Length]; // Allocate memory for the array for commands - byte[] ioMultiCmd = new byte[sizeof(ulong) + Marshal.SizeOf() * commands.Length]; + var ioMultiCmd = new byte[sizeof(ulong) + Marshal.SizeOf() * commands.Length]; // First value of array is uint64 with count of commands Array.Copy(BitConverter.GetBytes((ulong)commands.Length), 0, ioMultiCmd, 0, sizeof(ulong)); int off = sizeof(ulong); - for(int i = 0; i < commands.Length; i++) + for(var i = 0; i < commands.Length; i++) { // Create command var ioCmd = new MmcIocCmd(); @@ -573,9 +573,9 @@ partial class Device Marshal.Copy(ioMultiCmdPtr, ioMultiCmd, 0, ioMultiCmd.Length); // TODO: Use real pointers this is too slow - for(int i = 0; i < commands.Length; i++) + for(var i = 0; i < commands.Length; i++) { - byte[] tmp = new byte[Marshal.SizeOf()]; + var tmp = new byte[Marshal.SizeOf()]; // Copy command to managed space Array.Copy(ioMultiCmd, off, tmp, 0, tmp.Length); @@ -675,7 +675,7 @@ partial class Device resultSize = result; } - byte[] resultString = new byte[resultSize]; + var resultString = new byte[resultSize]; Marshal.Copy(buf, resultString, 0, resultSize); Marshal.FreeHGlobal(buf); diff --git a/Aaru.Devices/Linux/Device.cs b/Aaru.Devices/Linux/Device.cs index c8c14dfe9..4f618334a 100644 --- a/Aaru.Devices/Linux/Device.cs +++ b/Aaru.Devices/Linux/Device.cs @@ -248,8 +248,8 @@ partial class Device : Devices.Device, IDisposable var usbFs = new FileStream(resolvedLink + "/descriptors", FileMode.Open, FileAccess.Read); - byte[] usbBuf = new byte[65536]; - int usbCount = usbFs.EnsureRead(usbBuf, 0, 65536); + var usbBuf = new byte[65536]; + int usbCount = usbFs.EnsureRead(usbBuf, 0, 65536); dev.UsbDescriptors = new byte[usbCount]; Array.Copy(usbBuf, 0, dev.UsbDescriptors, 0, usbCount); usbFs.Close(); @@ -417,8 +417,8 @@ partial class Device : Devices.Device, IDisposable var cisFs = new FileStream(possibleDir + "/cis", FileMode.Open, FileAccess.Read); - byte[] cisBuf = new byte[65536]; - int cisCount = cisFs.EnsureRead(cisBuf, 0, 65536); + var cisBuf = new byte[65536]; + int cisCount = cisFs.EnsureRead(cisBuf, 0, 65536); dev.Cis = new byte[cisCount]; Array.Copy(cisBuf, 0, dev.Cis, 0, cisCount); cisFs.Close(); diff --git a/Aaru.Devices/Remote/Command.cs b/Aaru.Devices/Remote/Command.cs index c3f9f1ae7..28355b3aa 100644 --- a/Aaru.Devices/Remote/Command.cs +++ b/Aaru.Devices/Remote/Command.cs @@ -194,7 +194,7 @@ public partial class Device if(_remote.ServerProtocolVersion >= 2) return _remote.SendMultipleMmcCommands(commands, out duration, out sense, timeout); - int error = 0; + var error = 0; duration = 0; sense = false; diff --git a/Aaru.Devices/Windows/Command.cs b/Aaru.Devices/Windows/Command.cs index f02214670..9a46baf99 100644 --- a/Aaru.Devices/Windows/Command.cs +++ b/Aaru.Devices/Windows/Command.cs @@ -87,7 +87,7 @@ partial class Device if(direction != ScsiDirection.In) buffer.AsSpan().CopyTo(new Span((void*)_nativeBuffer, buffer.Length)); uint k = 0; - int error = 0; + var error = 0; var cmdStopwatch = new Stopwatch(); cmdStopwatch.Start(); @@ -172,7 +172,7 @@ partial class Device aptd.AtaFlags |= AtaFlags.DrdyRequired; uint k = 0; - int error = 0; + var error = 0; Marshal.Copy(buffer, 0, aptd.DataBuffer, buffer.Length); @@ -267,7 +267,7 @@ partial class Device aptd.AtaFlags |= AtaFlags.DrdyRequired; uint k = 0; - int error = 0; + var error = 0; Marshal.Copy(buffer, 0, aptd.DataBuffer, buffer.Length); @@ -371,7 +371,7 @@ partial class Device aptd.AtaFlags |= AtaFlags.DrdyRequired; uint k = 0; - int error = 0; + var error = 0; Marshal.Copy(buffer, 0, aptd.DataBuffer, buffer.Length); @@ -534,18 +534,17 @@ partial class Device if(flags.HasFlag(MmcFlags.ResponseR6)) commandDescriptor.responseType = SdResponseType.R6; - byte[] commandB = - new byte[commandData.size + commandData.protocolArgumentSize + commandData.deviceDataBufferSize]; + var commandB = new byte[commandData.size + commandData.protocolArgumentSize + commandData.deviceDataBufferSize]; Array.Copy(buffer, 0, commandB, commandData.size + commandData.protocolArgumentSize, buffer.Length); IntPtr hBuf = Marshal.AllocHGlobal(commandB.Length); Marshal.StructureToPtr(commandData, hBuf, true); - IntPtr descriptorOffset = IntPtr.Add(hBuf, commandData.size); + var descriptorOffset = IntPtr.Add(hBuf, commandData.size); Marshal.StructureToPtr(commandDescriptor, descriptorOffset, true); Marshal.Copy(hBuf, commandB, 0, commandB.Length); Marshal.FreeHGlobal(hBuf); - int error = 0; + var error = 0; cmdStopwatch.Restart(); sense = !Extern.DeviceIoControl(_fileHandle, @@ -577,7 +576,7 @@ partial class Device // We need a timeout if(timeout == 0) timeout = Timeout > 0 ? Timeout : 15; - int error = 0; + var error = 0; duration = 0; sense = false; diff --git a/Aaru.Devices/Windows/Device.cs b/Aaru.Devices/Windows/Device.cs index 6494fac89..6a0ad1313 100644 --- a/Aaru.Devices/Windows/Device.cs +++ b/Aaru.Devices/Windows/Device.cs @@ -128,10 +128,10 @@ partial class Device : Devices.Device, IDisposable }; IntPtr descriptorPtr = Marshal.AllocHGlobal(1000); - byte[] descriptorB = new byte[1000]; + var descriptorB = new byte[1000]; uint returned = 0; - int error = 0; + var error = 0; bool hasError = !Extern.DeviceIoControlStorageQuery(dev._fileHandle, WindowsIoctl.IoctlStorageQueryProperty, @@ -229,7 +229,7 @@ partial class Device : Devices.Device, IDisposable if(IsSdhci(dev._fileHandle)) { - byte[] sdBuffer = new byte[16]; + var sdBuffer = new byte[16]; dev.LastError = dev.SendMmcCommand(MmcCommands.SendCsd, false, diff --git a/Aaru.Filesystems/Aaru.Filesystems.csproj b/Aaru.Filesystems/Aaru.Filesystems.csproj index 95547a968..81e94e705 100644 --- a/Aaru.Filesystems/Aaru.Filesystems.csproj +++ b/Aaru.Filesystems/Aaru.Filesystems.csproj @@ -34,7 +34,7 @@ - + diff --git a/Aaru.Filesystems/CBM/Super.cs b/Aaru.Filesystems/CBM/Super.cs index 80edaf437..c5cd31840 100644 --- a/Aaru.Filesystems/CBM/Super.cs +++ b/Aaru.Filesystems/CBM/Super.cs @@ -241,8 +241,9 @@ public sealed partial class CBM _statfs.FreeFiles--; for(var i = 0; i < dirEntry.name.Length; i++) - if(dirEntry.name[i] == 0xA0) - dirEntry.name[i] = 0; + { + if(dirEntry.name[i] == 0xA0) dirEntry.name[i] = 0; + } string name = StringHandlers.CToString(dirEntry.name, encoding); diff --git a/Aaru.Filesystems/CPM/Definitions.cs b/Aaru.Filesystems/CPM/Definitions.cs index d5ae7d6ad..80da21f32 100644 --- a/Aaru.Filesystems/CPM/Definitions.cs +++ b/Aaru.Filesystems/CPM/Definitions.cs @@ -69,7 +69,7 @@ public sealed partial class CPM sectorIds = new int[def.sectorsPerTrack] }; - for(int i = 0; i < def.sectorsPerTrack; i++) def.side1.sectorIds[i] = i + 1; + for(var i = 0; i < def.sectorsPerTrack; i++) def.side1.sectorIds[i] = i + 1; } if(def.sides != 2 || def.side2 != null) continue; @@ -81,7 +81,7 @@ public sealed partial class CPM sectorIds = new int[def.sectorsPerTrack] }; - for(int i = 0; i < def.sectorsPerTrack; i++) def.side2.sectorIds[i] = i + 1; + for(var i = 0; i < def.sectorsPerTrack; i++) def.side2.sectorIds[i] = i + 1; } } diff --git a/Aaru.Filesystems/CPM/Dir.cs b/Aaru.Filesystems/CPM/Dir.cs index 2f63a70b9..08c46808b 100644 --- a/Aaru.Filesystems/CPM/Dir.cs +++ b/Aaru.Filesystems/CPM/Dir.cs @@ -41,6 +41,85 @@ namespace Aaru.Filesystems; public sealed partial class CPM { + /// + /// Checks that the given directory blocks follow the CP/M filesystem directory specification Corrupted + /// directories will fail. FAT directories will false positive if all files start with 0x05, and do not use full + /// extensions, for example: "σAFILE.GZ" (using code page 437) + /// + /// False if the directory does not follow the directory specification + /// Directory blocks. + bool CheckDir(byte[] directory) + { + try + { + if(directory == null) return false; + + var fileCount = 0; + + for(var off = 0; off < directory.Length; off += 32) + { + DirectoryEntry entry = Marshal.ByteArrayToStructureLittleEndian(directory, off, 32); + + if((entry.statusUser & 0x7F) < 0x20) + { + for(var f = 0; f < 8; f++) + { + if(entry.filename[f] < 0x20 && entry.filename[f] != 0x00) return false; + } + + for(var e = 0; e < 3; e++) + { + if(entry.extension[e] < 0x20 && entry.extension[e] != 0x00) return false; + } + + if(!ArrayHelpers.ArrayIsNullOrWhiteSpace(entry.filename)) fileCount++; + } + else + { + switch(entry.statusUser) + { + case 0x20: + { + for(var f = 0; f < 8; f++) + { + if(entry.filename[f] < 0x20 && entry.filename[f] != 0x00) return false; + } + + for(var e = 0; e < 3; e++) + { + if(entry.extension[e] < 0x20 && entry.extension[e] != 0x00) return false; + } + + _label = Encoding.ASCII.GetString(directory, off + 1, 11).Trim(); + _labelCreationDate = new byte[4]; + _labelUpdateDate = new byte[4]; + Array.Copy(directory, off + 24, _labelCreationDate, 0, 4); + Array.Copy(directory, off + 28, _labelUpdateDate, 0, 4); + + break; + } + case 0x21 when directory[off + 1] == 0x00: + _thirdPartyTimestamps = true; + + break; + case 0x21: + _standardTimestamps |= directory[off + 21] == 0x00 && directory[off + 31] == 0x00; + + break; + } + } + } + + return fileCount > 0; + } + catch(Exception ex) + { + SentrySdk.CaptureException(ex); + + return false; + } + } + #region IReadOnlyFilesystem Members /// @@ -93,79 +172,4 @@ public sealed partial class CPM } #endregion - - /// - /// Checks that the given directory blocks follow the CP/M filesystem directory specification Corrupted - /// directories will fail. FAT directories will false positive if all files start with 0x05, and do not use full - /// extensions, for example: "σAFILE.GZ" (using code page 437) - /// - /// False if the directory does not follow the directory specification - /// Directory blocks. - bool CheckDir(byte[] directory) - { - try - { - if(directory == null) return false; - - int fileCount = 0; - - for(int off = 0; off < directory.Length; off += 32) - { - DirectoryEntry entry = Marshal.ByteArrayToStructureLittleEndian(directory, off, 32); - - if((entry.statusUser & 0x7F) < 0x20) - { - for(int f = 0; f < 8; f++) - if(entry.filename[f] < 0x20 && entry.filename[f] != 0x00) - return false; - - for(int e = 0; e < 3; e++) - if(entry.extension[e] < 0x20 && entry.extension[e] != 0x00) - return false; - - if(!ArrayHelpers.ArrayIsNullOrWhiteSpace(entry.filename)) fileCount++; - } - else - { - switch(entry.statusUser) - { - case 0x20: - { - for(int f = 0; f < 8; f++) - if(entry.filename[f] < 0x20 && entry.filename[f] != 0x00) - return false; - - for(int e = 0; e < 3; e++) - if(entry.extension[e] < 0x20 && entry.extension[e] != 0x00) - return false; - - _label = Encoding.ASCII.GetString(directory, off + 1, 11).Trim(); - _labelCreationDate = new byte[4]; - _labelUpdateDate = new byte[4]; - Array.Copy(directory, off + 24, _labelCreationDate, 0, 4); - Array.Copy(directory, off + 28, _labelUpdateDate, 0, 4); - - break; - } - case 0x21 when directory[off + 1] == 0x00: - _thirdPartyTimestamps = true; - - break; - case 0x21: - _standardTimestamps |= directory[off + 21] == 0x00 && directory[off + 31] == 0x00; - - break; - } - } - } - - return fileCount > 0; - } - catch(Exception ex) - { - SentrySdk.CaptureException(ex); - - return false; - } - } } \ No newline at end of file diff --git a/Aaru.Filesystems/CPM/Info.cs b/Aaru.Filesystems/CPM/Info.cs index 53deba2b5..fb90da62e 100644 --- a/Aaru.Filesystems/CPM/Info.cs +++ b/Aaru.Filesystems/CPM/Info.cs @@ -1033,9 +1033,8 @@ public sealed partial class CPM // Complement of the directory bytes if needed if(def.complement) - { - for(var b = 0; b < directory.Length; b++) directory[b] = (byte)(~directory[b] & 0xFF); - } + for(var b = 0; b < directory.Length; b++) + directory[b] = (byte)(~directory[b] & 0xFF); // Check the directory if(CheckDir(directory)) diff --git a/Aaru.Filesystems/CPM/Super.cs b/Aaru.Filesystems/CPM/Super.cs index 6ad643729..f130b1ca2 100644 --- a/Aaru.Filesystems/CPM/Super.cs +++ b/Aaru.Filesystems/CPM/Super.cs @@ -169,9 +169,8 @@ public sealed partial class CPM if(errno != ErrorNumber.NoError) return errno; if(_workingDefinition.complement) - { - for(var b = 0; b < readSector.Length; b++) readSector[b] = (byte)(~readSector[b] & 0xFF); - } + for(var b = 0; b < readSector.Length; b++) + readSector[b] = (byte)(~readSector[b] & 0xFF); deinterleavedSectors.Add((ulong)p, readSector); } diff --git a/Aaru.Filesystems/CPM/Xattr.cs b/Aaru.Filesystems/CPM/Xattr.cs index e9b93d7e1..aaba1bf83 100644 --- a/Aaru.Filesystems/CPM/Xattr.cs +++ b/Aaru.Filesystems/CPM/Xattr.cs @@ -52,9 +52,8 @@ public sealed partial class CPM if(!_fileCache.ContainsKey(pathElements[0].ToUpperInvariant())) return ErrorNumber.NoSuchFile; if(string.Compare(xattr, "com.caldera.cpm.password", StringComparison.InvariantCulture) == 0) - { - if(!_passwordCache.TryGetValue(pathElements[0].ToUpperInvariant(), out buf)) return ErrorNumber.NoError; - } + if(!_passwordCache.TryGetValue(pathElements[0].ToUpperInvariant(), out buf)) + return ErrorNumber.NoError; if(string.Compare(xattr, "com.caldera.cpm.password.text", StringComparison.InvariantCulture) != 0) return ErrorNumber.NoSuchExtendedAttribute; diff --git a/Aaru.Filesystems/FAT/Super.cs b/Aaru.Filesystems/FAT/Super.cs index 8ebdf7b67..9843d5577 100644 --- a/Aaru.Filesystems/FAT/Super.cs +++ b/Aaru.Filesystems/FAT/Super.cs @@ -194,8 +194,9 @@ public sealed partial class FAT }; if((fat32Bpb.flags & 0xF8) == 0x00) - if((fat32Bpb.flags & 0x01) == 0x01) - Metadata.Dirty = true; + { + if((fat32Bpb.flags & 0x01) == 0x01) Metadata.Dirty = true; + } if((fat32Bpb.mirror_flags & 0x80) == 0x80) _useFirstFat = (fat32Bpb.mirror_flags & 0xF) != 1; @@ -460,8 +461,9 @@ public sealed partial class FAT if(fakeBpb.signature is 0x28 or 0x29 || andosOemCorrect) { if((fakeBpb.flags & 0xF8) == 0x00) - if((fakeBpb.flags & 0x01) == 0x01) - Metadata.Dirty = true; + { + if((fakeBpb.flags & 0x01) == 0x01) Metadata.Dirty = true; + } if(fakeBpb.signature == 0x29 || andosOemCorrect) { diff --git a/Aaru.Filesystems/FATX/Super.cs b/Aaru.Filesystems/FATX/Super.cs index c8f9ff33d..284444ca1 100644 --- a/Aaru.Filesystems/FATX/Super.cs +++ b/Aaru.Filesystems/FATX/Super.cs @@ -154,8 +154,9 @@ public sealed partial class XboxFatPlugin _fat32 = MemoryMarshal.Cast(buffer).ToArray(); if(!_littleEndian) - for(var i = 0; i < _fat32.Length; i++) - _fat32[i] = Swapping.Swap(_fat32[i]); + { + for(var i = 0; i < _fat32.Length; i++) _fat32[i] = Swapping.Swap(_fat32[i]); + } AaruLogging.Debug(MODULE_NAME, "fat32[0] == FATX32_ID = {0}", _fat32[0] == FATX32_ID); @@ -185,8 +186,9 @@ public sealed partial class XboxFatPlugin _fat16 = MemoryMarshal.Cast(buffer).ToArray(); if(!_littleEndian) - for(var i = 0; i < _fat16.Length; i++) - _fat16[i] = Swapping.Swap(_fat16[i]); + { + for(var i = 0; i < _fat16.Length; i++) _fat16[i] = Swapping.Swap(_fat16[i]); + } AaruLogging.Debug(MODULE_NAME, "fat16[0] == FATX16_ID = {0}", _fat16[0] == FATX16_ID); diff --git a/Aaru.Filesystems/LisaFS/File.cs b/Aaru.Filesystems/LisaFS/File.cs index 2291335ea..ec9b47ab8 100644 --- a/Aaru.Filesystems/LisaFS/File.cs +++ b/Aaru.Filesystems/LisaFS/File.cs @@ -105,8 +105,9 @@ public sealed partial class LisaFS if(!_mounted || !_debug) return ErrorNumber.AccessDenied; if(fileId is > 4 or <= 0) - if(fileId != FILEID_BOOT_SIGNED && fileId != FILEID_LOADER_SIGNED) - return ErrorNumber.InvalidArgument; + { + if(fileId != FILEID_BOOT_SIGNED && fileId != FILEID_LOADER_SIGNED) return ErrorNumber.InvalidArgument; + } if(_systemFileCache.TryGetValue(fileId, out buf) && !tags) return ErrorNumber.NoError; @@ -329,8 +330,9 @@ public sealed partial class LisaFS if(!tags) { if(_fileSizeCache.TryGetValue(fileId, out int realSize)) - if(realSize > temp.Length) - AaruLogging.Error(Localization.File_0_gets_truncated, fileId); + { + if(realSize > temp.Length) AaruLogging.Error(Localization.File_0_gets_truncated, fileId); + } buf = temp; diff --git a/Aaru.Filesystems/LisaFS/Xattr.cs b/Aaru.Filesystems/LisaFS/Xattr.cs index 3f623c8fd..2eb2697c0 100644 --- a/Aaru.Filesystems/LisaFS/Xattr.cs +++ b/Aaru.Filesystems/LisaFS/Xattr.cs @@ -42,31 +42,6 @@ namespace Aaru.Filesystems; public sealed partial class LisaFS { -#region IReadOnlyFilesystem Members - - /// - public ErrorNumber ListXAttr(string path, out List xattrs) - { - xattrs = null; - ErrorNumber error = LookupFileId(path, out short fileId, out bool isDir); - - if(error != ErrorNumber.NoError) return error; - - return isDir ? ErrorNumber.InvalidArgument : ListXAttr(fileId, out xattrs); - } - - /// - public ErrorNumber GetXattr(string path, string xattr, ref byte[] buf) - { - ErrorNumber error = LookupFileId(path, out short fileId, out bool isDir); - - if(error != ErrorNumber.NoError) return error; - - return isDir ? ErrorNumber.InvalidArgument : GetXattr(fileId, xattr, out buf); - } - -#endregion - /// Lists special Apple Lisa filesystem features as extended attributes /// Error number. /// File identifier. @@ -199,4 +174,29 @@ public sealed partial class LisaFS return ErrorNumber.NoError; } + +#region IReadOnlyFilesystem Members + + /// + public ErrorNumber ListXAttr(string path, out List xattrs) + { + xattrs = null; + ErrorNumber error = LookupFileId(path, out short fileId, out bool isDir); + + if(error != ErrorNumber.NoError) return error; + + return isDir ? ErrorNumber.InvalidArgument : ListXAttr(fileId, out xattrs); + } + + /// + public ErrorNumber GetXattr(string path, string xattr, ref byte[] buf) + { + ErrorNumber error = LookupFileId(path, out short fileId, out bool isDir); + + if(error != ErrorNumber.NoError) return error; + + return isDir ? ErrorNumber.InvalidArgument : GetXattr(fileId, xattr, out buf); + } + +#endregion } \ No newline at end of file diff --git a/Aaru.Filesystems/Locus/Structs.cs b/Aaru.Filesystems/Locus/Structs.cs index 89a6e7ba5..776dba259 100644 --- a/Aaru.Filesystems/Locus/Structs.cs +++ b/Aaru.Filesystems/Locus/Structs.cs @@ -150,7 +150,7 @@ public sealed partial class Locus public ino_t s_isize; /* size in blocks of i-list */ public short s_nfree; /* number of addresses in s_free */ - public Flags s_flags; /* filsys flags, defined below */ + public Flags s_flags; /* filsys flags, defined below */ public ino_t s_tinode; /* total free inodes */ public ino_t s_lasti; /* start place for circular search */ public ino_t s_nbehind; /* est # free inodes before s_lasti */ diff --git a/Aaru.Filesystems/ReFS/Info.cs b/Aaru.Filesystems/ReFS/Info.cs index 2e1f35bfc..6c7abf431 100644 --- a/Aaru.Filesystems/ReFS/Info.cs +++ b/Aaru.Filesystems/ReFS/Info.cs @@ -27,7 +27,6 @@ // ****************************************************************************/ using System; -using System.Linq; using System.Text; using Aaru.CommonTypes.AaruMetadata; using Aaru.CommonTypes.Enums; diff --git a/Aaru.Filesystems/exFAT/Info.cs b/Aaru.Filesystems/exFAT/Info.cs index 1db92f0b5..fe45cf6a1 100644 --- a/Aaru.Filesystems/exFAT/Info.cs +++ b/Aaru.Filesystems/exFAT/Info.cs @@ -28,7 +28,6 @@ using System; using System.Diagnostics.CodeAnalysis; -using System.Linq; using System.Text; using Aaru.CommonTypes.AaruMetadata; using Aaru.CommonTypes.Enums; diff --git a/Aaru.Filters/AppleDouble.cs b/Aaru.Filters/AppleDouble.cs index c422a9b20..a78953cf5 100644 --- a/Aaru.Filters/AppleDouble.cs +++ b/Aaru.Filters/AppleDouble.cs @@ -33,7 +33,6 @@ using System; using System.Diagnostics.CodeAnalysis; using System.IO; -using System.Linq; using System.Runtime.InteropServices; using Aaru.CommonTypes.Attributes; using Aaru.CommonTypes.Enums; @@ -515,8 +514,7 @@ public sealed partial class AppleDouble : IFilter } else if(_proDosHome.SequenceEqual(_header.homeFilesystem)) { - ProDOSFileInfo prodosinfo = - Marshal.ByteArrayToStructureBigEndian(finfo); + ProDOSFileInfo prodosinfo = Marshal.ByteArrayToStructureBigEndian(finfo); CreationTime = DateHandlers.MacToDateTime(prodosinfo.creationDate); LastWriteTime = DateHandlers.MacToDateTime(prodosinfo.modificationDate); diff --git a/Aaru.Filters/AppleSingle.cs b/Aaru.Filters/AppleSingle.cs index 34d28ed28..aac4ea807 100644 --- a/Aaru.Filters/AppleSingle.cs +++ b/Aaru.Filters/AppleSingle.cs @@ -33,7 +33,6 @@ using System; using System.Diagnostics.CodeAnalysis; using System.IO; -using System.Linq; using System.Runtime.InteropServices; using Aaru.CommonTypes.Attributes; using Aaru.CommonTypes.Enums; @@ -256,8 +255,7 @@ public sealed partial class AppleSingle : IFilter } else if(_proDosHome.SequenceEqual(_header.homeFilesystem)) { - ProDOSFileInfo prodosinfo = - Marshal.ByteArrayToStructureBigEndian(finfo); + ProDOSFileInfo prodosinfo = Marshal.ByteArrayToStructureBigEndian(finfo); CreationTime = DateHandlers.MacToDateTime(prodosinfo.creationDate); LastWriteTime = DateHandlers.MacToDateTime(prodosinfo.modificationDate); @@ -345,8 +343,7 @@ public sealed partial class AppleSingle : IFilter } else if(_proDosHome.SequenceEqual(_header.homeFilesystem)) { - ProDOSFileInfo prodosinfo = - Marshal.ByteArrayToStructureBigEndian(finfo); + ProDOSFileInfo prodosinfo = Marshal.ByteArrayToStructureBigEndian(finfo); CreationTime = DateHandlers.MacToDateTime(prodosinfo.creationDate); LastWriteTime = DateHandlers.MacToDateTime(prodosinfo.modificationDate); @@ -435,8 +432,7 @@ public sealed partial class AppleSingle : IFilter } else if(_proDosHome.SequenceEqual(_header.homeFilesystem)) { - ProDOSFileInfo prodosinfo = - Marshal.ByteArrayToStructureBigEndian(finfo); + ProDOSFileInfo prodosinfo = Marshal.ByteArrayToStructureBigEndian(finfo); CreationTime = DateHandlers.MacToDateTime(prodosinfo.creationDate); LastWriteTime = DateHandlers.MacToDateTime(prodosinfo.modificationDate); diff --git a/Aaru.Filters/XZ.cs b/Aaru.Filters/XZ.cs index ee8759bae..9b2717081 100644 --- a/Aaru.Filters/XZ.cs +++ b/Aaru.Filters/XZ.cs @@ -47,6 +47,60 @@ public sealed class XZ : IFilter Stream _dataStream; Stream _innerStream; + void GuessSize() + { + DataForkLength = 0; + + // Seek to footer backwards size field + _dataStream.Seek(-8, SeekOrigin.End); + var tmp = new byte[4]; + _dataStream.EnsureRead(tmp, 0, 4); + uint backwardSize = (BitConverter.ToUInt32(tmp, 0) + 1) * 4; + + // Seek to first indexed record + _dataStream.Seek(-12 - (backwardSize - 2), SeekOrigin.End); + + // Skip compressed size + tmp = new byte[backwardSize - 2]; + _dataStream.EnsureRead(tmp, 0, tmp.Length); + ulong number = 0; + int ignore = Decode(tmp, tmp.Length, ref number); + + // Get compressed size + _dataStream.Seek(-12 - (backwardSize - 2 - ignore), SeekOrigin.End); + tmp = new byte[backwardSize - 2 - ignore]; + _dataStream.EnsureRead(tmp, 0, tmp.Length); + Decode(tmp, tmp.Length, ref number); + DataForkLength = (long)number; + + _dataStream.Seek(0, SeekOrigin.Begin); + } + + static int Decode(byte[] buf, int sizeMax, ref ulong num) + { + switch(sizeMax) + { + case 0: + return 0; + case > 9: + sizeMax = 9; + + break; + } + + num = (ulong)(buf[0] & 0x7F); + var i = 0; + + while((buf[i++] & 0x80) == 0x80) + { + if(i >= sizeMax || buf[i] == 0x00) return 0; + + num |= (ulong)(buf[i] & 0x7F) << i * 7; + } + + return i; + } + #region IFilter Members /// @@ -215,58 +269,4 @@ public sealed class XZ : IFilter public string ParentFolder => System.IO.Path.GetDirectoryName(BasePath); #endregion - - void GuessSize() - { - DataForkLength = 0; - - // Seek to footer backwards size field - _dataStream.Seek(-8, SeekOrigin.End); - var tmp = new byte[4]; - _dataStream.EnsureRead(tmp, 0, 4); - uint backwardSize = (BitConverter.ToUInt32(tmp, 0) + 1) * 4; - - // Seek to first indexed record - _dataStream.Seek(-12 - (backwardSize - 2), SeekOrigin.End); - - // Skip compressed size - tmp = new byte[backwardSize - 2]; - _dataStream.EnsureRead(tmp, 0, tmp.Length); - ulong number = 0; - int ignore = Decode(tmp, tmp.Length, ref number); - - // Get compressed size - _dataStream.Seek(-12 - (backwardSize - 2 - ignore), SeekOrigin.End); - tmp = new byte[backwardSize - 2 - ignore]; - _dataStream.EnsureRead(tmp, 0, tmp.Length); - Decode(tmp, tmp.Length, ref number); - DataForkLength = (long)number; - - _dataStream.Seek(0, SeekOrigin.Begin); - } - - static int Decode(byte[] buf, int sizeMax, ref ulong num) - { - switch(sizeMax) - { - case 0: - return 0; - case > 9: - sizeMax = 9; - - break; - } - - num = (ulong)(buf[0] & 0x7F); - var i = 0; - - while((buf[i++] & 0x80) == 0x80) - { - if(i >= sizeMax || buf[i] == 0x00) return 0; - - num |= (ulong)(buf[i] & 0x7F) << i * 7; - } - - return i; - } } \ No newline at end of file diff --git a/Aaru.Generators/PluginRegisterGenerator.cs b/Aaru.Generators/PluginRegisterGenerator.cs index 19294280a..429aedca0 100644 --- a/Aaru.Generators/PluginRegisterGenerator.cs +++ b/Aaru.Generators/PluginRegisterGenerator.cs @@ -367,49 +367,43 @@ public class PluginRegisterGenerator : ISourceGenerator ?.Identifier.ValueText == "IArchive") == true) - { - if(!Archives.Contains(plugin.Identifier.Text)) Archives.Add(plugin.Identifier.Text); - } + if(!Archives.Contains(plugin.Identifier.Text)) + Archives.Add(plugin.Identifier.Text); if(plugin.BaseList?.Types.Any(static t => ((t as SimpleBaseTypeSyntax)?.Type as IdentifierNameSyntax) ?.Identifier.ValueText == "IChecksum") == true) - { - if(!Checksums.Contains(plugin.Identifier.Text)) Checksums.Add(plugin.Identifier.Text); - } + if(!Checksums.Contains(plugin.Identifier.Text)) + Checksums.Add(plugin.Identifier.Text); if(plugin.BaseList?.Types.Any(static t => ((t as SimpleBaseTypeSyntax)?.Type as IdentifierNameSyntax) ?.Identifier.ValueText == "IFilesystem") == true) - { - if(!FileSystems.Contains(plugin.Identifier.Text)) FileSystems.Add(plugin.Identifier.Text); - } + if(!FileSystems.Contains(plugin.Identifier.Text)) + FileSystems.Add(plugin.Identifier.Text); if(plugin.BaseList?.Types.Any(static t => ((t as SimpleBaseTypeSyntax)?.Type as IdentifierNameSyntax) ?.Identifier.ValueText == "IFilter") == true) - { - if(!Filters.Contains(plugin.Identifier.Text)) Filters.Add(plugin.Identifier.Text); - } + if(!Filters.Contains(plugin.Identifier.Text)) + Filters.Add(plugin.Identifier.Text); if(plugin.BaseList?.Types.Any(static t => ((t as SimpleBaseTypeSyntax)?.Type as IdentifierNameSyntax) ?.Identifier.ValueText == "IFloppyImage") == true) - { - if(!FloppyImagePlugins.Contains(plugin.Identifier.Text)) FloppyImagePlugins.Add(plugin.Identifier.Text); - } + if(!FloppyImagePlugins.Contains(plugin.Identifier.Text)) + FloppyImagePlugins.Add(plugin.Identifier.Text); if(plugin.BaseList?.Types.Any(static t => ((t as SimpleBaseTypeSyntax)?.Type as IdentifierNameSyntax) ?.Identifier.ValueText == "IFluxImage") == true) - { - if(!FluxImagePlugins.Contains(plugin.Identifier.Text)) FluxImagePlugins.Add(plugin.Identifier.Text); - } + if(!FluxImagePlugins.Contains(plugin.Identifier.Text)) + FluxImagePlugins.Add(plugin.Identifier.Text); if(plugin.BaseList?.Types.Any(static t => @@ -420,17 +414,15 @@ public class PluginRegisterGenerator : ISourceGenerator or "ITapeImage" or "IFluxImage") == true) - { - if(!MediaImagePlugins.Contains(plugin.Identifier.Text)) MediaImagePlugins.Add(plugin.Identifier.Text); - } + if(!MediaImagePlugins.Contains(plugin.Identifier.Text)) + MediaImagePlugins.Add(plugin.Identifier.Text); if(plugin.BaseList?.Types.Any(static t => ((t as SimpleBaseTypeSyntax)?.Type as IdentifierNameSyntax) ?.Identifier.ValueText == "IPartition") == true) - { - if(!PartitionPlugins.Contains(plugin.Identifier.Text)) PartitionPlugins.Add(plugin.Identifier.Text); - } + if(!PartitionPlugins.Contains(plugin.Identifier.Text)) + PartitionPlugins.Add(plugin.Identifier.Text); if(plugin.BaseList?.Types.Any(static t => ((t as SimpleBaseTypeSyntax)?.Type as IdentifierNameSyntax)?.Identifier diff --git a/Aaru.Gui/Controls/HexViewPanel.cs b/Aaru.Gui/Controls/HexViewPanel.cs index bcbbf21e5..6200bb973 100644 --- a/Aaru.Gui/Controls/HexViewPanel.cs +++ b/Aaru.Gui/Controls/HexViewPanel.cs @@ -329,8 +329,9 @@ public class HexViewPanel : UserControl foreach(ColorRange range in ColorRanges) { for(int i = range.Start; i <= range.End && i < _data.Length; i++) - if(!colorLookup.ContainsKey(i)) - colorLookup[i] = range.Color; + { + if(!colorLookup.ContainsKey(i)) colorLookup[i] = range.Color; + } } } diff --git a/Aaru.Gui/Models/SubdirectoryModel.cs b/Aaru.Gui/Models/SubdirectoryModel.cs index e1a3582f5..26550aac2 100644 --- a/Aaru.Gui/Models/SubdirectoryModel.cs +++ b/Aaru.Gui/Models/SubdirectoryModel.cs @@ -32,7 +32,6 @@ using System.Collections.ObjectModel; using Aaru.CommonTypes.Interfaces; -using Avalonia.Media; using Avalonia.Media.Imaging; namespace Aaru.Gui.Models; diff --git a/Aaru.Gui/ViewModels/Panels/ImageInfoViewModel.cs b/Aaru.Gui/ViewModels/Panels/ImageInfoViewModel.cs index 321d5d023..66613d7df 100644 --- a/Aaru.Gui/ViewModels/Panels/ImageInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Panels/ImageInfoViewModel.cs @@ -241,8 +241,9 @@ public sealed class ImageInfoViewModel : ViewModelBase } if(imageFormat.Info.ReadableMediaTags is { Count: > 0 }) - foreach(MediaTagType tag in imageFormat.Info.ReadableMediaTags.Order()) - MediaTagsList.Add(tag.Humanize()); + { + foreach(MediaTagType tag in imageFormat.Info.ReadableMediaTags.Order()) MediaTagsList.Add(tag.Humanize()); + } if(imageFormat.Info.ReadableSectorTags is { Count: > 0 }) { @@ -761,9 +762,8 @@ public sealed class ImageInfoViewModel : ViewModelBase try { if(opticalMediaImage.Sessions is { Count: > 0 }) - { - foreach(Session session in opticalMediaImage.Sessions) Sessions.Add(session); - } + foreach(Session session in opticalMediaImage.Sessions) + Sessions.Add(session); } catch(Exception ex) { @@ -773,9 +773,8 @@ public sealed class ImageInfoViewModel : ViewModelBase try { if(opticalMediaImage.Tracks is { Count: > 0 }) - { - foreach(Track track in opticalMediaImage.Tracks) Tracks.Add(track); - } + foreach(Track track in opticalMediaImage.Tracks) + Tracks.Add(track); } catch(Exception ex) { diff --git a/Aaru.Gui/ViewModels/Tabs/DvdWritableInfoViewModel.cs b/Aaru.Gui/ViewModels/Tabs/DvdWritableInfoViewModel.cs index 15434243d..9c21ac415 100644 --- a/Aaru.Gui/ViewModels/Tabs/DvdWritableInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Tabs/DvdWritableInfoViewModel.cs @@ -31,7 +31,6 @@ // ****************************************************************************/ using System; -using System.Collections.Generic; using System.IO; using System.Threading.Tasks; using System.Windows.Input; diff --git a/Aaru.Gui/ViewModels/Windows/MhddLogViewModel.cs b/Aaru.Gui/ViewModels/Windows/MhddLogViewModel.cs index cdefbb2eb..a8b7d9a20 100644 --- a/Aaru.Gui/ViewModels/Windows/MhddLogViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/MhddLogViewModel.cs @@ -137,15 +137,19 @@ public partial class MhddLogViewModel : ViewModelBase Match sectorSizeMatch = SectorSizeRegex().Match(header); if(sectorSizeMatch.Success) + { SectorSize = string.Format(UI._0_bytes_markup, ParseNumberWithSeparator(sectorSizeMatch.Groups[1].Value)); + } // Parse SCAN BLOCK SIZE field Match scanBlockMatch = ScanBlockSizeRegex().Match(header); if(scanBlockMatch.Success) + { ScanBlockSize = string.Format(UI._0_sectors_markup, ParseNumberWithSeparator(scanBlockMatch.Groups[1].Value)); + } } catch(Exception ex) { diff --git a/Aaru.Gui/Views/Panels/ImageInfo.xaml b/Aaru.Gui/Views/Panels/ImageInfo.xaml index cb40e0bcd..c6b4b8000 100644 --- a/Aaru.Gui/Views/Panels/ImageInfo.xaml +++ b/Aaru.Gui/Views/Panels/ImageInfo.xaml @@ -46,9 +46,12 @@ - - + - - - - + + + - + + HorizontalAlignment="Stretch" + Margin="8"> @@ -259,7 +268,8 @@ IsVisible="{Binding !!Tracks.Count, Mode=OneWay}" IsReadOnly="True" VerticalAlignment="Stretch" - HorizontalAlignment="Stretch" Margin="8"> + HorizontalAlignment="Stretch" + Margin="8"> @@ -398,7 +408,8 @@ + IsReadOnly="True" + Margin="8"> @@ -551,59 +562,71 @@ - + - + - + - + - + - + - + - + - + - + diff --git a/Aaru.Gui/Views/Windows/ImageSidecar.xaml b/Aaru.Gui/Views/Windows/ImageSidecar.xaml index 3ec61db41..807cc26b4 100644 --- a/Aaru.Gui/Views/Windows/ImageSidecar.xaml +++ b/Aaru.Gui/Views/Windows/ImageSidecar.xaml @@ -51,36 +51,60 @@ - - - - + + + - - - + - - - + + - - - + + - +