Skip to main content

compare_dir/
lib.rs

1mod dir_comparer;
2mod file_comparer;
3mod file_hash_cache;
4mod file_hasher;
5mod file_iterator;
6mod progress_reporter;
7
8pub use dir_comparer::{DirectoryComparer, FileComparisonMethod};
9pub use file_comparer::{Classification, FileComparer, FileComparisonResult};
10pub(crate) use file_hash_cache::FileHashCache;
11pub use file_hasher::{DuplicatedFiles, FileHasher};
12pub(crate) use file_iterator::FileIterator;
13pub(crate) use progress_reporter::ProgressReporter;
14
15pub(crate) fn human_readable_size(size: u64) -> String {
16    const MB: u64 = 1024 * 1024;
17    const GB: u64 = 1024 * 1024 * 1024;
18    if size >= GB {
19        format!("{:.1}GB", size as f64 / GB as f64)
20    } else if size >= MB {
21        format!("{:.1}MB", size as f64 / MB as f64)
22    } else {
23        format!("{} bytes", size)
24    }
25}