From dbdff120bc097c8d9e2fdcc7fb1dff969e0c9586 Mon Sep 17 00:00:00 2001 From: rustdesk Date: Mon, 27 Dec 2021 00:24:57 +0800 Subject: [PATCH] move get_version_number to hbb_common --- libs/hbb_common/src/lib.rs | 8 ++++++++ src/ui.rs | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/libs/hbb_common/src/lib.rs b/libs/hbb_common/src/lib.rs index 91cc076d3..dc0c3e3e2 100644 --- a/libs/hbb_common/src/lib.rs +++ b/libs/hbb_common/src/lib.rs @@ -179,6 +179,14 @@ where Ok(io::BufReader::new(file).lines()) } +pub fn get_version_number(v: &str) -> i64 { + let mut n = 0; + for x in v.split(".") { + n = n * 1000 + x.parse::().unwrap_or(0); + } + n +} + #[cfg(test)] mod tests { use super::*; diff --git a/src/ui.rs b/src/ui.rs index 21694cec0..27d5f1476 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -369,8 +369,8 @@ impl UI { #[cfg(windows)] { let installed_version = crate::platform::windows::get_installed_version(); - let a = crate::common::get_version_number(crate::VERSION); - let b = crate::common::get_version_number(&installed_version); + let a = hbb_common::get_version_number(crate::VERSION); + let b = hbb_common::get_version_number(&installed_version); return a > b; } }