3 use std::path::PathBuf;
4 use std::fs::{copy, create_dir_all};
6 use crate::file_handler::{File, FileType, FileHandlerStrategy};
8 impl FileHandlerStrategy for Strategy {
9 fn is(&self, path: &PathBuf) -> bool {
13 fn identify(&self) -> FileType {
17 fn can_handle(&self, file_type: &FileType) -> bool {
19 FileType::File => true,
24 fn handle(&self, source: &PathBuf, destination: &PathBuf, file: &File, _l: &String) {
25 let relative_path = file.path.strip_prefix(&source).unwrap();
26 let complete_destination = destination.join(relative_path);
27 let destination_parent = complete_destination.parent().unwrap();
28 create_dir_all(destination_parent).unwrap();
29 copy(&file.path, &complete_destination).unwrap();