summaryrefslogtreecommitdiffstats
path: root/src/file_sum
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2020-07-04 07:08:10 +0200
committerCanop <cano.petrole@gmail.com>2020-07-04 07:08:10 +0200
commit607cf10e37138bd1144ad2953d03f0724a8bffe2 (patch)
tree3024498b0580ba6c61d6ba2f726f1de4283461d8 /src/file_sum
parent1361f19fdd5a5d9dfda2d2b49b9268da51ee48b5 (diff)
improve rendering file size as string with ISO units
Sizes now always fit 4 chars and are correctly rounded. When we had "2389M" we now have "2.4G".
Diffstat (limited to 'src/file_sum')
-rw-r--r--src/file_sum/mod.rs12
1 files changed, 0 insertions, 12 deletions
diff --git a/src/file_sum/mod.rs b/src/file_sum/mod.rs
index 894f457..a6fec11 100644
--- a/src/file_sum/mod.rs
+++ b/src/file_sum/mod.rs
@@ -17,8 +17,6 @@ use {
},
};
-const SIZE_NAMES: &[&str] = &["", "K", "M", "G", "T", "P", "E", "Z", "Y"];
-
lazy_static! {
static ref SUM_CACHE_MUTEX: Mutex<HashMap<PathBuf, FileSum>> = Mutex::new(HashMap::new());
}
@@ -90,16 +88,6 @@ impl FileSum {
self.real_size as f32 / total.real_size as f32
}
}
- /// format a number of bytes as a string, for example 247K
- pub fn to_size_string(self) -> String {
- let mut v = self.real_size;
- let mut i = 0;
- while v >= 5000 && i < SIZE_NAMES.len() - 1 {
- v /= 1000;
- i += 1;
- }
- format!("{}{}", v, &SIZE_NAMES[i])
- }
/// return the number of files (normally at least 1)
pub fn to_count(self) -> usize {
self.count