use std::io;
#[cfg(target_os = "windows")]
use crate::os_windows;
#[cfg(not(target_os = "windows"))]
use crate::os_unix;
pub trait EnvironmentAccessor {
fn set_user_environment_variable(&self, name: &str, value: &str) -> io::Result<()>;
fn get_user_environment_variable(&self, name: &str) -> io::Result<String>;
fn set_system_environment_variable(&self, name: &str, value: &str) -> io::Result<()>;
fn get_system_environment_variable(&self, name: &str) -> io::Result<String>;
fn broadcast_environment_change(&self) -> io::Result<()> {
Ok(())
}
fn ensure_java_home_bin_in_user_path(&self) -> io::Result<()> {
Ok(())
}
fn ensure_java_home_bin_in_system_path(&self) -> io::Result<()> {
Ok(())
}
}
pub fn create_os_environment_handler() -> Box<dyn EnvironmentAccessor> {
#[cfg(target_os = "windows")]
{
Box::new(os_windows::WindowsEnvironmentAccessor::default())
}
#[cfg(not(target_os = "windows"))]
{
Box::new(os_unix::UnixEnvironmentAccessor::default())
}
}