mirror of
https://github.com/bootandy/dust.git
synced 2026-06-08 11:29:05 +03:00
feat: Added the ability to filter the corresponding files based on the access time, modify time, and change time of the file for statistics
This commit is contained in:
+14
-1
@@ -2,6 +2,9 @@ use platform::get_metadata;
|
||||
use std::collections::HashSet;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use crate::config::DAY_SECEONDS;
|
||||
|
||||
use crate::dir_walker::Operater;
|
||||
use crate::platform;
|
||||
use regex::Regex;
|
||||
|
||||
@@ -36,7 +39,7 @@ pub fn get_filesystem_devices<'a, P: IntoIterator<Item = &'a PathBuf>>(paths: P)
|
||||
paths
|
||||
.into_iter()
|
||||
.filter_map(|p| match get_metadata(p, false) {
|
||||
Some((_size, Some((_id, dev)))) => Some(dev),
|
||||
Some((_size, Some((_id, dev)), _time)) => Some(dev),
|
||||
_ => None,
|
||||
})
|
||||
.collect()
|
||||
@@ -62,6 +65,16 @@ pub fn is_filtered_out_due_to_regex(filter_regex: &[Regex], dir: &Path) -> bool
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_filtered_out_due_to_file_time(filter_time: &(Operater, i64), actual_time: i64) -> bool {
|
||||
match filter_time {
|
||||
(Operater::Equal, bound_time) => {
|
||||
!(actual_time >= *bound_time && actual_time < *bound_time + DAY_SECEONDS)
|
||||
}
|
||||
(Operater::GreaterThan, bound_time) => actual_time < *bound_time,
|
||||
(Operater::LessThan, bound_time) => actual_time > *bound_time,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_filtered_out_due_to_invert_regex(filter_regex: &[Regex], dir: &Path) -> bool {
|
||||
filter_regex
|
||||
.iter()
|
||||
|
||||
Reference in New Issue
Block a user