[feat] launch game code optim + open path after mkdir
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use std::fs;
|
||||
use std::process::Command;
|
||||
|
||||
#[cfg(windows)]
|
||||
@@ -23,10 +24,8 @@ pub fn run_steam() -> std::io::Result<std::process::Output> {
|
||||
.creation_flags(CREATE_NO_WINDOW)
|
||||
.output();
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
Command::new("open")
|
||||
.args(&["-a", "Steam"])
|
||||
.output()
|
||||
#[cfg(target_os = "macos")]
|
||||
Command::new("open").args(&["-a", "Steam"]).output()
|
||||
}
|
||||
|
||||
pub fn get_exe_path(name: &str) -> Result<String, std::io::Error> {
|
||||
@@ -44,10 +43,13 @@ pub fn get_exe_path(name: &str) -> Result<String, std::io::Error> {
|
||||
.creation_flags(CREATE_NO_WINDOW)
|
||||
.output()?;
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
let output = Command::new("osascript")
|
||||
.args(&["-e", &format!("tell application \"{}\" to get path to me", name)])
|
||||
.output()?;
|
||||
#[cfg(target_os = "macos")]
|
||||
let output = Command::new("osascript")
|
||||
.args(&[
|
||||
"-e",
|
||||
&format!("tell application \"{}\" to get path to me", name),
|
||||
])
|
||||
.output()?;
|
||||
|
||||
let out = String::from_utf8_lossy(&output.stdout).to_string();
|
||||
|
||||
@@ -68,6 +70,8 @@ pub fn get_exe_path(name: &str) -> Result<String, std::io::Error> {
|
||||
pub fn open_path(path: &str) -> Result<(), std::io::Error> {
|
||||
// path中所有/ 转换为 \
|
||||
let path = path.replace("/", "\\");
|
||||
fs::create_dir_all(path)?;
|
||||
|
||||
#[cfg(windows)]
|
||||
Command::new("cmd.exe")
|
||||
.args(["/c", "start", "", &path])
|
||||
|
||||
Reference in New Issue
Block a user