MCPcopy Create free account
hub / github.com/f0rr0/oliphaunt / copy_dir_all

Function copy_dir_all

xtask/src/main.rs:9454–9477  ·  view source on GitHub ↗
(source: &Path, destination: &Path)

Source from the content-addressed store, hash-verified

9452}
9453
9454fn 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
9479fn ensure_file(path: &Path) -> Result<()> {
9480 if !path.is_file() {

Callers 3

stage_release_workspaceFunction · 0.85

Calls 3

copy_fileFunction · 0.85
pathMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected