Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/walkdir.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2015-09-27 08:27:18 +0300
committerAndrew Gallant <jamslam@gmail.com>2015-09-27 08:27:18 +0300
commit0964a448b7e128f603f4e78e049e84d25a0670d7 (patch)
tree2549bd53764689086f0331f15d9cab9f45996e81
parent8a8a89202bfacc8317f049708ac321a1274b3a0e (diff)
Tweak when max depth pruning happens.
-rw-r--r--src/lib.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs
index a86ce46..0e2bca9 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -488,6 +488,12 @@ impl Iterator for Iter {
}
while !self.stack_list.is_empty() {
self.depth = self.stack_list.len();
+ if self.depth > self.opts.max_depth {
+ // If we've exceeded the max depth, pop the current dir
+ // so that we don't descend.
+ self.pop();
+ continue;
+ }
match self.stack_list.last_mut().unwrap().next() {
None => self.pop(),
Some(Err(err)) => return Some(Err(err)),
@@ -522,7 +528,7 @@ impl Iter {
if self.opts.follow_links && dent.file_type().is_symlink() {
dent = itry!(self.follow(dent));
}
- if dent.file_type().is_dir() && self.depth < self.opts.max_depth {
+ if dent.file_type().is_dir() {
self.push(&dent);
}
if self.skippable() { None } else { Some(Ok(dent)) }