aboutsummaryrefslogtreecommitdiff
path: root/src-tauri/src/northstar/mod.rs
blob: 7bd0b0a3b8f551f9ed79e69b5341968ec1028490 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//! This module deals with handling things around Northstar such as
//! - getting version number

use crate::{check_mod_version_number, constants::CORE_MODS};
use anyhow::anyhow;

/// Returns the current Northstar version number as a string
pub fn get_northstar_version_number(game_path: &str) -> Result<String, anyhow::Error> {
    log::info!("{}", game_path);

    // TODO:
    // Check if NorthstarLauncher.exe exists and check its version number
    let profile_folder = "R2Northstar";
    let initial_version_number = match check_mod_version_number(&format!(
        "{game_path}/{profile_folder}/mods/{}",
        CORE_MODS[0]
    )) {
        Ok(version_number) => version_number,
        Err(err) => return Err(err),
    };

    for core_mod in CORE_MODS {
        let current_version_number = match check_mod_version_number(&format!(
            "{game_path}/{profile_folder}/mods/{core_mod}",
        )) {
            Ok(version_number) => version_number,
            Err(err) => return Err(err),
        };
        if current_version_number != initial_version_number {
            // We have a version number mismatch
            return Err(anyhow!("Found version number mismatch"));
        }
    }
    log::info!("All mods same version");

    Ok(initial_version_number)
}