aboutsummaryrefslogtreecommitdiff
path: root/src-tauri/src/northstar/profile.rs
diff options
context:
space:
mode:
authorGeckoEidechse <gecko.eidechse+git@pm.me>2024-01-27 22:21:12 +0100
committerGeckoEidechse <gecko.eidechse+git@pm.me>2024-01-27 22:21:12 +0100
commit5284445cab89bb5af6d415c825a2cfa45cb92592 (patch)
tree5880b3ab4b48fdf28c7c5189a874494fcac31b97 /src-tauri/src/northstar/profile.rs
parentbcb77c2f326450e0cac78dd965cd6cb4dceaa736 (diff)
parent83ed4bedc183975f2f1a65b9cd38881410605904 (diff)
downloadFlightCore-5284445cab89bb5af6d415c825a2cfa45cb92592.tar.gz
FlightCore-5284445cab89bb5af6d415c825a2cfa45cb92592.zip
Merge branch 'main' into refactor/pass-launch-options-object
Diffstat (limited to 'src-tauri/src/northstar/profile.rs')
-rw-r--r--src-tauri/src/northstar/profile.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src-tauri/src/northstar/profile.rs b/src-tauri/src/northstar/profile.rs
index b0c6c418..26a32d6b 100644
--- a/src-tauri/src/northstar/profile.rs
+++ b/src-tauri/src/northstar/profile.rs
@@ -1,3 +1,4 @@
+use crate::util::copy_dir_all;
use crate::GameInstall;
// These folders are part of Titanfall 2 and
@@ -91,3 +92,30 @@ pub fn delete_profile(game_install: GameInstall, profile: String) -> Result<(),
Err(err) => Err(format!("Failed to delete Profile: {}", err)),
}
}
+
+/// Clones a profile by simply duplicating the folder under a new name
+#[tauri::command]
+pub fn clone_profile(
+ game_install: GameInstall,
+ old_profile: String,
+ new_profile: String,
+) -> Result<(), String> {
+ // Check if the old Profile already exists
+ if !validate_profile(game_install.clone(), old_profile.clone()) {
+ return Err(format!("{} is not a valid Profile", old_profile));
+ }
+
+ // Check that new Profile does not already exist
+ if validate_profile(game_install.clone(), new_profile.clone()) {
+ return Err(format!("{} already exists", new_profile));
+ }
+
+ log::info!("Cloning Profile {} to {}", old_profile, new_profile);
+
+ let old_profile_path = format!("{}/{}", game_install.game_path, old_profile);
+ let new_profile_path = format!("{}/{}", game_install.game_path, new_profile);
+
+ copy_dir_all(old_profile_path, new_profile_path).unwrap();
+
+ Ok(())
+}