Add get_system32_path function
This commit is contained in:
parent
31d1391925
commit
7e08ca5f72
1 changed files with 18 additions and 24 deletions
|
|
@ -178,18 +178,7 @@ impl App {
|
||||||
))?;
|
))?;
|
||||||
|
|
||||||
// Get System32 path
|
// Get System32 path
|
||||||
let system32 = if cfg!(windows) {
|
let system32 = get_system32_path(&self.action_tx);
|
||||||
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(".")
|
|
||||||
};
|
|
||||||
|
|
||||||
// (Re)Enable volume mounting
|
// (Re)Enable volume mounting
|
||||||
self.tasks.add(TaskType::CommandWait(
|
self.tasks.add(TaskType::CommandWait(
|
||||||
|
|
@ -227,18 +216,7 @@ impl App {
|
||||||
))?;
|
))?;
|
||||||
|
|
||||||
// Get System32 path
|
// Get System32 path
|
||||||
let system32 = if cfg!(windows) {
|
let system32 = get_system32_path(&self.action_tx);
|
||||||
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(".")
|
|
||||||
};
|
|
||||||
|
|
||||||
// Add actions
|
// Add actions
|
||||||
let disk_list = self.clone.disk_list.lock().unwrap();
|
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)
|
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
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue