1use std::fs::{read_to_string, File};
2use std::io::Write;
3use std::path::Path;
4
5const DIF_STATIC: &'static str = "#[no_mangle]\npub static DIF_FILE: &'static [(&'static str, &'static str)] = &";
6
7pub fn add_dif(dif_path: &str) {
10 let dif = File::open(dif_path);
11 let rust_dif = File::create("src/dif.rs"); if dif.is_err() {
14 panic!("Failed to open DIF file ({})", dif_path);
15 } else if rust_dif.is_err() {
16 panic!("Failed to create Rust DIF file (src/dif.rs)");
17 }
18
19 rust_dif.unwrap().write_fmt(format_args!("{}{}{}", DIF_STATIC, read_to_string(Path::new(dif_path)).unwrap(), ";\n"));
20}