diff options
Diffstat (limited to 'src-tauri/src/repair_and_verify')
-rw-r--r-- | src-tauri/src/repair_and_verify/mod.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src-tauri/src/repair_and_verify/mod.rs b/src-tauri/src/repair_and_verify/mod.rs index 70abc127..11dbee0e 100644 --- a/src-tauri/src/repair_and_verify/mod.rs +++ b/src-tauri/src/repair_and_verify/mod.rs @@ -2,6 +2,31 @@ use crate::mod_management::{get_enabled_mods, rebuild_enabled_mods_json, set_mod /// Contains various functions to repair common issues and verifying installation use crate::{constants::CORE_MODS, GameInstall}; +/// Checks if is valid Titanfall2 install based on certain conditions +#[tauri::command] +pub async fn verify_install_location(game_path: String) -> bool { + match check_is_valid_game_path(&game_path) { + Ok(()) => true, + Err(err) => { + log::warn!("{}", err); + false + } + } +} + +/// Checks whether the provided path is a valid Titanfall2 gamepath by checking against a certain set of criteria +pub fn check_is_valid_game_path(game_install_path: &str) -> Result<(), String> { + let path_to_titanfall2_exe = format!("{game_install_path}/Titanfall2.exe"); + let is_correct_game_path = std::path::Path::new(&path_to_titanfall2_exe).exists(); + log::info!("Titanfall2.exe exists in path? {}", is_correct_game_path); + + // Exit early if wrong game path + if !is_correct_game_path { + return Err(format!("Incorrect game path \"{game_install_path}\"")); // Return error cause wrong game path + } + Ok(()) +} + /// Verifies Titanfall2 game files #[tauri::command] pub fn verify_game_files(game_install: GameInstall) -> Result<String, String> { |