]> git.r.bdr.sh - rbdr/page/blame - src/file_handler/file_strategies/file.rs
Add gemini parsing
[rbdr/page] / src / file_handler / file_strategies / file.rs
CommitLineData
1e2d00b6
RBR
1pub struct Strategy {}
2
3use std::path::PathBuf;
ea529736 4use std::fs::{copy, create_dir_all};
1e2d00b6 5
4fd89b80 6use crate::file_handler::{File, FileType, FileHandlerStrategy};
1e2d00b6
RBR
7
8impl FileHandlerStrategy for Strategy {
9 fn is(&self, path: &PathBuf) -> bool {
10 !path.is_dir()
11 }
12
13 fn identify(&self) -> FileType {
14 FileType::File
15 }
16
4fd89b80
RBR
17 fn can_handle(&self, file_type: &FileType) -> bool {
18 match file_type {
19 FileType::File => true,
20 _ => false,
21 }
1e2d00b6
RBR
22 }
23
68fa37d6 24 fn handle(&self, source: &PathBuf, destination: &PathBuf, file: &File, _l: &String) {
ea529736
RBR
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();
1e2d00b6
RBR
30 }
31}