[feat] basic open path but having issue of path with spaces

This commit is contained in:
Purp1e
2025-03-21 16:02:47 +08:00
parent 90a05017ce
commit 2e18fbdffd
5 changed files with 52 additions and 9 deletions

View File

@@ -15,6 +15,7 @@ pub fn run_steam() -> std::io::Result<std::process::Output> {
.output()
}
// FIXME wmic is deprecated
pub fn get_exe_path(name: &str) -> Result<String, std::io::Error> {
let command = format!("/C wmic process where name='{}' get ExecutablePath", name);
let args = command.split_whitespace().collect::<Vec<&str>>();
@@ -33,3 +34,12 @@ pub fn get_exe_path(name: &str) -> Result<String, std::io::Error> {
"Failed to get executable path",
))
}
pub fn open_path(path: &str) -> Result<(), std::io::Error> {
let p = format!("file:///{}", path);
Command::new("explorer")
.args([p])
.spawn()
.expect("Failed to open path");
Ok(())
}