Add get_system32_path function

This commit is contained in:
2Shirt 2025-04-05 15:12:30 -07:00
parent 31d1391925
commit 7e08ca5f72
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -178,18 +178,7 @@ impl App {
))?;
// Get System32 path
let system32 = if cfg!(windows) {
if let Ok(path) = env::var("SYSTEMROOT") {
format!("{path}/System32")
} else {
self.action_tx.send(Action::Error(String::from(
"ERROR\n\n\nFailed to find SYSTEMROOT",
)))?;
return Ok(());
}
} else {
String::from(".")
};
let system32 = get_system32_path(&self.action_tx);
// (Re)Enable volume mounting
self.tasks.add(TaskType::CommandWait(
@ -227,18 +216,7 @@ impl App {
))?;
// Get System32 path
let system32 = if cfg!(windows) {
if let Ok(path) = env::var("SYSTEMROOT") {
format!("{path}/System32")
} else {
self.action_tx.send(Action::Error(String::from(
"ERROR\n\n\nFailed to find SYSTEMROOT",
)))?;
return Ok(());
}
} else {
String::from(".")
};
let system32 = get_system32_path(&self.action_tx);
// Add actions
let disk_list = self.clone.disk_list.lock().unwrap();
@ -796,3 +774,19 @@ fn build_right_items(app: &App, cur_mode: Mode) -> Action {
}
Action::UpdateRight(labels, start_index, items)
}
pub fn get_system32_path(action_tx: &mpsc::UnboundedSender<Action>) -> String {
let mut system32_path = String::from(".");
if cfg!(windows) {
if let Ok(path) = env::var("SYSTEMROOT") {
system32_path = format!("{path}/System32");
} else {
action_tx
.send(Action::Error(String::from(
"ERROR\n\n\nFailed to find SYSTEMROOT",
)))
.expect("Failed to find SYSTEMROOT and then failed to send action");
}
}
system32_path
}