mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Make media scanning non-static.
This commit is contained in:
1
.idea/.idea.DiscImageChef/.idea/contentModel.xml
generated
1
.idea/.idea.DiscImageChef/.idea/contentModel.xml
generated
@@ -240,6 +240,7 @@
|
||||
</e>
|
||||
<e p="Scanning" t="Include">
|
||||
<e p="ATA.cs" t="Include" />
|
||||
<e p="MediaScan.cs" t="Include" />
|
||||
<e p="NVMe.cs" t="Include" />
|
||||
<e p="SCSI.cs" t="Include" />
|
||||
<e p="ScanResults.cs" t="Include" />
|
||||
|
||||
@@ -35,24 +35,19 @@ using System.Collections.Generic;
|
||||
using DiscImageChef.Console;
|
||||
using DiscImageChef.Core.Logging;
|
||||
using DiscImageChef.Decoders.ATA;
|
||||
using DiscImageChef.Devices;
|
||||
|
||||
namespace DiscImageChef.Core.Devices.Scanning
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements scanning the media from an ATA device
|
||||
/// </summary>
|
||||
public static class Ata
|
||||
public partial class MediaScan
|
||||
{
|
||||
/// <summary>
|
||||
/// Scans the media from an ATA device
|
||||
/// </summary>
|
||||
/// <param name="mhddLogPath">Path to a MHDD log file</param>
|
||||
/// <param name="ibgLogPath">Path to a IMGBurn log file</param>
|
||||
/// <param name="devicePath">Device path</param>
|
||||
/// <param name="dev">Device</param>
|
||||
/// <returns>Scanning results</returns>
|
||||
public static ScanResults Scan(string mhddLogPath, string ibgLogPath, string devicePath, Device dev)
|
||||
public ScanResults Ata()
|
||||
{
|
||||
ScanResults results = new ScanResults();
|
||||
bool aborted;
|
||||
|
||||
40
DiscImageChef.Core/Devices/Scanning/MediaScan.cs
Normal file
40
DiscImageChef.Core/Devices/Scanning/MediaScan.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using DiscImageChef.CommonTypes.Enums;
|
||||
using DiscImageChef.Devices;
|
||||
|
||||
namespace DiscImageChef.Core.Devices.Scanning
|
||||
{
|
||||
public partial class MediaScan
|
||||
{
|
||||
readonly Device dev;
|
||||
readonly string devicePath;
|
||||
readonly string ibgLogPath;
|
||||
readonly string mhddLogPath;
|
||||
|
||||
/// <param name="mhddLogPath">Path to a MHDD log file</param>
|
||||
/// <param name="ibgLogPath">Path to a IMGBurn log file</param>
|
||||
/// <param name="devicePath">Device path</param>
|
||||
/// <param name="dev">Device</param>
|
||||
public MediaScan(string mhddLogPath, string ibgLogPath, string devicePath, Device dev)
|
||||
{
|
||||
this.mhddLogPath = mhddLogPath;
|
||||
this.ibgLogPath = ibgLogPath;
|
||||
this.devicePath = devicePath;
|
||||
this.dev = dev;
|
||||
}
|
||||
|
||||
public ScanResults Scan()
|
||||
{
|
||||
switch(dev.Type)
|
||||
{
|
||||
case DeviceType.ATA: return Ata();
|
||||
case DeviceType.MMC:
|
||||
case DeviceType.SecureDigital: return SecureDigital();
|
||||
case DeviceType.NVMe: return Nvme();
|
||||
case DeviceType.ATAPI:
|
||||
case DeviceType.SCSI: return Scsi();
|
||||
default: throw new NotSupportedException("Unknown device type.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,13 +31,11 @@
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using DiscImageChef.Devices;
|
||||
|
||||
namespace DiscImageChef.Core.Devices.Scanning
|
||||
{
|
||||
public static class Nvme
|
||||
public partial class MediaScan
|
||||
{
|
||||
public static ScanResults Scan(string mhddLogPath, string ibgLogPath, string devicePath, Device dev) =>
|
||||
throw new NotImplementedException("NVMe devices not yet supported.");
|
||||
public ScanResults Nvme() => throw new NotImplementedException("NVMe devices not yet supported.");
|
||||
}
|
||||
}
|
||||
@@ -45,9 +45,9 @@ namespace DiscImageChef.Core.Devices.Scanning
|
||||
/// <summary>
|
||||
/// Implements scanning the media from an SCSI device
|
||||
/// </summary>
|
||||
public static class Scsi
|
||||
public partial class MediaScan
|
||||
{
|
||||
public static ScanResults Scan(string mhddLogPath, string ibgLogPath, string devicePath, Device dev)
|
||||
public ScanResults Scsi()
|
||||
{
|
||||
ScanResults results = new ScanResults();
|
||||
bool aborted;
|
||||
|
||||
@@ -36,16 +36,15 @@ using DiscImageChef.CommonTypes.Enums;
|
||||
using DiscImageChef.Console;
|
||||
using DiscImageChef.Core.Logging;
|
||||
using DiscImageChef.Decoders.MMC;
|
||||
using DiscImageChef.Devices;
|
||||
|
||||
namespace DiscImageChef.Core.Devices.Scanning
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements scanning a SecureDigital or MultiMediaCard flash card
|
||||
/// </summary>
|
||||
public static class SecureDigital
|
||||
public partial class MediaScan
|
||||
{
|
||||
public static ScanResults Scan(string mhddLogPath, string ibgLogPath, string devicePath, Device dev)
|
||||
public ScanResults SecureDigital()
|
||||
{
|
||||
ScanResults results = new ScanResults();
|
||||
bool aborted;
|
||||
@@ -87,6 +86,7 @@ namespace DiscImageChef.Core.Devices.Scanning
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case DeviceType.SecureDigital:
|
||||
{
|
||||
sense = dev.ReadCsd(out cmdBuf, out _, TIMEOUT, out _);
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
<Compile Include="Devices\Report\Scsi.cs" />
|
||||
<Compile Include="Devices\Report\MMC.cs" />
|
||||
<Compile Include="Devices\Report\SSC.cs" />
|
||||
<Compile Include="Devices\Scanning\MediaScan.cs" />
|
||||
<Compile Include="Entropy.cs" />
|
||||
<Compile Include="GetPluginBase.cs" />
|
||||
<Compile Include="ImageInfo.cs" />
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
|
||||
using System;
|
||||
using DiscImageChef.CommonTypes;
|
||||
using DiscImageChef.CommonTypes.Enums;
|
||||
using DiscImageChef.Core;
|
||||
using DiscImageChef.Core.Devices.Scanning;
|
||||
using DiscImageChef.Core.Media.Info;
|
||||
@@ -90,26 +89,8 @@ namespace DiscImageChef.Gui.Forms
|
||||
|
||||
Statistics.AddDevice(dev);
|
||||
|
||||
ScanResults results;
|
||||
|
||||
switch(dev.Type)
|
||||
{
|
||||
case DeviceType.ATA:
|
||||
results = Ata.Scan(null, null, devicePath, dev);
|
||||
break;
|
||||
case DeviceType.MMC:
|
||||
case DeviceType.SecureDigital:
|
||||
results = SecureDigital.Scan(null, null, devicePath, dev);
|
||||
break;
|
||||
case DeviceType.NVMe:
|
||||
results = Nvme.Scan(null, null, devicePath, dev);
|
||||
break;
|
||||
case DeviceType.ATAPI:
|
||||
case DeviceType.SCSI:
|
||||
results = Scsi.Scan(null, null, devicePath, dev);
|
||||
break;
|
||||
default: throw new NotSupportedException("Unknown device type.");
|
||||
}
|
||||
MediaScan scanner = new MediaScan(null, null, devicePath, dev);
|
||||
ScanResults results = scanner.Scan();
|
||||
|
||||
lblTotalTime.Text = lblTotalTime.Text =
|
||||
$"Took a total of {results.TotalTime} seconds ({results.ProcessingTime} processing commands).";
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
// Copyright © 2011-2019 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using DiscImageChef.CommonTypes.Enums;
|
||||
using DiscImageChef.Console;
|
||||
@@ -112,26 +111,8 @@ namespace DiscImageChef.Commands
|
||||
|
||||
Statistics.AddDevice(dev);
|
||||
|
||||
ScanResults results;
|
||||
|
||||
switch(dev.Type)
|
||||
{
|
||||
case DeviceType.ATA:
|
||||
results = Ata.Scan(mhddLogPath, ibgLogPath, devicePath, dev);
|
||||
break;
|
||||
case DeviceType.MMC:
|
||||
case DeviceType.SecureDigital:
|
||||
results = SecureDigital.Scan(mhddLogPath, ibgLogPath, devicePath, dev);
|
||||
break;
|
||||
case DeviceType.NVMe:
|
||||
results = Nvme.Scan(mhddLogPath, ibgLogPath, devicePath, dev);
|
||||
break;
|
||||
case DeviceType.ATAPI:
|
||||
case DeviceType.SCSI:
|
||||
results = Scsi.Scan(mhddLogPath, ibgLogPath, devicePath, dev);
|
||||
break;
|
||||
default: throw new NotSupportedException("Unknown device type.");
|
||||
}
|
||||
MediaScan scanner = new MediaScan(mhddLogPath, ibgLogPath, devicePath, dev);
|
||||
ScanResults results = scanner.Scan();
|
||||
|
||||
DicConsole.WriteLine("Took a total of {0} seconds ({1} processing commands).", results.TotalTime,
|
||||
results.ProcessingTime);
|
||||
|
||||
Reference in New Issue
Block a user