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);
|
||||
|
||||
@@ -80,17 +52,17 @@ namespace DiscImageChef.Interop
|
||||
static extern int OSX_sysctlbyname(string name, IntPtr oldp, IntPtr oldlenp, IntPtr newp, uint newlen);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the real platform ID, not the incomplete .NET framework one
|
||||
/// Gets the real platform ID, not the incomplete .NET framework one
|
||||
/// </summary>
|
||||
/// <returns>Platform ID</returns>
|
||||
/// <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;
|
||||
}
|
||||
@@ -174,7 +147,7 @@ namespace DiscImageChef.Interop
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the underlying runtime runs in 64-bit mode
|
||||
/// Checks if the underlying runtime runs in 64-bit mode
|
||||
/// </summary>
|
||||
public static bool Is64Bit()
|
||||
{
|
||||
@@ -182,7 +155,7 @@ namespace DiscImageChef.Interop
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the underlying runtime runs in 32-bit mode
|
||||
/// Checks if the underlying runtime runs in 32-bit mode
|
||||
/// </summary>
|
||||
public static bool Is32Bit()
|
||||
{
|
||||
@@ -190,7 +163,7 @@ namespace DiscImageChef.Interop
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a string for the current operating system REAL version (handles Darwin 1.4 and Windows 10 falsifying)
|
||||
/// Gets a string for the current operating system REAL version (handles Darwin 1.4 and Windows 10 falsifying)
|
||||
/// </summary>
|
||||
/// <returns>Current operating system version</returns>
|
||||
public static string GetVersion()
|
||||
@@ -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";
|
||||
}
|
||||
@@ -223,7 +197,7 @@ namespace DiscImageChef.Interop
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// From a platform ID and version returns a human-readable version
|
||||
/// From a platform ID and version returns a human-readable version
|
||||
/// </summary>
|
||||
/// <param name="id">Platform ID</param>
|
||||
/// <param name="version">Version number</param>
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,152 +39,152 @@
|
||||
namespace DiscImageChef.Interop
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains an arbitrary list of OSes, even if .NET does not run on them
|
||||
/// Contains an arbitrary list of OSes, even if .NET does not run on them
|
||||
/// </summary>
|
||||
public enum PlatformID
|
||||
{
|
||||
/// <summary>
|
||||
/// Win32s
|
||||
/// Win32s
|
||||
/// </summary>
|
||||
Win32S = 0,
|
||||
/// <summary>
|
||||
/// Win32 (Windows 9x)
|
||||
/// Win32 (Windows 9x)
|
||||
/// </summary>
|
||||
Win32Windows = 1,
|
||||
/// <summary>
|
||||
/// Windows NT
|
||||
/// Windows NT
|
||||
/// </summary>
|
||||
Win32NT = 2,
|
||||
/// <summary>
|
||||
/// Windows Mobile
|
||||
/// Windows Mobile
|
||||
/// </summary>
|
||||
WinCE = 3,
|
||||
/// <summary>
|
||||
/// UNIX (do not use, too generic)
|
||||
/// UNIX (do not use, too generic)
|
||||
/// </summary>
|
||||
Unix = 4,
|
||||
/// <summary>
|
||||
/// Xbox 360
|
||||
/// Xbox 360
|
||||
/// </summary>
|
||||
Xbox = 5,
|
||||
/// <summary>
|
||||
/// OS X
|
||||
/// OS X
|
||||
/// </summary>
|
||||
MacOSX = 6,
|
||||
/// <summary>
|
||||
/// iOS is not OS X
|
||||
/// iOS is not OS X
|
||||
/// </summary>
|
||||
iOS = 7,
|
||||
/// <summary>
|
||||
/// Linux
|
||||
/// Linux
|
||||
/// </summary>
|
||||
Linux = 8,
|
||||
/// <summary>
|
||||
/// Sun Solaris
|
||||
/// Sun Solaris
|
||||
/// </summary>
|
||||
Solaris = 9,
|
||||
/// <summary>
|
||||
/// NetBSD
|
||||
/// NetBSD
|
||||
/// </summary>
|
||||
NetBSD = 10,
|
||||
/// <summary>
|
||||
/// OpenBSD
|
||||
/// OpenBSD
|
||||
/// </summary>
|
||||
OpenBSD = 11,
|
||||
/// <summary>
|
||||
/// FreeBSD
|
||||
/// FreeBSD
|
||||
/// </summary>
|
||||
FreeBSD = 12,
|
||||
/// <summary>
|
||||
/// DragonFly BSD
|
||||
/// DragonFly BSD
|
||||
/// </summary>
|
||||
DragonFly = 13,
|
||||
/// <summary>
|
||||
/// Nintendo Wii
|
||||
/// Nintendo Wii
|
||||
/// </summary>
|
||||
Wii = 14,
|
||||
/// <summary>
|
||||
/// Nintendo Wii U
|
||||
/// Nintendo Wii U
|
||||
/// </summary>
|
||||
WiiU = 15,
|
||||
/// <summary>
|
||||
/// Sony PlayStation 3
|
||||
/// Sony PlayStation 3
|
||||
/// </summary>
|
||||
PlayStation3 = 16,
|
||||
/// <summary>
|
||||
/// Sony Playstation 4
|
||||
/// Sony Playstation 4
|
||||
/// </summary>
|
||||
PlayStation4 = 17,
|
||||
/// <summary>
|
||||
/// Google Android
|
||||
/// Google Android
|
||||
/// </summary>
|
||||
Android = 18,
|
||||
/// <summary>
|
||||
/// Samsung Tizen
|
||||
/// Samsung Tizen
|
||||
/// </summary>
|
||||
Tizen = 19,
|
||||
/// <summary>
|
||||
/// Windows Phone
|
||||
/// Windows Phone
|
||||
/// </summary>
|
||||
WindowsPhone = 20,
|
||||
/// <summary>
|
||||
/// GNU/Hurd
|
||||
/// GNU/Hurd
|
||||
/// </summary>
|
||||
Hurd = 21,
|
||||
/// <summary>
|
||||
/// Haiku
|
||||
/// Haiku
|
||||
/// </summary>
|
||||
Haiku = 22,
|
||||
/// <summary>
|
||||
/// HP-UX
|
||||
/// HP-UX
|
||||
/// </summary>
|
||||
HPUX = 23,
|
||||
/// <summary>
|
||||
/// AIX
|
||||
/// AIX
|
||||
/// </summary>
|
||||
AIX = 24,
|
||||
/// <summary>
|
||||
/// OS/400
|
||||
/// OS/400
|
||||
/// </summary>
|
||||
OS400 = 25,
|
||||
/// <summary>
|
||||
/// IRIX
|
||||
/// IRIX
|
||||
/// </summary>
|
||||
IRIX = 26,
|
||||
/// <summary>
|
||||
/// Minix
|
||||
/// Minix
|
||||
/// </summary>
|
||||
Minix = 27,
|
||||
/// <summary>
|
||||
/// NonStop
|
||||
/// NonStop
|
||||
/// </summary>
|
||||
NonStop = 28,
|
||||
/// <summary>
|
||||
/// QNX
|
||||
/// QNX
|
||||
/// </summary>
|
||||
QNX = 29,
|
||||
/// <summary>
|
||||
/// SINIX
|
||||
/// SINIX
|
||||
/// </summary>
|
||||
SINIX = 30,
|
||||
/// <summary>
|
||||
/// Tru64 UNIX
|
||||
/// Tru64 UNIX
|
||||
/// </summary>
|
||||
Tru64 = 31,
|
||||
/// <summary>
|
||||
/// Ultrix
|
||||
/// Ultrix
|
||||
/// </summary>
|
||||
Ultrix = 32,
|
||||
/// <summary>
|
||||
/// SCO OpenServer / SCO UNIX
|
||||
/// SCO OpenServer / SCO UNIX
|
||||
/// </summary>
|
||||
OpenServer = 33,
|
||||
/// <summary>
|
||||
/// SCO UnixWare
|
||||
/// SCO UnixWare
|
||||
/// </summary>
|
||||
UnixWare = 34,
|
||||
/// <summary>
|
||||
/// IBM z/OS
|
||||
/// IBM z/OS
|
||||
/// </summary>
|
||||
zOS = 35,
|
||||
Unknown = -1
|
||||
|
||||
@@ -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