(source: &Path, destination: &Path)
| 9452 | } |
| 9453 | |
| 9454 | fn copy_dir_all(source: &Path, destination: &Path) -> Result<()> { |
| 9455 | if destination.exists() { |
| 9456 | fs::remove_dir_all(destination) |
| 9457 | .with_context(|| format!("remove {}", destination.display()))?; |
| 9458 | } |
| 9459 | fs::create_dir_all(destination).with_context(|| format!("create {}", destination.display()))?; |
| 9460 | for entry in WalkDir::new(source) { |
| 9461 | let entry = entry.with_context(|| format!("walk {}", source.display()))?; |
| 9462 | let path = entry.path(); |
| 9463 | let relative = path |
| 9464 | .strip_prefix(source) |
| 9465 | .with_context(|| format!("strip {} from {}", source.display(), path.display()))?; |
| 9466 | if relative.as_os_str().is_empty() { |
| 9467 | continue; |
| 9468 | } |
| 9469 | let output = destination.join(relative); |
| 9470 | if entry.file_type().is_dir() { |
| 9471 | fs::create_dir_all(&output).with_context(|| format!("create {}", output.display()))?; |
| 9472 | } else if entry.file_type().is_file() { |
| 9473 | copy_file(path, &output)?; |
| 9474 | } |
| 9475 | } |
| 9476 | Ok(()) |
| 9477 | } |
| 9478 | |
| 9479 | fn ensure_file(path: &Path) -> Result<()> { |
| 9480 | if !path.is_file() { |
no test coverage detected