MCPcopy Create free account
hub / github.com/Recordscript/recordscript / get_version_number

Function get_version_number

libs/hbb_common/src/lib.rs:244–269  ·  view source on GitHub ↗

Support 1.1.10-1, the number after - is a patch version.

(v: &str)

Source from the content-addressed store, hash-verified

242
243// Support 1.1.10-1, the number after - is a patch version.
244pub 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
271pub fn get_modified_time(path: &std::path::Path) -> SystemTime {
272 std::fs::metadata(path)

Callers 1

Calls 1

nextMethod · 0.45

Tested by

no test coverage detected