pub fn copy_folder_dir(source: &Path, destination: &Path) -> Result<()>Expand description
Recursively copies the contents of the source directory to the destination directory.
This function creates the destination directory (if it doesn’t exist), then copies all files
and subdirectories from source into destination, preserving the directory structure.
§Arguments
source- A reference to the path of the directory to copy from.destination- A reference to the path of the directory to copy to.
§Errors
Returns an io::Result<()> which is Ok if the operation succeeds, or an error if any I/O
operation fails during copying or directory creation.
§Usage:
§Example (1)
// // src/assets
// pub fn fluxor_copy_folder(dest_path: &Path) {
// let source_path = Path::new("src/examples/fluxor/assets");
// // Copy entire directory recursively
// match copy_folder_dir(source_path, &dest_path.join("assets")) {
// Ok(_) => println!("Copied assets successfully."),
// Err(e) => eprintln!("Error copying assets: {}", e),
// }
// }§Example (2)
// pub fn fluxor_copy_folder(source_path: &str, dest_path: &Path, folder_name: &str) {
// match copy_folder_dir(Path::new(&source_path), &dest_path.join(folder_name)) {
// Ok(_) => println!("Copied {} successfully.", folder_name),
// Err(e) => eprintln!("Error copying {}: {}", folder_name, e),
// }
// }