liftinstall/src/installer.rs

48 lines
1.1 KiB
Rust
Raw Normal View History

2018-01-27 03:27:41 +00:00
/// installer.rs
///
/// Contains the main installer structure, as well as high-level means of controlling it.
2018-01-27 04:14:56 +00:00
use std::env::home_dir;
use std::env::var;
use std::path::PathBuf;
2018-01-27 03:27:41 +00:00
use config::Config;
/// The installer framework contains metadata about packages, what is installable, what isn't,
/// etc.
pub struct InstallerFramework {
config : Config
}
impl InstallerFramework {
/// Returns a copy of the configuration.
pub fn get_config(&self) -> Config {
self.config.clone()
}
2018-01-27 04:14:56 +00:00
/// Returns the default install path.
pub fn get_default_path(&self) -> Option<String> {
let app_name = &self.config.general.name;
let base_dir = match var("LOCALAPPDATA") {
Ok(path) => PathBuf::from(path),
Err(_) => home_dir()?
};
println!("{:?}", base_dir);
let file = base_dir.join(app_name);
println!("{:?}", file);
Some(file.to_str()?.to_owned())
}
2018-01-27 03:27:41 +00:00
/// Creates a new instance of the Installer Framework with a specified Config.
pub fn new(config : Config) -> Self {
InstallerFramework {
config
}
}
}