Support 1.1.10-1, the number after - is a patch version.
(v: &str)
| 242 | |
| 243 | // Support 1.1.10-1, the number after - is a patch version. |
| 244 | pub fn get_version_number(v: &str) -> i64 { |
| 245 | let mut versions = v.split('-'); |
| 246 | |
| 247 | let mut n = 0; |
| 248 | |
| 249 | // The first part is the version number. |
| 250 | // 1.1.10 -> 1001100, 1.2.3 -> 1001030, multiple the last number by 10 |
| 251 | // to leave space for patch version. |
| 252 | if let Some(v) = versions.next() { |
| 253 | let mut last = 0; |
| 254 | for x in v.split('.') { |
| 255 | last = x.parse::<i64>().unwrap_or(0); |
| 256 | n = n * 1000 + last; |
| 257 | } |
| 258 | n -= last; |
| 259 | n += last * 10; |
| 260 | } |
| 261 | |
| 262 | if let Some(v) = versions.next() { |
| 263 | n += v.parse::<i64>().unwrap_or(0); |
| 264 | } |
| 265 | |
| 266 | // Ignore the rest |
| 267 | |
| 268 | n |
| 269 | } |
| 270 | |
| 271 | pub fn get_modified_time(path: &std::path::Path) -> SystemTime { |
| 272 | std::fs::metadata(path) |
no test coverage detected