Added util.getFormattedSize() (#3383)

This commit is contained in:
poire-z
2017-10-20 19:29:52 +02:00
committed by Frans de Jonge
parent ba6cc87424
commit ecaeb4b6d7
2 changed files with 13 additions and 1 deletions

View File

@@ -369,6 +369,16 @@ function util.getFriendlySize(size)
return s
end
--- Gets formatted size as string (1273334 => "1,273,334")
---- @int size (bytes)
---- @treturn string
function util.getFormattedSize(size)
local s = tostring(size)
s = s:reverse():gsub("(%d%d%d)", "%1,")
s = s:reverse():gsub("^,", "")
return s
end
--- Adds > to touch menu items with a submenu
function util.getMenuText(item)
local text