use std::fs; use std::env; use std::io; use std::path::Path; const HELP_MSG: &'static str = "\ FEJIX_CONFIG_PATH is not defined. \ Define it please so that I will know \ where to put the compiler's configuration and other important stuff"; const OBJECTS: &'static [&'static str] = &[ "fejix_config.toml", "fejix_stdlib", "fejix_stdlib/core.fj", "fejix_stdlib/uibase.fj", ]; fn main() -> io::Result<()> { if let Ok(destination) = env::var("FEJIX_CONFIG_PATH") { let path = Path::new(&destination); if !path.exists() { fs::create_dir(&path)?; } if !path.is_dir() { panic!("Path is not a directory: {}", &destination); } for object_name in OBJECTS { let object_path = Path::new(object_name); let target_path = path.join(object_path); if target_path.exists() { continue; } if object_path.is_dir() { fs::create_dir(target_path)?; } else { fs::copy(object_path, target_path)?; } } } else { panic!("{}", HELP_MSG); } Ok(()) }