]> git.r.bdr.sh - rbdr/blog/blob - src/utils.rs
Get rid of signing code
[rbdr/blog] / src / utils.rs
1 use std::io::Result;
2 use std::path::PathBuf;
3 use std::fs::{copy, create_dir_all, read_dir};
4
5 pub fn recursively_copy(source: &PathBuf, target: &PathBuf) -> Result<()> {
6 let entries = read_dir(source)?;
7 for entry in entries {
8 let entry = entry?;
9 let entry_type = entry.file_type()?;
10 let entry_name = entry.file_name();
11 let entry_source = entry.path();
12 let entry_target = target.join(entry_name);
13
14 if entry_type.is_dir() {
15 create_dir_all(&entry_target)?;
16 recursively_copy(&entry_source, &entry_target)?;
17 } else {
18 copy(&entry_source, &entry_target)?;
19 }
20 }
21
22 Ok(())
23 }