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>
|
||||||
<e p="Scanning" t="Include">
|
<e p="Scanning" t="Include">
|
||||||
<e p="ATA.cs" t="Include" />
|
<e p="ATA.cs" t="Include" />
|
||||||
|
<e p="MediaScan.cs" t="Include" />
|
||||||
<e p="NVMe.cs" t="Include" />
|
<e p="NVMe.cs" t="Include" />
|
||||||
<e p="SCSI.cs" t="Include" />
|
<e p="SCSI.cs" t="Include" />
|
||||||
<e p="ScanResults.cs" t="Include" />
|
<e p="ScanResults.cs" t="Include" />
|
||||||
|
|||||||
@@ -35,24 +35,19 @@ using System.Collections.Generic;
|
|||||||
using DiscImageChef.Console;
|
using DiscImageChef.Console;
|
||||||
using DiscImageChef.Core.Logging;
|
using DiscImageChef.Core.Logging;
|
||||||
using DiscImageChef.Decoders.ATA;
|
using DiscImageChef.Decoders.ATA;
|
||||||
using DiscImageChef.Devices;
|
|
||||||
|
|
||||||
namespace DiscImageChef.Core.Devices.Scanning
|
namespace DiscImageChef.Core.Devices.Scanning
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Implements scanning the media from an ATA device
|
/// Implements scanning the media from an ATA device
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class Ata
|
public partial class MediaScan
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Scans the media from an ATA device
|
/// Scans the media from an ATA device
|
||||||
/// </summary>
|
/// </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>
|
/// <returns>Scanning results</returns>
|
||||||
public static ScanResults Scan(string mhddLogPath, string ibgLogPath, string devicePath, Device dev)
|
public ScanResults Ata()
|
||||||
{
|
{
|
||||||
ScanResults results = new ScanResults();
|
ScanResults results = new ScanResults();
|
||||||
bool aborted;
|
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 System;
|
||||||
using DiscImageChef.Devices;
|
|
||||||
|
|
||||||
namespace DiscImageChef.Core.Devices.Scanning
|
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) =>
|
public ScanResults Nvme() => throw new NotImplementedException("NVMe devices not yet supported.");
|
||||||
throw new NotImplementedException("NVMe devices not yet supported.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,9 +45,9 @@ namespace DiscImageChef.Core.Devices.Scanning
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Implements scanning the media from an SCSI device
|
/// Implements scanning the media from an SCSI device
|
||||||
/// </summary>
|
/// </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();
|
ScanResults results = new ScanResults();
|
||||||
bool aborted;
|
bool aborted;
|
||||||
|
|||||||
@@ -36,16 +36,15 @@ using DiscImageChef.CommonTypes.Enums;
|
|||||||
using DiscImageChef.Console;
|
using DiscImageChef.Console;
|
||||||
using DiscImageChef.Core.Logging;
|
using DiscImageChef.Core.Logging;
|
||||||
using DiscImageChef.Decoders.MMC;
|
using DiscImageChef.Decoders.MMC;
|
||||||
using DiscImageChef.Devices;
|
|
||||||
|
|
||||||
namespace DiscImageChef.Core.Devices.Scanning
|
namespace DiscImageChef.Core.Devices.Scanning
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Implements scanning a SecureDigital or MultiMediaCard flash card
|
/// Implements scanning a SecureDigital or MultiMediaCard flash card
|
||||||
/// </summary>
|
/// </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();
|
ScanResults results = new ScanResults();
|
||||||
bool aborted;
|
bool aborted;
|
||||||
@@ -87,6 +86,7 @@ namespace DiscImageChef.Core.Devices.Scanning
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case DeviceType.SecureDigital:
|
case DeviceType.SecureDigital:
|
||||||
{
|
{
|
||||||
sense = dev.ReadCsd(out cmdBuf, out _, TIMEOUT, out _);
|
sense = dev.ReadCsd(out cmdBuf, out _, TIMEOUT, out _);
|
||||||
|
|||||||
@@ -55,6 +55,7 @@
|
|||||||
<Compile Include="Devices\Report\Scsi.cs" />
|
<Compile Include="Devices\Report\Scsi.cs" />
|
||||||
<Compile Include="Devices\Report\MMC.cs" />
|
<Compile Include="Devices\Report\MMC.cs" />
|
||||||
<Compile Include="Devices\Report\SSC.cs" />
|
<Compile Include="Devices\Report\SSC.cs" />
|
||||||
|
<Compile Include="Devices\Scanning\MediaScan.cs" />
|
||||||
<Compile Include="Entropy.cs" />
|
<Compile Include="Entropy.cs" />
|
||||||
<Compile Include="GetPluginBase.cs" />
|
<Compile Include="GetPluginBase.cs" />
|
||||||
<Compile Include="ImageInfo.cs" />
|
<Compile Include="ImageInfo.cs" />
|
||||||
|
|||||||
@@ -32,7 +32,6 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using DiscImageChef.CommonTypes;
|
using DiscImageChef.CommonTypes;
|
||||||
using DiscImageChef.CommonTypes.Enums;
|
|
||||||
using DiscImageChef.Core;
|
using DiscImageChef.Core;
|
||||||
using DiscImageChef.Core.Devices.Scanning;
|
using DiscImageChef.Core.Devices.Scanning;
|
||||||
using DiscImageChef.Core.Media.Info;
|
using DiscImageChef.Core.Media.Info;
|
||||||
@@ -90,26 +89,8 @@ namespace DiscImageChef.Gui.Forms
|
|||||||
|
|
||||||
Statistics.AddDevice(dev);
|
Statistics.AddDevice(dev);
|
||||||
|
|
||||||
ScanResults results;
|
MediaScan scanner = new MediaScan(null, null, devicePath, dev);
|
||||||
|
ScanResults results = scanner.Scan();
|
||||||
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.");
|
|
||||||
}
|
|
||||||
|
|
||||||
lblTotalTime.Text = lblTotalTime.Text =
|
lblTotalTime.Text = lblTotalTime.Text =
|
||||||
$"Took a total of {results.TotalTime} seconds ({results.ProcessingTime} processing commands).";
|
$"Took a total of {results.TotalTime} seconds ({results.ProcessingTime} processing commands).";
|
||||||
|
|||||||
@@ -30,7 +30,6 @@
|
|||||||
// Copyright © 2011-2019 Natalia Portillo
|
// Copyright © 2011-2019 Natalia Portillo
|
||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using DiscImageChef.CommonTypes.Enums;
|
using DiscImageChef.CommonTypes.Enums;
|
||||||
using DiscImageChef.Console;
|
using DiscImageChef.Console;
|
||||||
@@ -112,26 +111,8 @@ namespace DiscImageChef.Commands
|
|||||||
|
|
||||||
Statistics.AddDevice(dev);
|
Statistics.AddDevice(dev);
|
||||||
|
|
||||||
ScanResults results;
|
MediaScan scanner = new MediaScan(mhddLogPath, ibgLogPath, devicePath, dev);
|
||||||
|
ScanResults results = scanner.Scan();
|
||||||
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.");
|
|
||||||
}
|
|
||||||
|
|
||||||
DicConsole.WriteLine("Took a total of {0} seconds ({1} processing commands).", results.TotalTime,
|
DicConsole.WriteLine("Took a total of {0} seconds ({1} processing commands).", results.TotalTime,
|
||||||
results.ProcessingTime);
|
results.ProcessingTime);
|
||||||
|
|||||||
Reference in New Issue
Block a user