]> git.r.bdr.sh - rbdr/page/blame - src/file_finder.rs
Add basic strategies
[rbdr/page] / src / file_finder.rs
CommitLineData
1e2d00b6
RBR
1use crate::file_handler::{File, FileHandler};
2use std::fs::read_dir;
3use std::path::PathBuf;
4
5pub fn find_files(directory_path: PathBuf) -> Vec<File> {
6 let mut result: Vec<File> = vec![];
7 let file_handler = FileHandler::default();
8 let entries = read_dir(directory_path).unwrap();
9 for entry in entries {
10 let path = entry.unwrap().path();
11 if path.starts_with(".") && !path.starts_with(".well-known") {
12 continue;
13 }
14 if path.is_dir() {
15 result.append(&mut find_files(path))
16 } else {
17 let file_type = file_handler.identify(&path);
18 result.push(File {
19 path: path,
20 file_type: file_type,
21 });
22 }
23 }
24 return result;
25}