malvin 0.2.4

Non-interactive research and coding agent
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::fs;
use std::io;
use std::path::Path;

pub(super) fn copy_dir_recursive(from: &Path, to: &Path) -> io::Result<()> {
    fs::create_dir_all(to)?;
    for entry in fs::read_dir(from)? {
        let entry = entry?;
        let dest = to.join(entry.file_name());
        let ftype = entry.file_type()?;
        if ftype.is_dir() {
            copy_dir_recursive(&entry.path(), &dest)?;
        } else if ftype.is_file() {
            fs::copy(entry.path(), &dest)?;
        }
    }
    Ok(())
}