mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Add new official .NET guards for OS dependant code.
This commit is contained in:
@@ -36,7 +36,6 @@ using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Aaru.CommonTypes.Interop;
|
||||
using Aaru.Console;
|
||||
using PlatformID = Aaru.CommonTypes.Interop.PlatformID;
|
||||
|
||||
/// <summary>Contains device information</summary>
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
|
||||
@@ -102,13 +101,15 @@ public sealed partial class Device
|
||||
serverArchitecture = null;
|
||||
|
||||
if(aaruRemote is null)
|
||||
switch(DetectOS.GetRealPlatformID())
|
||||
{
|
||||
case PlatformID.Win32NT: return Windows.ListDevices.GetList();
|
||||
case PlatformID.Linux: return Linux.ListDevices.GetList();
|
||||
default:
|
||||
throw new InvalidOperationException($"Platform {DetectOS.GetRealPlatformID()} not yet supported.");
|
||||
}
|
||||
{
|
||||
if(OperatingSystem.IsWindows())
|
||||
return Windows.ListDevices.GetList();
|
||||
|
||||
if(OperatingSystem.IsLinux())
|
||||
return Linux.ListDevices.GetList();
|
||||
|
||||
throw new InvalidOperationException($"Platform {DetectOS.GetRealPlatformID()} not yet supported.");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -36,6 +36,7 @@ using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
[System.Runtime.Versioning.SupportedOSPlatform("linux")]
|
||||
static class ListDevices
|
||||
{
|
||||
const string PATH_SYS_DEVBLOCK = "/sys/block/";
|
||||
|
||||
@@ -42,6 +42,7 @@ using Aaru.Helpers;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
using Marshal = System.Runtime.InteropServices.Marshal;
|
||||
|
||||
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
|
||||
static class ListDevices
|
||||
{
|
||||
/// <summary>Converts a hex dump string to the ASCII string it represents</summary>
|
||||
|
||||
Reference in New Issue
Block a user