From 2cb09e431e5693eba208dff5220580aeaa692d5c Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Thu, 10 Oct 2019 11:08:40 -0300 Subject: [PATCH] Recursively check paths, not only the parent of files --- Cargo.lock | 2 ++ src/main.rs | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index adc4973..14fa4c5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,3 +1,5 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. [[package]] name = "aho-corasick" version = "0.7.6" diff --git a/src/main.rs b/src/main.rs index 2abed64..292e88b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -60,7 +60,11 @@ fn main() { if filename.ends_with("/") { files_dirs.insert(filename.clone()); } else { - directory_files.insert(Path::new(filename).parent().unwrap().to_str().unwrap().to_string() + "/"); + let mut path = Path::new(filename); + while path.parent().is_some() { + directory_files.insert(path.parent().unwrap().to_str().unwrap().to_string() + "/"); + path = path.parent().unwrap(); + } } }); }