feat: shorten unit names and add more units to ya.readable_size

This commit is contained in:
sxyazi 2024-01-26 16:35:36 +08:00
parent a9ce714571
commit c02d69590b
No known key found for this signature in database

View file

@ -45,13 +45,13 @@ end
function ya.basename(str) return string.gsub(str, "(.*[/\\])(.*)", "%2") end
function ya.readable_size(size)
local units = { "B", "KB", "MB", "GB", "TB", "PB", "EB" }
local units = { "B", "K", "M", "G", "T", "P", "E", "Z", "Y", "R", "Q" }
local i = 1
while size > 1024.0 and i < #units do
size = size / 1024.0
i = i + 1
end
return string.format("%.1f %s", size, units[i])
return string.format("%.1f%s", size, units[i])
end
function ya.readable_path(path)