]> git.r.bdr.sh - rbdr/page/blob - src/file_finder.rs
Read the files
[rbdr/page] / src / file_finder.rs
1 use crate::file_handler::{File, FileHandler};
2 use std::fs::read_dir;
3 use std::path::PathBuf;
4
5 pub 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 }