use std::path::{Path, PathBuf};
use crate::error::Result;
#[cfg(target_os = "linux")]
mod linux;
#[cfg(target_os = "macos")]
mod macos;
#[cfg(target_os = "windows")]
mod windows;
#[derive(Debug, Clone)]
pub struct Installed {
pub restart_path: Option<PathBuf>,
}
pub fn install(artifact: &Path, install_root: &Path) -> Result<Installed> {
#[cfg(target_os = "macos")]
{
macos::install(artifact, install_root)
}
#[cfg(target_os = "linux")]
{
linux::install(artifact, install_root)
}
#[cfg(target_os = "windows")]
{
windows::install(artifact, install_root)
}
#[cfg(not(any(target_os = "macos", target_os = "linux", target_os = "windows")))]
{
let _ = (artifact, install_root);
Err(crate::Error::UnsupportedPlatform(std::env::consts::OS))
}
}
pub fn current_install_root() -> Result<PathBuf> {
let exe = std::env::current_exe()?;
#[cfg(target_os = "macos")]
{
Ok(macos::bundle_root(&exe).unwrap_or(exe))
}
#[cfg(not(target_os = "macos"))]
{
Ok(exe)
}
}