weaver_lib/tasks/
common.rs1use std::{fs, path::Path};
2
3use crate::{BuildError, renderers::WritableFile};
4
5pub fn copy_dir_all(
6 src: impl AsRef<Path>,
7 dst: impl AsRef<Path>,
8) -> Result<Option<WritableFile>, BuildError> {
9 fs::create_dir_all(&dst).unwrap();
10 for entry in fs::read_dir(src).unwrap() {
11 let entry = entry.unwrap();
12 let ty = entry.file_type().unwrap();
13 if ty.is_dir() {
14 copy_dir_all(entry.path(), dst.as_ref().join(entry.file_name()))?;
15 } else {
16 fs::copy(entry.path(), dst.as_ref().join(entry.file_name())).unwrap();
17 }
18 }
19 Ok(None)
20}