Recursively copy a directory.
(src: &std::path::Path, dst: &std::path::Path)
| 359 | |
| 360 | /// Recursively copy a directory. |
| 361 | fn copy_dir_recursive(src: &std::path::Path, dst: &std::path::Path) -> std::io::Result<()> { |
| 362 | std::fs::create_dir_all(dst)?; |
| 363 | for entry in std::fs::read_dir(src)? { |
| 364 | let entry = entry?; |
| 365 | let ty = entry.file_type()?; |
| 366 | let dst_path = dst.join(entry.file_name()); |
| 367 | if ty.is_dir() { |
| 368 | copy_dir_recursive(&entry.path(), &dst_path)?; |
| 369 | } else { |
| 370 | std::fs::copy(entry.path(), &dst_path)?; |
| 371 | } |
| 372 | } |
| 373 | Ok(()) |
| 374 | } |
| 375 | |
| 376 | // ─── Tests ─────────────────────────────────────────────────────────────────── |
| 377 |
no test coverage detected