summaryrefslogtreecommitdiff
path: root/bin/hashl
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-01-09 11:28:40 +0100
committerDaniel Friesel <derf@finalrewind.org>2011-01-09 11:28:40 +0100
commit4054e752d00721a9a0c5da43ebbf949544e33b59 (patch)
tree60a3dd5876677d08ddd3ba9c61a67492f656fcf4 /bin/hashl
parent7ae2890248388904feb29b6a726b24b5c798ea9f (diff)
hashl list: Print filesize
Diffstat (limited to 'bin/hashl')
-rwxr-xr-xbin/hashl17
1 files changed, 16 insertions, 1 deletions
diff --git a/bin/hashl b/bin/hashl
index 084b4d2..8ee20d5 100755
--- a/bin/hashl
+++ b/bin/hashl
@@ -74,6 +74,16 @@ sub get_total {
}
}
+sub si_size {
+ my @post = ('', 'ki', 'Mi', 'Gi', 'Ti');
+ my $bytes = shift;
+ while ($bytes > 1024) {
+ $bytes /= 1024;
+ shift @post;
+ }
+ return sprintf("%5.1f%sB", $bytes, $post[0]);
+}
+
sub drop_deleted {
for my $file (keys %{$db->{'files'}}) {
if (! -e $file) {
@@ -352,7 +362,12 @@ sub cmd_list {
);
for my $name (sort keys %{$db->{'files'}}) {
my $file = $db->{'files'}->{$name};
- printf("%s %s\n", $file->{'hash'}, $name);
+ printf(
+ "%s %-8s %s\n",
+ $file->{'hash'},
+ si_size($file->{'size'}),
+ $name
+ );
}
}