testing video parse
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
use std::os::windows::process::CommandExt;
|
||||
use std::process::Command;
|
||||
|
||||
#[cfg(windows)]
|
||||
use std::os::windows::process::CommandExt;
|
||||
const CREATE_NO_WINDOW: u32 = 0x08000000;
|
||||
// const DETACHED_PROCESS: u32 = 0x00000008;
|
||||
|
||||
pub fn kill(name: &str) -> String {
|
||||
#[cfg(windows)]
|
||||
Command::new("taskkill")
|
||||
.args(&["/IM", name, "/F"])
|
||||
.creation_flags(CREATE_NO_WINDOW)
|
||||
@@ -15,10 +17,16 @@ pub fn kill(name: &str) -> String {
|
||||
}
|
||||
|
||||
pub fn run_steam() -> std::io::Result<std::process::Output> {
|
||||
#[cfg(target_os = "windows")]
|
||||
Command::new("cmd")
|
||||
.args(&["/C", "start", "steam://run"])
|
||||
.creation_flags(CREATE_NO_WINDOW)
|
||||
.output()
|
||||
.output();
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
Command::new("open")
|
||||
.args(&["-a", "Steam"])
|
||||
.output()
|
||||
}
|
||||
|
||||
pub fn get_exe_path(name: &str) -> Result<String, std::io::Error> {
|
||||
@@ -30,11 +38,17 @@ pub fn get_exe_path(name: &str) -> Result<String, std::io::Error> {
|
||||
// 进程路径
|
||||
let command = format!("Get-Process {} | Select-Object path", name);
|
||||
let args = command.split_whitespace().collect::<Vec<&str>>();
|
||||
#[cfg(windows)]
|
||||
let output = Command::new("powershell.exe")
|
||||
.args(&args)
|
||||
.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()?;
|
||||
|
||||
let out = String::from_utf8_lossy(&output.stdout).to_string();
|
||||
|
||||
if out.contains("Path") {
|
||||
@@ -54,6 +68,7 @@ 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("/", "\\");
|
||||
#[cfg(windows)]
|
||||
Command::new("cmd.exe")
|
||||
.args(["/c", "start", "", &path])
|
||||
.creation_flags(CREATE_NO_WINDOW)
|
||||
|
||||
Reference in New Issue
Block a user