|
|
@@ -2,37 +2,38 @@ use std::{fs};
|
|
|
use std::path::{Path};
|
|
|
|
|
|
|
|
|
-const MAX_DEPTH: usize = 6;
|
|
|
+const MAX_DEPTH: usize = 5;
|
|
|
|
|
|
fn main() {
|
|
|
- println!("init");
|
|
|
- search_directory_recursive("E:\\Users\\cleme\\Documents\\Development", 0)
|
|
|
+ search_directory_recursive("E:\\Users\\cleme\\Downloads", 0)
|
|
|
}
|
|
|
fn search_directory_recursive(directory_path: impl AsRef<Path>, depth: usize) {
|
|
|
let directory_path = directory_path.as_ref();
|
|
|
- println!("{:?}", directory_path);
|
|
|
+ //println!("{:?}", directory_path);
|
|
|
|
|
|
if let Ok(entries) = fs::read_dir(directory_path) {
|
|
|
for entry in entries {
|
|
|
if let Ok(entry) = entry {
|
|
|
let file_path = entry.path();
|
|
|
if file_path.is_file() {
|
|
|
- if let Some(extension) = file_extension(file_path){
|
|
|
- println!("Filetype: {}", extension)
|
|
|
+ if let Some(extension) = file_extension(&file_path){
|
|
|
+ if extension == "exe" {
|
|
|
+ println!("{:?}", file_path)
|
|
|
+ }
|
|
|
}
|
|
|
} else if file_path.is_dir() && depth < MAX_DEPTH && verify_path(&file_path) {
|
|
|
- search_directory_recursive(file_path, depth + 1);
|
|
|
+ search_directory_recursive(&file_path, depth + 1);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-fn file_extension(p: impl AsRef<Path>) -> Option<String> {
|
|
|
- let p_in = p.as_ref();
|
|
|
- if let Ok(metadata) = fs::metadata(p_in) {
|
|
|
+
|
|
|
+fn file_extension(p: &Path) -> Option<String> {
|
|
|
+ if let Ok(metadata) = fs::metadata(p) {
|
|
|
if metadata.is_file() {
|
|
|
- if let Some(extension) = p_in
|
|
|
+ if let Some(extension) = p
|
|
|
.extension()
|
|
|
.and_then(|ext| ext.to_str())
|
|
|
{
|
|
|
@@ -40,13 +41,14 @@ fn file_extension(p: impl AsRef<Path>) -> Option<String> {
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- println!("Bad path: {:?}", p_in);
|
|
|
+ println!("Bad path: {:?}", p);
|
|
|
}
|
|
|
None
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
fn verify_path(p: &Path) -> bool {
|
|
|
let path_string = p.to_string_lossy().to_lowercase();
|
|
|
- !(path_string.contains("node_modules")) && !(path_string.contains("target")) && !(path_string.contains(".git")) && !(path_string.contains("venv"))
|
|
|
+ !(path_string.contains("node_modules")) && !(path_string.contains("target")) && !(path_string.contains(".git")) && !(path_string.contains("venv")) && !(path_string.contains("dependencies"))
|
|
|
}
|