pub fn platform_name() -> &'static str {
#[cfg(windows)]
{
"Windows"
}
#[cfg(target_os = "macos")]
{
"macOS"
}
#[cfg(target_os = "linux")]
{
"Linux"
}
#[cfg(not(any(windows, target_os = "macos", target_os = "linux")))]
{
"Unknown"
}
}
pub fn is_elevated() -> bool {
#[cfg(windows)]
{
is_elevated_windows()
}
#[cfg(unix)]
{
unsafe { libc::geteuid() == 0 }
}
}
#[cfg(windows)]
fn is_elevated_windows() -> bool {
use std::process::Command;
match Command::new("net").args(["session"]).output() {
Ok(output) => output.status.success(),
Err(_) => false,
}
}