file-size ( entry -- string )


Vocabulary
gopher.server.private

Inputs
entryan object


Outputs
stringan object


Definition


: file-size ( entry -- string )
dup directory?
[ drop "- " ] [
size>> {
{ [ dup 40 2^ >= ] [ 40 2^ /f "TB" ] }
{ [ dup 30 2^ >= ] [ 30 2^ /f "GB" ] }
{ [ dup 20 2^ >= ] [ 20 2^ /f "MB" ] }
[ 10 2^ /f "KB" ]
} cond "%.1f %s" sprintf
] if ;