Subversion Repositories pub

Compare Revisions

Ignore whitespace Rev 679 → Rev 680

/video-contact-sheet/trunk/dist/vcs
1447,13 → 1447,17
local size=
 
# Sizes are always rounded up (hence the addition 0.999999 to the fractionary part)
if [[ $bytes -gt $(( 1024**3 )) ]]; then
local gibs_int=$(( $bytes / 1024**3 ))
local gibs_frac=$(awkex "int($bytes%(1024**3)*100/1024**3 + 0.999999)" )
# gawk understands the ** operator, but mawk does not, using precomputed
# values for the sake of compatibility
declare -ri GBS=$(( 1024**3 ))
declare -ri MBS=$(( 1024**2 ))
if [[ $bytes -gt $GBS ]]; then
local gibs_int=$(( $bytes / $GBS ))
local gibs_frac=$(awkex "int($bytes%$GBS*100/$GBS + 0.999999)" )
size="$(printf '%d.%02d' $gibs_int $gibs_frac) GiB"
elif [[ $bytes -gt $(( 1024**2)) ]]; then
local mibs_int=$(( $bytes / 1024**2 ))
local mibs_frac=$(awkex "int($bytes%(1024**2)*100/1024**2 + 0.999999)")
elif [[ $bytes -gt $MBS ]]; then
local mibs_int=$(( $bytes / $MBS ))
local mibs_frac=$(awkex "int($bytes%$MBS*100/$MBS + 0.999999)")
size="$(printf '%d.%02d' $mibs_int $mibs_frac) MiB"
elif [[ $bytes -gt 1024 ]]; then
local kibs_int=$(( $bytes / 1024 ))