3 use std::path::PathBuf;
4 use std::fs::{copy, create_dir_all};
6 use crate::file_handler::{File, FileType, FileHandlerStrategy};
9 fn handle(&self, source: &PathBuf, destination: &PathBuf, file: &File) {
10 let relative_path = file.path.strip_prefix(&source).unwrap();
11 let complete_destination = destination.join(relative_path);
12 let destination_parent = complete_destination.parent().unwrap();
13 create_dir_all(destination_parent).unwrap();
14 copy(&file.path, &complete_destination).unwrap();
18 impl FileHandlerStrategy for Strategy {
19 fn is(&self, path: &PathBuf) -> bool {
23 fn identify(&self) -> FileType {
27 fn can_handle(&self, file_type: &FileType) -> bool {
29 FileType::File => true,
34 fn handle_html(&self, source: &PathBuf, destination: &PathBuf, file: &File, _l: &String) {
35 return self.handle(source, destination, file);
38 fn handle_gemini(&self, source: &PathBuf, destination: &PathBuf, file: &File) {
39 return self.handle(source, destination, file);