mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
REFACTOR: Final cleanup of DiscImageChef.Metadata.
This commit is contained in:
@@ -45,34 +45,6 @@ namespace DiscImageChef.Interop
|
||||
{
|
||||
public static class DetectOS
|
||||
{
|
||||
/// <summary>
|
||||
/// POSIX uname structure, size from OSX, big enough to handle extra fields
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
struct utsname
|
||||
{
|
||||
/// <summary>
|
||||
/// System name
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string sysname;
|
||||
/// <summary>
|
||||
/// Node name
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string nodename;
|
||||
/// <summary>
|
||||
/// Release level
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string release;
|
||||
/// <summary>
|
||||
/// Version level
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string version;
|
||||
/// <summary>
|
||||
/// Hardware level
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string machine;
|
||||
}
|
||||
|
||||
[DllImport("libc", SetLastError = true)]
|
||||
static extern int uname(out utsname name);
|
||||
|
||||
@@ -86,11 +58,11 @@ namespace DiscImageChef.Interop
|
||||
/// <exception cref="Exception">Unhandled exception</exception>
|
||||
public static PlatformID GetRealPlatformID()
|
||||
{
|
||||
if((int)Environment.OSVersion.Platform < 4 || (int)Environment.OSVersion.Platform == 5) return (PlatformID)(int)Environment.OSVersion.Platform;
|
||||
if((int)Environment.OSVersion.Platform < 4 || (int)Environment.OSVersion.Platform == 5)
|
||||
return (PlatformID)(int)Environment.OSVersion.Platform;
|
||||
|
||||
int error = uname(out utsname unixname);
|
||||
if(error != 0)
|
||||
throw new Exception($"Unhandled exception calling uname: {Marshal.GetLastWin32Error()}");
|
||||
if(error != 0) throw new Exception($"Unhandled exception calling uname: {Marshal.GetLastWin32Error()}");
|
||||
|
||||
switch(unixname.sysname)
|
||||
{
|
||||
@@ -134,7 +106,8 @@ namespace DiscImageChef.Interop
|
||||
|
||||
if(machine != null && (machine.StartsWith("iPad", StringComparison.Ordinal) ||
|
||||
machine.StartsWith("iPod", StringComparison.Ordinal) ||
|
||||
machine.StartsWith("iPhone", StringComparison.Ordinal))) return PlatformID.iOS;
|
||||
machine.StartsWith("iPhone", StringComparison.Ordinal)))
|
||||
return PlatformID.iOS;
|
||||
|
||||
return PlatformID.MacOSX;
|
||||
}
|
||||
@@ -203,7 +176,8 @@ namespace DiscImageChef.Interop
|
||||
if(Environment.OSVersion.Version.Major != 1)
|
||||
return $"10.{Environment.OSVersion.Version.Major - 4}.{Environment.OSVersion.Version.Minor}";
|
||||
|
||||
switch(Environment.OSVersion.Version.Minor) {
|
||||
switch(Environment.OSVersion.Version.Minor)
|
||||
{
|
||||
case 3: return "10.0";
|
||||
case 4: return "10.1";
|
||||
}
|
||||
@@ -301,5 +275,33 @@ namespace DiscImageChef.Interop
|
||||
default: return id.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// POSIX uname structure, size from OSX, big enough to handle extra fields
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
struct utsname
|
||||
{
|
||||
/// <summary>
|
||||
/// System name
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string sysname;
|
||||
/// <summary>
|
||||
/// Node name
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string nodename;
|
||||
/// <summary>
|
||||
/// Release level
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string release;
|
||||
/// <summary>
|
||||
/// Version level
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string version;
|
||||
/// <summary>
|
||||
/// Hardware level
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string machine;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,11 +31,11 @@
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Xml.Serialization;
|
||||
using DiscImageChef.Decoders.ATA;
|
||||
using DiscImageChef.Decoders.SCSI;
|
||||
using DiscImageChef.Decoders.SCSI.MMC;
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
|
||||
|
||||
@@ -57,7 +57,8 @@ namespace DiscImageChef.Metadata
|
||||
{
|
||||
if(extents == null) return null;
|
||||
|
||||
List<Tuple<ulong, ulong>> tuples = extents.Select(extent => new Tuple<ulong, ulong>(extent.Start, extent.End)).ToList();
|
||||
List<Tuple<ulong, ulong>> tuples =
|
||||
extents.Select(extent => new Tuple<ulong, ulong>(extent.Start, extent.End)).ToList();
|
||||
|
||||
return new ExtentsULong(tuples);
|
||||
}
|
||||
|
||||
@@ -38,11 +38,11 @@ namespace DiscImageChef.Metadata
|
||||
[XmlRoot("DicStats", Namespace = "", IsNullable = false)]
|
||||
public class Stats
|
||||
{
|
||||
public CommandsStats Commands;
|
||||
[XmlArrayItem("OperatingSystem")]
|
||||
public List<OsStats> OperatingSystems { get; set; }
|
||||
[XmlArrayItem("Version")]
|
||||
public List<NameValueStats> Versions { get; set; }
|
||||
public CommandsStats Commands;
|
||||
[XmlArrayItem("Filesystem")]
|
||||
public List<NameValueStats> Filesystems { get; set; }
|
||||
[XmlArrayItem("Scheme")]
|
||||
@@ -74,13 +74,13 @@ namespace DiscImageChef.Metadata
|
||||
public long Entropy;
|
||||
public long ExtractFiles;
|
||||
public long Formats;
|
||||
public long ListDevices;
|
||||
public long ListEncodings;
|
||||
public long Ls;
|
||||
public long MediaInfo;
|
||||
public long MediaScan;
|
||||
public long PrintHex;
|
||||
public long Verify;
|
||||
public long ListDevices;
|
||||
public long ListEncodings;
|
||||
}
|
||||
|
||||
public class VerifiedItems
|
||||
@@ -97,19 +97,19 @@ namespace DiscImageChef.Metadata
|
||||
|
||||
public class ScannedSectors
|
||||
{
|
||||
public long Total;
|
||||
public long Error;
|
||||
public long Correct;
|
||||
public long Error;
|
||||
public long Total;
|
||||
public long Unverifiable;
|
||||
}
|
||||
|
||||
public class TimeStats
|
||||
{
|
||||
public long LessThan3ms;
|
||||
public long LessThan10ms;
|
||||
public long LessThan50ms;
|
||||
public long LessThan150ms;
|
||||
public long LessThan3ms;
|
||||
public long LessThan500ms;
|
||||
public long LessThan50ms;
|
||||
public long MoreThan500ms;
|
||||
}
|
||||
|
||||
@@ -127,12 +127,12 @@ namespace DiscImageChef.Metadata
|
||||
|
||||
public class BenchmarkStats
|
||||
{
|
||||
public double All;
|
||||
[XmlElement("Checksum")] public List<ChecksumStats> Checksum;
|
||||
public double Entropy;
|
||||
public double All;
|
||||
public double Sequential;
|
||||
public long MaxMemory;
|
||||
public long MinMemory;
|
||||
public double Sequential;
|
||||
}
|
||||
|
||||
public class MediaStats
|
||||
@@ -144,12 +144,11 @@ namespace DiscImageChef.Metadata
|
||||
|
||||
public class DeviceStats
|
||||
{
|
||||
[XmlIgnore] public bool ManufacturerSpecified;
|
||||
public string Manufacturer { get; set; }
|
||||
public string Model { get; set; }
|
||||
public string Revision { get; set; }
|
||||
public string Bus { get; set; }
|
||||
|
||||
[XmlIgnore] public bool ManufacturerSpecified;
|
||||
}
|
||||
|
||||
public class NameValueStats
|
||||
|
||||
Reference in New Issue
Block a user