use std::fs;
use std::path::Path;
fn main() {
let src = Path::new("doc/media"); let dest = Path::new("target/doc/media");
println!("cargo:rerun-if-changed=doc/media");
if !src.exists() {
eprintln!("Warning: Source directory {:?} does not exist!", src);
return;
}
if let Err(e) = fs::create_dir_all(dest) {
eprintln!("Error: Could not create {:?}: {}", dest, e);
return;
}
for entry in src.read_dir().expect("Failed to read source directory") {
let entry = entry.expect("Failed to read directory entry");
let path = entry.path();
let dest_path = dest.join(path.file_name().unwrap());
if let Err(e) = fs::copy(&path, &dest_path) {
eprintln!(
"Warning: Failed to copy {:?} to {:?}: {}",
path, dest_path, e
);
} else {
println!("Copied {:?} to {:?}", path, dest_path);
}
}
println!("✅ Image copying complete.");
}