ID:144561
 
Code:
FileSize(FILE)
ASSERT(FILE)
var/leng=length(FILE)
if(leng < 1024) return "[leng] Bytes"
leng /= 1024
if(leng < 1024) return "[leng] Kilobytes"
leng /= 1024
if(leng < 1024) return "[leng] Megabytes"
leng /= 1024
return "[leng] Gigabytes"


Problem description:
I think my file size proc is wrong. it isnt giving me accurate readings. anyone know whats wrong?

Well, their are some alternative ways, but that seems about right. You could do this.

proc/FileSize(FILE)
ASSERT(FILE)
var/list/L=list("Bytes","Kilobytes","Megabytes","Gigabytes","Terabyte")
var/leng = length(FILE)
var/pos = 1
while(leng >= 1024)
leng /= 1024
pos++
return "[leng] [L[pos]]"


If this starts spitting out terabyte, or gigabyte even, you need to look into this procedure more. Post back, maybe it's a BYOND bug or something I am overlooking. I really don't see anything wrong with either procedure.
In response to CaptFalcon33035
ive been trying to make a sort of thing that rounds off the size of the file so i can determine ratio.

say i upload 1mb, meaning i can only download 1mb; having a 1:1 ratio.

i have no idea how to do this though b/c length determines kb and round goes to decimal so i cant make a solid number. ya know what i mean? caaapttain i neeeeed you!