You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
865 B
Rust
46 lines
865 B
Rust
#[derive(Debug)]
|
|
#[derive(PartialEq)]
|
|
#[derive(Clone)]
|
|
pub struct IglooEnv
|
|
{
|
|
// Current Working Directory
|
|
pub cwd: PathBuf,
|
|
// Home Directory
|
|
pub hd: PathBuf,
|
|
// ESF Directory
|
|
pub esfd: PathBuf,
|
|
}
|
|
|
|
impl IglooEnv
|
|
{
|
|
pub fn get_env() -> IglooEnvInfo
|
|
{
|
|
cwd: env::current_dir().unwrap(),
|
|
hd: match UserDirs::new()
|
|
{
|
|
Some(v) => v.home_dir().to_owned(),
|
|
None =>
|
|
{
|
|
println!("Error: Failed to get home directory.\n\
|
|
This should never happen. Exiting...");
|
|
std::process::exit(1);
|
|
}
|
|
},
|
|
esfd: match std::env::var("ESF_DIR")
|
|
{
|
|
Ok(v)
|
|
{
|
|
std::path::PathBuf::from(&v.to_owned())
|
|
}
|
|
Err(e) =>
|
|
{
|
|
// Note : Need to change new to return actual errors
|
|
// instead of exiting early
|
|
println!("Error: $ESF_DIR not defined as an environment\
|
|
variable -- {:?}", e);
|
|
std::process::exit(1);
|
|
}
|
|
}
|
|
}
|
|
}
|