]> git.r.bdr.sh - rbdr/page/blobdiff - src/file_finder.rs
Wrap headings, fix empty lines
[rbdr/page] / src / file_finder.rs
index fc32fa92d16e11d8e5cdeadbe26ceaccc078004e..bcd368dbf94089280c36010ac35f51c6b4618aca 100644 (file)
@@ -2,17 +2,22 @@ use crate::file_handler::{File, FileHandler};
 use std::fs::read_dir;
 use std::path::PathBuf;
 
 use std::fs::read_dir;
 use std::path::PathBuf;
 
-pub fn find_files(directory_path: PathBuf) -> Vec<File> {
+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 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();
     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(".git") || relative_path.starts_with(".gitignore") {
             continue;
         }
         if path.is_dir() {
             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 {
         } else {
             let file_type = file_handler.identify(&path);
             result.push(File {