diff options
| author | TSR Berry <20988865+TSRBerry@users.noreply.github.com> | 2023-04-08 01:22:00 +0200 |
|---|---|---|
| committer | Mary <thog@protonmail.com> | 2023-04-27 23:51:14 +0200 |
| commit | cee712105850ac3385cd0091a923438167433f9f (patch) | |
| tree | 4a5274b21d8b7f938c0d0ce18736d3f2993b11b1 /Ryujinx.Common/SystemInfo/LinuxSystemInfo.cs | |
| parent | cd124bda587ef09668a971fa1cac1c3f0cfc9f21 (diff) | |
Move solution and projects to src
Diffstat (limited to 'Ryujinx.Common/SystemInfo/LinuxSystemInfo.cs')
| -rw-r--r-- | Ryujinx.Common/SystemInfo/LinuxSystemInfo.cs | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/Ryujinx.Common/SystemInfo/LinuxSystemInfo.cs b/Ryujinx.Common/SystemInfo/LinuxSystemInfo.cs deleted file mode 100644 index b0c15e49..00000000 --- a/Ryujinx.Common/SystemInfo/LinuxSystemInfo.cs +++ /dev/null @@ -1,80 +0,0 @@ -using Ryujinx.Common.Logging; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Runtime.Versioning; - -namespace Ryujinx.Common.SystemInfo -{ - [SupportedOSPlatform("linux")] - class LinuxSystemInfo : SystemInfo - { - internal LinuxSystemInfo() - { - string cpuName = GetCpuidCpuName(); - - if (cpuName == null) - { - var cpuDict = new Dictionary<string, string>(StringComparer.Ordinal) - { - ["model name"] = null, - ["Processor"] = null, - ["Hardware"] = null - }; - - ParseKeyValues("/proc/cpuinfo", cpuDict); - - cpuName = cpuDict["model name"] ?? cpuDict["Processor"] ?? cpuDict["Hardware"] ?? "Unknown"; - } - - var memDict = new Dictionary<string, string>(StringComparer.Ordinal) - { - ["MemTotal"] = null, - ["MemAvailable"] = null - }; - - ParseKeyValues("/proc/meminfo", memDict); - - // Entries are in KiB - ulong.TryParse(memDict["MemTotal"]?.Split(' ')[0], NumberStyles.Integer, CultureInfo.InvariantCulture, out ulong totalKiB); - ulong.TryParse(memDict["MemAvailable"]?.Split(' ')[0], NumberStyles.Integer, CultureInfo.InvariantCulture, out ulong availableKiB); - - CpuName = $"{cpuName} ; {LogicalCoreCount} logical"; - RamTotal = totalKiB * 1024; - RamAvailable = availableKiB * 1024; - } - - private static void ParseKeyValues(string filePath, Dictionary<string, string> itemDict) - { - if (!File.Exists(filePath)) - { - Logger.Error?.Print(LogClass.Application, $"File \"{filePath}\" not found"); - - return; - } - - int count = itemDict.Count; - - using (StreamReader file = new StreamReader(filePath)) - { - string line; - while ((line = file.ReadLine()) != null) - { - string[] kvPair = line.Split(':', 2, StringSplitOptions.TrimEntries); - - if (kvPair.Length < 2) continue; - - string key = kvPair[0]; - - if (itemDict.TryGetValue(key, out string value) && value == null) - { - itemDict[key] = kvPair[1]; - - if (--count <= 0) break; - } - } - } - } - } -}
\ No newline at end of file |
