mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
More pattern matching.
This commit is contained in:
@@ -90,8 +90,7 @@ public sealed partial class DeviceReport
|
|||||||
|
|
||||||
Features.SeparatedFeatures ftr = Features.Separate(buffer);
|
Features.SeparatedFeatures ftr = Features.Separate(buffer);
|
||||||
|
|
||||||
if(ftr.Descriptors == null ||
|
if(ftr.Descriptors is not { Length: > 0 })
|
||||||
ftr.Descriptors.Length <= 0)
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var report = new MmcFeatures
|
var report = new MmcFeatures
|
||||||
|
|||||||
@@ -113,8 +113,7 @@ public sealed partial class DeviceReport
|
|||||||
|
|
||||||
byte[] evpdPages = EVPD.DecodePage00(buffer);
|
byte[] evpdPages = EVPD.DecodePage00(buffer);
|
||||||
|
|
||||||
if(evpdPages == null ||
|
if(evpdPages is not { Length: > 0 })
|
||||||
evpdPages.Length <= 0)
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
List<ScsiPage> evpds = new();
|
List<ScsiPage> evpds = new();
|
||||||
|
|||||||
@@ -1196,8 +1196,7 @@ public static class Statistics
|
|||||||
if(string.IsNullOrWhiteSpace(command))
|
if(string.IsNullOrWhiteSpace(command))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(Settings.Current.Stats == null ||
|
if(Settings.Current.Stats is not { DeviceStats: true })
|
||||||
!Settings.Current.Stats.DeviceStats)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
using var ctx = AaruContext.Create(Settings.LocalDbPath);
|
using var ctx = AaruContext.Create(Settings.LocalDbPath);
|
||||||
@@ -1227,8 +1226,7 @@ public static class Statistics
|
|||||||
if(string.IsNullOrWhiteSpace(filesystem))
|
if(string.IsNullOrWhiteSpace(filesystem))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(Settings.Current.Stats == null ||
|
if(Settings.Current.Stats is not { FilesystemStats: true })
|
||||||
!Settings.Current.Stats.FilesystemStats)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
using var ctx = AaruContext.Create(Settings.LocalDbPath);
|
using var ctx = AaruContext.Create(Settings.LocalDbPath);
|
||||||
@@ -1258,8 +1256,7 @@ public static class Statistics
|
|||||||
if(string.IsNullOrWhiteSpace(partition))
|
if(string.IsNullOrWhiteSpace(partition))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(Settings.Current.Stats == null ||
|
if(Settings.Current.Stats is not { PartitionStats: true })
|
||||||
!Settings.Current.Stats.PartitionStats)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
using var ctx = AaruContext.Create(Settings.LocalDbPath);
|
using var ctx = AaruContext.Create(Settings.LocalDbPath);
|
||||||
@@ -1289,8 +1286,7 @@ public static class Statistics
|
|||||||
if(string.IsNullOrWhiteSpace(filter))
|
if(string.IsNullOrWhiteSpace(filter))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(Settings.Current.Stats == null ||
|
if(Settings.Current.Stats is not { FilterStats: true })
|
||||||
!Settings.Current.Stats.FilterStats)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
using var ctx = AaruContext.Create(Settings.LocalDbPath);
|
using var ctx = AaruContext.Create(Settings.LocalDbPath);
|
||||||
@@ -1320,8 +1316,7 @@ public static class Statistics
|
|||||||
if(string.IsNullOrWhiteSpace(format))
|
if(string.IsNullOrWhiteSpace(format))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(Settings.Current.Stats == null ||
|
if(Settings.Current.Stats is not { MediaImageStats: true })
|
||||||
!Settings.Current.Stats.MediaImageStats)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
using var ctx = AaruContext.Create(Settings.LocalDbPath);
|
using var ctx = AaruContext.Create(Settings.LocalDbPath);
|
||||||
@@ -1348,8 +1343,7 @@ public static class Statistics
|
|||||||
/// <param name="dev">Device</param>
|
/// <param name="dev">Device</param>
|
||||||
public static void AddDevice(Device dev)
|
public static void AddDevice(Device dev)
|
||||||
{
|
{
|
||||||
if(Settings.Current.Stats == null ||
|
if(Settings.Current.Stats is not { DeviceStats: true })
|
||||||
!Settings.Current.Stats.DeviceStats)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string deviceBus;
|
string deviceBus;
|
||||||
@@ -1392,8 +1386,7 @@ public static class Statistics
|
|||||||
/// <param name="real">Set if media was found on a real device, otherwise found on a media image</param>
|
/// <param name="real">Set if media was found on a real device, otherwise found on a media image</param>
|
||||||
public static void AddMedia(MediaType type, bool real)
|
public static void AddMedia(MediaType type, bool real)
|
||||||
{
|
{
|
||||||
if(Settings.Current.Stats == null ||
|
if(Settings.Current.Stats is not { MediaStats: true })
|
||||||
!Settings.Current.Stats.MediaStats)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
using var ctx = AaruContext.Create(Settings.LocalDbPath);
|
using var ctx = AaruContext.Create(Settings.LocalDbPath);
|
||||||
@@ -1421,8 +1414,7 @@ public static class Statistics
|
|||||||
public static void AddRemote(string serverApplication, string serverVersion, string serverOperatingSystem,
|
public static void AddRemote(string serverApplication, string serverVersion, string serverOperatingSystem,
|
||||||
string serverOperatingSystemVersion, string serverArchitecture)
|
string serverOperatingSystemVersion, string serverArchitecture)
|
||||||
{
|
{
|
||||||
if(Settings.Current.Stats == null ||
|
if(Settings.Current.Stats is not { MediaStats: true })
|
||||||
!Settings.Current.Stats.MediaStats)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
using var ctx = AaruContext.Create(Settings.LocalDbPath);
|
using var ctx = AaruContext.Create(Settings.LocalDbPath);
|
||||||
|
|||||||
Submodule Aaru.Decoders updated: e6db6032f3...a02220902c
@@ -77,8 +77,7 @@ public partial class Device
|
|||||||
if(dev is null)
|
if(dev is null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if(dev.Type == DeviceType.SCSI ||
|
if(dev.Type is DeviceType.SCSI or DeviceType.ATAPI)
|
||||||
dev.Type == DeviceType.ATAPI)
|
|
||||||
{
|
{
|
||||||
dev.ScsiInquiry(out byte[] inqBuf, out _);
|
dev.ScsiInquiry(out byte[] inqBuf, out _);
|
||||||
|
|
||||||
|
|||||||
@@ -132,7 +132,6 @@ public sealed partial class Device : Devices.Device
|
|||||||
dev.Type = DeviceType.Unknown;
|
dev.Type = DeviceType.Unknown;
|
||||||
dev.ScsiType = PeripheralDeviceTypes.UnknownDevice;
|
dev.ScsiType = PeripheralDeviceTypes.UnknownDevice;
|
||||||
|
|
||||||
if(dev.Error)
|
|
||||||
if(dev.Error)
|
if(dev.Error)
|
||||||
{
|
{
|
||||||
errno = (ErrorNumber)dev.LastError;
|
errno = (ErrorNumber)dev.LastError;
|
||||||
|
|||||||
@@ -285,8 +285,7 @@ public sealed class RBF : IFilesystem
|
|||||||
|
|
||||||
static uint LSNToUInt32(byte[] lsn)
|
static uint LSNToUInt32(byte[] lsn)
|
||||||
{
|
{
|
||||||
if(lsn == null ||
|
if(lsn is not { Length: 3 })
|
||||||
lsn.Length != 3)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return (uint)((lsn[0] << 16) + (lsn[1] << 8) + lsn[2]);
|
return (uint)((lsn[0] << 16) + (lsn[1] << 8) + lsn[2]);
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ public sealed class ImageInfoViewModel : ViewModelBase
|
|||||||
imageFormat.Info.Heads > 0 &&
|
imageFormat.Info.Heads > 0 &&
|
||||||
imageFormat.Info.SectorsPerTrack > 0 &&
|
imageFormat.Info.SectorsPerTrack > 0 &&
|
||||||
imageFormat.Info.XmlMediaType != XmlMediaType.OpticalDisc &&
|
imageFormat.Info.XmlMediaType != XmlMediaType.OpticalDisc &&
|
||||||
(imageFormat is not ITapeImage tapeImage || !tapeImage.IsTape))
|
imageFormat is not ITapeImage { IsTape: true })
|
||||||
MediaGeometryText =
|
MediaGeometryText =
|
||||||
$"Media geometry: {imageFormat.Info.Cylinders} cylinders, {imageFormat.Info.Heads} heads, {imageFormat.Info.SectorsPerTrack} sectors per track";
|
$"Media geometry: {imageFormat.Info.Cylinders} cylinders, {imageFormat.Info.Heads} heads, {imageFormat.Info.SectorsPerTrack} sectors per track";
|
||||||
|
|
||||||
|
|||||||
@@ -522,9 +522,7 @@ public sealed class MainWindowViewModel : ViewModelBase
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var imageFormat = ImageFormat.Detect(inputFilter) as IMediaImage;
|
if(ImageFormat.Detect(inputFilter) is not IMediaImage imageFormat)
|
||||||
|
|
||||||
if(imageFormat == null)
|
|
||||||
{
|
{
|
||||||
MessageBoxManager.GetMessageBoxStandardWindow("Error", "Image format not identified.", ButtonEnum.Ok,
|
MessageBoxManager.GetMessageBoxStandardWindow("Error", "Image format not identified.", ButtonEnum.Ok,
|
||||||
Icon.Error);
|
Icon.Error);
|
||||||
|
|||||||
Submodule Aaru.Helpers updated: c2878f9a42...368e40d7bd
@@ -1302,9 +1302,7 @@ public sealed partial class BlindWrite5
|
|||||||
|
|
||||||
AaruConsole.VerboseWriteLine("BlindWrite image describes a disc of type {0}", _imageInfo.MediaType);
|
AaruConsole.VerboseWriteLine("BlindWrite image describes a disc of type {0}", _imageInfo.MediaType);
|
||||||
|
|
||||||
if(_header.profile == ProfileNumber.CDR ||
|
if(_header.profile is ProfileNumber.CDR or ProfileNumber.CDRW or ProfileNumber.CDROM)
|
||||||
_header.profile == ProfileNumber.CDRW ||
|
|
||||||
_header.profile == ProfileNumber.CDROM)
|
|
||||||
return ErrorNumber.NoError;
|
return ErrorNumber.NoError;
|
||||||
|
|
||||||
foreach(Track track in Tracks)
|
foreach(Track track in Tracks)
|
||||||
|
|||||||
@@ -1549,9 +1549,8 @@ public sealed partial class CdrWin
|
|||||||
|
|
||||||
var mediaTypeAsInt = (int)_discImage.MediaType;
|
var mediaTypeAsInt = (int)_discImage.MediaType;
|
||||||
|
|
||||||
_isCd = mediaTypeAsInt is >= 10 and <= 39 || mediaTypeAsInt is 112 or 113 ||
|
_isCd = mediaTypeAsInt is >= 10 and <= 39 or 112 or 113 or >= 150 and <= 152 or 154 or 155
|
||||||
mediaTypeAsInt is >= 150 and <= 152 || mediaTypeAsInt is 154 or 155 ||
|
or >= 171 and <= 179 or >= 740 and <= 749;
|
||||||
mediaTypeAsInt is >= 171 and <= 179 || mediaTypeAsInt is >= 740 and <= 749;
|
|
||||||
|
|
||||||
if(currentSession > 1 &&
|
if(currentSession > 1 &&
|
||||||
leadouts.Count == 0 &&
|
leadouts.Count == 0 &&
|
||||||
|
|||||||
@@ -107,9 +107,8 @@ public sealed partial class CdrWin
|
|||||||
|
|
||||||
var mediaTypeAsInt = (int)_discImage.MediaType;
|
var mediaTypeAsInt = (int)_discImage.MediaType;
|
||||||
|
|
||||||
_isCd = mediaTypeAsInt is >= 10 and <= 39 || mediaTypeAsInt is 112 or 113 ||
|
_isCd = mediaTypeAsInt is >= 10 and <= 39 or 112 or 113 or >= 150 and <= 152 or 154 or 155 or >= 171 and <= 179
|
||||||
mediaTypeAsInt is >= 150 and <= 152 || mediaTypeAsInt is 154 or 155 ||
|
or >= 740 and <= 749;
|
||||||
mediaTypeAsInt is >= 171 and <= 179 || mediaTypeAsInt is >= 740 and <= 749;
|
|
||||||
|
|
||||||
if(_isCd)
|
if(_isCd)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -159,10 +159,9 @@ public sealed partial class Ndif
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Handle compressed chunks
|
// TODO: Handle compressed chunks
|
||||||
if(bChnk.type is > CHUNK_TYPE_COPY and < CHUNK_TYPE_KENCODE ||
|
if(bChnk.type is > CHUNK_TYPE_COPY and < CHUNK_TYPE_KENCODE or > CHUNK_TYPE_ADC and < CHUNK_TYPE_STUFFIT
|
||||||
bChnk.type is > CHUNK_TYPE_ADC and < CHUNK_TYPE_STUFFIT ||
|
or > CHUNK_TYPE_STUFFIT and < CHUNK_TYPE_END
|
||||||
bChnk.type is > CHUNK_TYPE_STUFFIT and < CHUNK_TYPE_END ||
|
or 1)
|
||||||
bChnk.type == 1)
|
|
||||||
{
|
{
|
||||||
AaruConsole.ErrorWriteLine($"Unsupported chunk type 0x{bChnk.type:X8} found");
|
AaruConsole.ErrorWriteLine($"Unsupported chunk type 0x{bChnk.type:X8} found");
|
||||||
|
|
||||||
|
|||||||
@@ -414,8 +414,7 @@ public sealed partial class Udif
|
|||||||
return ErrorNumber.NotImplemented;
|
return ErrorNumber.NotImplemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bChnk.type is > CHUNK_TYPE_NOCOPY and < CHUNK_TYPE_COMMNT ||
|
if(bChnk.type is > CHUNK_TYPE_NOCOPY and < CHUNK_TYPE_COMMNT or > CHUNK_TYPE_LZMA and < CHUNK_TYPE_END)
|
||||||
bChnk.type is > CHUNK_TYPE_LZMA and < CHUNK_TYPE_END)
|
|
||||||
{
|
{
|
||||||
AaruConsole.ErrorWriteLine($"Unsupported chunk type 0x{bChnk.type:X8} found");
|
AaruConsole.ErrorWriteLine($"Unsupported chunk type 0x{bChnk.type:X8} found");
|
||||||
|
|
||||||
|
|||||||
@@ -160,9 +160,8 @@ public abstract class ReadOnlyFilesystemTest : FilesystemTest
|
|||||||
|
|
||||||
var filtersList = new FiltersList();
|
var filtersList = new FiltersList();
|
||||||
IFilter inputFilter = filtersList.GetFilter(testFile);
|
IFilter inputFilter = filtersList.GetFilter(testFile);
|
||||||
var image = ImageFormat.Detect(inputFilter) as IMediaImage;
|
|
||||||
|
|
||||||
if(image is null)
|
if(ImageFormat.Detect(inputFilter) is not IMediaImage image)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ErrorNumber opened = image.Open(inputFilter);
|
ErrorNumber opened = image.Open(inputFilter);
|
||||||
|
|||||||
@@ -216,9 +216,7 @@ public abstract class OpticalMediaImageTest : BaseMediaImageTest
|
|||||||
Assert.AreEqual(track.FileSystems[i].VolumeSerial, fs.XmlFsType.VolumeSerial,
|
Assert.AreEqual(track.FileSystems[i].VolumeSerial, fs.XmlFsType.VolumeSerial,
|
||||||
$"Volume serial: {testFile}");
|
$"Volume serial: {testFile}");
|
||||||
|
|
||||||
var rofs = Activator.CreateInstance(plugin.GetType()) as IReadOnlyFilesystem;
|
if(Activator.CreateInstance(plugin.GetType()) is not IReadOnlyFilesystem rofs)
|
||||||
|
|
||||||
if(rofs == null)
|
|
||||||
{
|
{
|
||||||
if(track.FileSystems[i].Contents != null ||
|
if(track.FileSystems[i].Contents != null ||
|
||||||
track.FileSystems[i].ContentsJson != null ||
|
track.FileSystems[i].ContentsJson != null ||
|
||||||
|
|||||||
@@ -413,7 +413,7 @@ sealed class ChecksumCommand : Command
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ITapeImage { IsTape: true, Files: { Count: > 0 } } tapeImage:
|
case ITapeImage { IsTape: true, Files.Count: > 0 } tapeImage:
|
||||||
{
|
{
|
||||||
Checksum trackChecksum = null;
|
Checksum trackChecksum = null;
|
||||||
|
|
||||||
@@ -580,7 +580,7 @@ sealed class ChecksumCommand : Command
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case IByteAddressableImage { Info: { XmlMediaType: XmlMediaType.LinearMedia } } byteAddressableImage:
|
case IByteAddressableImage { Info.XmlMediaType: XmlMediaType.LinearMedia } byteAddressableImage:
|
||||||
{
|
{
|
||||||
mediaChecksum = new Checksum(enabledChecksums);
|
mediaChecksum = new Checksum(enabledChecksums);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user