2011-06-22 23:36:30 +00:00
|
|
|
|
2012-01-13 21:23:03 +00:00
|
|
|
if {![exists -proc pretty_size]} {
|
2011-06-22 23:36:30 +00:00
|
|
|
proc pretty_size {size} {
|
|
|
|
set units {bytes KiB MiB GiB TiB}
|
|
|
|
|
|
|
|
for {set i 0} {$size > 1023} {incr i} {
|
|
|
|
set size $($size / 1024.0)
|
|
|
|
}
|
|
|
|
|
2014-03-03 17:30:17 +00:00
|
|
|
set size [string trimright \
|
|
|
|
[string trimright [format "%.2f" $size] "0"] "."]
|
2011-06-22 23:36:30 +00:00
|
|
|
|
|
|
|
return "$size [lindex $units $i]"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|