From d175e1594ce9802ce362865a0c453ac0ebdd24ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20L=C3=B6nnhager?= Date: Mon, 8 Apr 2024 15:54:36 +0200 Subject: [PATCH] Expose 'marketing' Windows version --- talpid-platform-metadata/src/windows.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/talpid-platform-metadata/src/windows.rs b/talpid-platform-metadata/src/windows.rs index 6dc474227b94..1df2cb0f12f0 100644 --- a/talpid-platform-metadata/src/windows.rs +++ b/talpid-platform-metadata/src/windows.rs @@ -80,20 +80,28 @@ impl WindowsVersion { return "Server".to_owned(); } + match self.release_version() { + (major, 0) => major.to_string(), + (major, minor) => format!("{major}.{minor}"), + } + } + + /// Release version. E.g. `(10, 0)` for Windows 10, or `(8, 0)` for Windows 8.1. + pub fn release_version(&self) -> (u32, u32) { // Check https://en.wikipedia.org/wiki/List_of_Microsoft_Windows_versions#Personal_computer_versions 'Release version' column // for the correct NT versions for specific windows releases. match (self.major_version(), self.minor_version()) { - (6, 1) => "7".into(), - (6, 2) => "8".into(), - (6, 3) => "8.1".into(), + (6, 1) => (7, 0), + (6, 2) => (8, 0), + (6, 3) => (8, 1), (10, 0) => { if self.build_number() < 22000 { - "10".into() + (10, 0) } else { - "11".into() + (11, 0) } } - (major, minor) => format!("{}.{}", major, minor), + (major, minor) => (major, minor), } }