use std::path::Path; use std::{env, fs}; fn main() { println!("cargo:rerun-if-changed=soundboard.toml"); println!("cargo:rerun-if-changed=soundboards"); let target_dir_path = Path::new(&env::var("OUT_DIR").unwrap()) .join("..") .join("..") .join(".."); copy_file(&target_dir_path, "soundboard.toml"); let out_soundboards_path = Path::new(&target_dir_path).join("soundboards"); if out_soundboards_path.exists() && out_soundboards_path.is_dir() { std::fs::remove_dir_all(&out_soundboards_path).unwrap(); } let copy_options = fs_extra::dir::CopyOptions::new(); if Path::new("soundboards").exists() { fs_extra::dir::copy("soundboards", target_dir_path, ©_options).expect("copy failed"); } } fn copy_file + ?Sized, P: Copy + AsRef>( target_dir_path: &S, file_name: P, ) { fs::copy(file_name, Path::new(&target_dir_path).join(file_name)).unwrap(); }