H36WAZXM2LZAJGYPRRMJUUQTER6RUOV4YXJDFXBZOHG73UPA7M5AC
use std::fs::File;
use std::io::Read;
use serde_json;
// This is probably weird place to load a file from
let app_dir = util::user_app_dir("elemeld").unwrap();
let screens = match File::open(app_dir.join("screens.json")) {
Ok(file) => match serde_json::from_reader(file) {
Ok(screens) => Some(screens),
Err(err) => {
println!("Failed to parse screens.json: {}", err);
None
},
},
Err(_) => None,
};
// Obtain the directory for storing application data
pub fn user_app_dir(name: &str) -> Option<PathBuf> {
match env::home_dir() {
Some(base) => Some(base.join(".config").join(name)),
None => None,
}
// I think this is what is needed for other
// OSes but I can't test them right now:
//
// Windows: %APPDATA%\<name>
// Mac: ~/Library/Preferences/<name> or
// ~/Library/Application Support/<name>
//
}