parent
7f1a1ff57b
commit
9d973a0fd6
8 changed files with 388 additions and 26 deletions
31
src/sys.rs
31
src/sys.rs
|
|
@ -17,6 +17,37 @@ pub fn open_url(url: &str) {
|
|||
}
|
||||
}
|
||||
|
||||
/// Reveal a saved drawing in the native platform's file manager.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub fn reveal_in_file_manager(path: &std::path::Path) -> Result<(), String> {
|
||||
#[cfg(target_os = "windows")]
|
||||
let status = std::process::Command::new("explorer.exe")
|
||||
.arg("/select,")
|
||||
.arg(path)
|
||||
.status();
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
let status = std::process::Command::new("open")
|
||||
.arg("-R")
|
||||
.arg(path)
|
||||
.status();
|
||||
|
||||
#[cfg(not(any(target_os = "windows", target_os = "macos")))]
|
||||
{
|
||||
let folder = path
|
||||
.parent()
|
||||
.ok_or_else(|| format!("Path has no parent folder: {}", path.display()))?;
|
||||
return open::that(folder).map_err(|e| e.to_string());
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "windows", target_os = "macos"))]
|
||||
match status {
|
||||
Ok(status) if status.success() => Ok(()),
|
||||
Ok(status) => Err(format!("File manager exited with {status}")),
|
||||
Err(error) => Err(error.to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
/// Web: read text from the system clipboard via the async Clipboard API.
|
||||
/// iced's own `clipboard::read` is a no-op on the web (the browser clipboard is
|
||||
/// async + permission-gated), so the editor paste paths use this instead. The
|
||||
|
|
|
|||
Loading…
Reference in a new issue