diff options
author | Daniel Wilhelm <shieldwed@outlook.com> | 2020-03-20 22:34:51 +0000 |
---|---|---|
committer | Daniel Wilhelm <shieldwed@outlook.com> | 2020-03-20 22:34:51 +0000 |
commit | 543ddcd795ba2fa44676b59135a745f51f28a8da (patch) | |
tree | 5c378aa54f4bb65c081cf9a92530d8af1f1f53dd /zen/system.cpp | |
parent | Merge branch '10.20' into 'master' (diff) | |
parent | add upstream 10.21 (diff) | |
download | FreeFileSync-543ddcd795ba2fa44676b59135a745f51f28a8da.tar.gz FreeFileSync-543ddcd795ba2fa44676b59135a745f51f28a8da.tar.bz2 FreeFileSync-543ddcd795ba2fa44676b59135a745f51f28a8da.zip |
Merge branch '10.21' into 'master'10.21
add upstream 10.21
See merge request opensource-tracking/FreeFileSync!18
Diffstat (limited to 'zen/system.cpp')
-rw-r--r-- | zen/system.cpp | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/zen/system.cpp b/zen/system.cpp index 5945484f..9401b94f 100644 --- a/zen/system.cpp +++ b/zen/system.cpp @@ -44,6 +44,7 @@ namespace ComputerModel zen::getComputerModel() //throw FileError { + ComputerModel cm; try { auto tryGetInfo = [](const Zstring& filePath) @@ -57,9 +58,33 @@ ComputerModel zen::getComputerModel() //throw FileError } catch (const FileError& e) { throw SysError(e.toString()); } //errors should be further enriched by context info => SysError }; - return { tryGetInfo("/sys/devices/virtual/dmi/id/product_name"), //throw SysError - tryGetInfo("/sys/devices/virtual/dmi/id/sys_vendor") }; // + cm.model = tryGetInfo("/sys/devices/virtual/dmi/id/product_name"); //throw SysError + cm.vendor = tryGetInfo("/sys/devices/virtual/dmi/id/sys_vendor"); // + + //clean up: + for (const char* dummyModel : + { + "To Be Filled By O.E.M.", "Default string", "empty", "O.E.M", "OEM", "NA", + "System Product Name", "Please change product name", "INVALID", + }) + if (equalAsciiNoCase(cm.model, dummyModel)) + { + cm.model.clear(); + break; + } + + for (const char* dummyVendor : + { + "To Be Filled By O.E.M.", "Default string", "empty", "O.E.M", "OEM", "NA", + "System manufacturer", "OEM Manufacturer", + }) + if (equalAsciiNoCase(cm.vendor, dummyVendor)) + { + cm.vendor.clear(); + break; + } + return cm; } catch (const SysError& e) { throw FileError(_("Cannot get process information."), e.toString()); } } @@ -73,7 +98,7 @@ std::wstring zen::getOsDescription() //throw FileError { const std::string osName = trimCpy(getCommandOutput("lsb_release --id -s" )); //throw SysError const std::string osVersion = trimCpy(getCommandOutput("lsb_release --release -s")); // - return utfTo<std::wstring>(osName + " " + osVersion); //e.g. "CentOS 7.7.1908" + return utfTo<std::wstring>(osName + ' ' + osVersion); //e.g. "CentOS 7.7.1908" } catch (const SysError& e) { throw FileError(_("Cannot get process information."), e.toString()); } |