diff options
author | Sebastian Thiel <sthiel@thoughtworks.com> | 2019-06-01 13:56:07 +0530 |
---|---|---|
committer | Sebastian Thiel <sthiel@thoughtworks.com> | 2019-06-01 13:56:33 +0530 |
commit | 9ba5a348c67a898abb0ae648e686da48649a33df (patch) | |
tree | 6280fb3905bcbf2ecdfebf9c2f18fd5c2e9b4623 /src/common.rs | |
parent | 8b2ef49bf9f37d0e126fa68115175fe2cf82aaf5 (diff) |
Make explicit that Sorting is disabled during aggregation; more spacing
Diffstat (limited to 'src/common.rs')
-rw-r--r-- | src/common.rs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/common.rs b/src/common.rs index afeaf1f..91a24f1 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,5 +1,5 @@ use jwalk::WalkDir; -use std::{fmt, path::Path}; +use std::path::Path; pub enum ByteFormat { Metric, @@ -7,6 +7,11 @@ pub enum ByteFormat { Bytes, } +pub enum Sorting { + None, + Alphabetical, +} + pub struct WalkOptions { pub threads: usize, pub format: ByteFormat, @@ -25,9 +30,14 @@ impl WalkOptions { .get_appropriate_unit(binary) .format(2) } - pub fn iter_from_path(&self, path: &Path) -> WalkDir { + + pub fn iter_from_path(&self, path: &Path, sort: Sorting) -> WalkDir { WalkDir::new(path) .preload_metadata(true) + .sort(match sort { + Sorting::Alphabetical => true, + Sorting::None => false, + }) .skip_hidden(false) .num_threads(self.threads) } @@ -37,9 +47,3 @@ impl WalkOptions { pub struct WalkResult { pub num_errors: u64, } - -impl fmt::Display for WalkResult { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - write!(f, "Encountered {} IO error(s)", self.num_errors) - } -} |