mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-10-13 10:24:47 +00:00
23 lines
592 B
Rust
23 lines
592 B
Rust
use anyhow::Result;
|
|
use std::fs;
|
|
use std::path::Path;
|
|
use walkdir::WalkDir;
|
|
|
|
pub fn copy_dir_recursive(src: &Path, dst: &Path) -> Result<()> {
|
|
for entry in WalkDir::new(src).into_iter().filter_map(|e| e.ok()) {
|
|
let path = entry.path();
|
|
let rel = path.strip_prefix(src)?;
|
|
let target = dst.join(rel);
|
|
|
|
if path.is_dir() {
|
|
fs::create_dir_all(&target)?;
|
|
} else {
|
|
if let Some(parent) = target.parent() {
|
|
fs::create_dir_all(parent)?;
|
|
}
|
|
fs::copy(path, &target)?;
|
|
}
|
|
}
|
|
Ok(())
|
|
}
|