/****************************************************************************** * @file build.rs * @author Joey Pollack * @date 2025/11/20 (y/m/d) * @modified 2025/11/20 (y/m/d) * @copyright Joseph R Pollack (2025) * @brief ******************************************************************************/ // use std::process::Command; use std::io::prelude::*; use std::{env, fs, fs::File, path::Path}; fn main() { let name = env!("CARGO_PKG_NAME"); println!("{} build.rs started...", name); let in_path = Path::new("input/"); let out_path = format!("target/{}", &env::var("PROFILE").unwrap()); let out_path = Path::new(&out_path).join("input/"); let test_file_name = out_path.join("foo.txt".to_string()); if !out_path.exists() { fs::create_dir(&out_path).expect("Failed to create the out directory"); } if !in_path.exists() { fs::create_dir(&in_path).expect("failed to create dummy input path"); } if !in_path.is_dir() { println!("in_path is not a directory"); } // Test file let mut file = File::create(test_file_name).expect("Failed to create test file"); file.write_all(b"Hello, world!").expect("Failed to write to test file"); // Copy input files for f in in_path.read_dir().expect("Failed to parse directory entries") { let f = f.expect("failed to parse directly entry"); let dest = out_path.join(f.path().file_name().unwrap()); fs::copy(f.path(), &dest).expect(&format!("failed to copy file: {:#?}, to {:#?}", f, dest)); } println!("{} build.rs finished", name); }