alterware-launcher/src/misc.rs
mxve 932c41d369 misc
- reduce github calls
- latest_tag returns full tag
- rev_to_int default to 0 on strip_prefix
- lint
2023-08-30 13:06:49 +02:00

21 lines
482 B
Rust

use std::{fs, path::PathBuf};
pub fn get_file_sha1(path: &PathBuf) -> String {
let mut sha1 = sha1_smol::Sha1::new();
sha1.update(&fs::read(path).unwrap());
sha1.digest().to_string()
}
pub fn stdin() -> String {
let mut input = String::new();
std::io::stdin().read_line(&mut input).unwrap();
input.trim().to_string()
}
pub fn rev_to_int(rev: &str) -> u16 {
rev.strip_prefix('r')
.unwrap_or("0")
.parse::<u16>()
.unwrap_or(0)
}