mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Code cleanup.
This commit is contained in:
@@ -46,15 +46,16 @@ namespace DiscImageChef.Devices.Linux
|
||||
/// <returns>List of devices</returns>
|
||||
internal static DeviceInfo[] GetList()
|
||||
{
|
||||
string[] sysdevs = Directory.GetFileSystemEntries(PATH_SYS_DEVBLOCK, "*", SearchOption.TopDirectoryOnly);
|
||||
string[] sysdevs =
|
||||
Directory.GetFileSystemEntries(PATH_SYS_DEVBLOCK, "*", SearchOption.TopDirectoryOnly);
|
||||
DeviceInfo[] devices = new DeviceInfo[sysdevs.Length];
|
||||
bool hasUdev;
|
||||
bool hasUdev;
|
||||
|
||||
IntPtr udev = IntPtr.Zero;
|
||||
|
||||
try
|
||||
{
|
||||
udev = Extern.udev_new();
|
||||
udev = Extern.udev_new();
|
||||
hasUdev = udev != IntPtr.Zero;
|
||||
}
|
||||
catch { hasUdev = false; }
|
||||
@@ -68,7 +69,7 @@ namespace DiscImageChef.Devices.Linux
|
||||
IntPtr udevDev =
|
||||
Extern.udev_device_new_from_subsystem_sysname(udev, "block", Path.GetFileName(sysdevs[i]));
|
||||
devices[i].Vendor = Extern.udev_device_get_property_value(udevDev, "ID_VENDOR");
|
||||
devices[i].Model = Extern.udev_device_get_property_value(udevDev, "ID_MODEL");
|
||||
devices[i].Model = Extern.udev_device_get_property_value(udevDev, "ID_MODEL");
|
||||
if(!string.IsNullOrEmpty(devices[i].Model)) devices[i].Model = devices[i].Model.Replace('_', ' ');
|
||||
devices[i].Serial = Extern.udev_device_get_property_value(udevDev, "ID_SCSI_SERIAL");
|
||||
if(string.IsNullOrEmpty(devices[i].Serial))
|
||||
@@ -79,7 +80,7 @@ namespace DiscImageChef.Devices.Linux
|
||||
StreamReader sr;
|
||||
if(File.Exists(Path.Combine(sysdevs[i], "device/vendor")) && string.IsNullOrEmpty(devices[i].Vendor))
|
||||
{
|
||||
sr = new StreamReader(Path.Combine(sysdevs[i], "device/vendor"), Encoding.ASCII);
|
||||
sr = new StreamReader(Path.Combine(sysdevs[i], "device/vendor"), Encoding.ASCII);
|
||||
devices[i].Vendor = sr.ReadLine()?.Trim();
|
||||
}
|
||||
else if(devices[i].Path.StartsWith("/dev/loop", StringComparison.CurrentCulture))
|
||||
@@ -88,7 +89,7 @@ namespace DiscImageChef.Devices.Linux
|
||||
if(File.Exists(Path.Combine(sysdevs[i], "device/model")) &&
|
||||
(string.IsNullOrEmpty(devices[i].Model) || devices[i].Bus == "ata"))
|
||||
{
|
||||
sr = new StreamReader(Path.Combine(sysdevs[i], "device/model"), Encoding.ASCII);
|
||||
sr = new StreamReader(Path.Combine(sysdevs[i], "device/model"), Encoding.ASCII);
|
||||
devices[i].Model = sr.ReadLine()?.Trim();
|
||||
}
|
||||
else if(devices[i].Path.StartsWith("/dev/loop", StringComparison.CurrentCulture))
|
||||
@@ -96,7 +97,7 @@ namespace DiscImageChef.Devices.Linux
|
||||
|
||||
if(File.Exists(Path.Combine(sysdevs[i], "device/serial")) && string.IsNullOrEmpty(devices[i].Serial))
|
||||
{
|
||||
sr = new StreamReader(Path.Combine(sysdevs[i], "device/serial"), Encoding.ASCII);
|
||||
sr = new StreamReader(Path.Combine(sysdevs[i], "device/serial"), Encoding.ASCII);
|
||||
devices[i].Serial = sr.ReadLine()?.Trim();
|
||||
}
|
||||
|
||||
@@ -107,7 +108,7 @@ namespace DiscImageChef.Devices.Linux
|
||||
if(pieces.Length > 1)
|
||||
{
|
||||
devices[i].Vendor = pieces[0];
|
||||
devices[i].Model = devices[i].Model.Substring(pieces[0].Length + 1);
|
||||
devices[i].Model = devices[i].Model.Substring(pieces[0].Length + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user