diff options
author | Daniel Friesel <derf@finalrewind.org> | 2011-01-09 11:28:40 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2011-01-09 11:28:40 +0100 |
commit | 4054e752d00721a9a0c5da43ebbf949544e33b59 (patch) | |
tree | 60a3dd5876677d08ddd3ba9c61a67492f656fcf4 /bin/hashl | |
parent | 7ae2890248388904feb29b6a726b24b5c798ea9f (diff) |
hashl list: Print filesize
Diffstat (limited to 'bin/hashl')
-rwxr-xr-x | bin/hashl | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -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 + ); } } |