parent
bfd9bb8a7c
commit
c763c8c64b
1 changed files with 31 additions and 4 deletions
|
@ -275,9 +275,37 @@ impl Platform for WindowsPlatform {
|
|||
.detach();
|
||||
}
|
||||
|
||||
// todo(windows)
|
||||
fn restart(&self) {
|
||||
unimplemented!()
|
||||
let pid = std::process::id();
|
||||
let Some(app_path) = self.app_path().log_err() else {
|
||||
return;
|
||||
};
|
||||
let script = format!(
|
||||
r#"
|
||||
$pidToWaitFor = {}
|
||||
$exePath = "{}"
|
||||
|
||||
while ($true) {{
|
||||
$process = Get-Process -Id $pidToWaitFor -ErrorAction SilentlyContinue
|
||||
if (-not $process) {{
|
||||
Start-Process -FilePath $exePath
|
||||
break
|
||||
}}
|
||||
Start-Sleep -Seconds 0.1
|
||||
}}
|
||||
"#,
|
||||
pid,
|
||||
app_path.display(),
|
||||
);
|
||||
let restart_process = std::process::Command::new("powershell.exe")
|
||||
.arg("-command")
|
||||
.arg(script)
|
||||
.spawn();
|
||||
|
||||
match restart_process {
|
||||
Ok(_) => self.quit(),
|
||||
Err(e) => log::error!("failed to spawn restart script: {:?}", e),
|
||||
}
|
||||
}
|
||||
|
||||
// todo(windows)
|
||||
|
@ -621,9 +649,8 @@ impl Platform for WindowsPlatform {
|
|||
}
|
||||
}
|
||||
|
||||
// todo(windows)
|
||||
fn app_path(&self) -> Result<PathBuf> {
|
||||
Err(anyhow!("not yet implemented"))
|
||||
Ok(std::env::current_exe()?)
|
||||
}
|
||||
|
||||
fn local_timezone(&self) -> UtcOffset {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue