Skip to content

Portable Tool for an Ideal Windows Setup

add storage type (CD/SCSI) & re

Greedeks9ecbefd38a4f
diff --git a/.Source/GTweak/Utilities/Configuration/DiskTypeIdentifier.cs b/.Source/GTweak/Utilities/Configuration/DiskTypeIdentifier.cs
index 3aaf385a..2b09501c 100644
--- a/.Source/GTweak/Utilities/Configuration/DiskTypeIdentifier.cs
+++ b/.Source/GTweak/Utilities/Configuration/DiskTypeIdentifier.cs
@@ -123,6 +123,8 @@ namespace GTweak.Utilities.Configuration
STORAGE_BUS_TYPE.BusTypeSd => HardwareData.DiskTypeLabels.SD,
STORAGE_BUS_TYPE.BusTypeVirtual => HardwareData.DiskTypeLabels.VHD,
STORAGE_BUS_TYPE.BusTypeFileBackedVirtual => HardwareData.DiskTypeLabels.VHDX,
+ STORAGE_BUS_TYPE.BusTypeAtapi => HardwareData.DiskTypeLabels.CD,
+ STORAGE_BUS_TYPE.BusTypeScsi => HardwareData.DiskTypeLabels.SCSI,
_ => isSSD ? HardwareData.DiskTypeLabels.SSD : HardwareData.DiskTypeLabels.HDD
};
}
diff --git a/.Source/GTweak/Utilities/Configuration/HardwareData.cs b/.Source/GTweak/Utilities/Configuration/HardwareData.cs
index 691f2511..7c532cf5 100644
--- a/.Source/GTweak/Utilities/Configuration/HardwareData.cs
+++ b/.Source/GTweak/Utilities/Configuration/HardwareData.cs
@@ -64,8 +64,10 @@ namespace GTweak.Utilities.Configuration
internal const string HDD = "(HDD)";
internal const string SSD = "(SSD)";
internal const string NVMe = "(NVMe SSD)";
+ internal const string SCSI = "(SCSI)";
internal const string USB = "(USB-Media)";
internal const string SD = "(SD-Card)";
+ internal const string CD = "(CD/DVD)";
internal const string VHD = "(VHD)";
internal const string VHDX = "(VHDX)";
}
diff --git a/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs b/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs
index 4c3c2cd4..9d322d1f 100644
--- a/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs
+++ b/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs
@@ -399,7 +399,7 @@ namespace GTweak.Utilities.Configuration
string data = new[] { "FriendlyName", "Model", "Description" }.Select(prop => managementObj[prop] as string).FirstOrDefault(info => !string.IsNullOrEmpty(info)) ?? string.Empty;
ushort mediaType = managementObj["MediaType"] != null ? (ushort)managementObj["MediaType"] : (ushort)0;
ushort busType = managementObj["BusType"] != null ? (ushort)managementObj["BusType"] : (ushort)0;
- string storageType = GetStorageType(mediaType, $@"\\.\PhysicalDrive{managementObj["DeviceId"]?.ToString() ?? "0"}", busType, null);
+ string storageType = GetStorageType(mediaType, $@"\\.\PhysicalDrive{managementObj["DeviceId"]?.ToString() ?? "0"}", busType, default);
result.AppendLine($"{SizeCalculationHelper((ulong)managementObj["Size"])} [{data}] {storageType}");
}
@@ -484,28 +484,18 @@ namespace GTweak.Utilities.Configuration
private static string SizeCalculationHelper<T>(T sizeInBytes) where T : struct, IConvertible
{
- double totalSize = Convert.ToDouble(sizeInBytes) / (1024.0 * 1024.0);
+ decimal bytes = Convert.ToDecimal(sizeInBytes);
- if (Convert.ToDouble(sizeInBytes) < 1024)
+ foreach (string unit in new[] { "B", "KB", "MB", "GB", "TB" })
{
- return $"{Convert.ToDouble(sizeInBytes):N0} B";
- }
- else if (totalSize < 1)
- {
- return $"{Math.Round(totalSize * 1024)} KB";
- }
- else if (totalSize < 1024)
- {
- return $"{Math.Round(totalSize)} MB";
- }
- else if (totalSize < 1024 * 1024)
- {
- return $"{Math.Round(totalSize / 1024.0)} GB";
- }
- else
- {
- return $"{Math.Round(totalSize / (1024.0 * 1024.0), 2):G} TB";
+ if (bytes < 1024 || unit == "TB")
+ {
+ return unit == "TB" ? $"{Math.Round(bytes, 2):G} {unit}" : $"{Math.Round(bytes):N0} {unit}";
+ }
+ bytes /= 1024;
}
+
+ return $"{Math.Round(bytes, 2):G} TB";
}
private string GetNetworkAdapters()