use std::path::PathBuf;
pub fn find_files(directory_path: PathBuf) -> Vec<File> {
+ return find_files_recursively(&directory_path, &directory_path);
+}
+
+fn find_files_recursively(root_path: &PathBuf, directory_path: &PathBuf) -> Vec<File> {
let mut result: Vec<File> = vec![];
let file_handler = FileHandler::default();
- let entries = read_dir(directory_path).unwrap();
+ let entries = read_dir(&directory_path).unwrap();
for entry in entries {
let path = entry.unwrap().path();
- if path.starts_with(".") && !path.starts_with(".well-known") {
+ let relative_path = path.strip_prefix(&root_path).unwrap();
+ if relative_path.starts_with(".") && !relative_path.starts_with(".well-known") {
continue;
}
if path.is_dir() {
- result.append(&mut find_files(path))
+ result.append(&mut find_files_recursively(&root_path, &path))
} else {
let file_type = file_handler.identify(&path);
result.push(File {