Added util.getFriendlySize() (#3381)
* Added util.getFriendlySize() * Allow for GB
This commit is contained in:
1 parent
87a86e0dc1
commit
c15915a4ee
4 files changed
+21
-25
No files matched your search
@@ -352,6 +352,23 @@ function util.getFileNameSuffix(file)
|
||||
return suffix
|
||||
end
|
||||
|
||||
--- Gets human friendly size as string
|
||||
---- @int size (bytes)
|
||||
---- @treturn string
|
||||
function util.getFriendlySize(size)
|
||||
local s
|
||||
if size > 1024*1024*1024 then
|
||||
s = string.format("%4.1f GB", size/1024/1024/1024)
|
||||
elseif size > 1024*1024 then
|
||||
s = string.format("%4.1f MB", size/1024/1024)
|
||||
elseif size > 1024 then
|
||||
s = string.format("%4.1f KB", size/1024)
|
||||
else
|
||||
s = string.format("%d B", size)
|
||||
end
|
||||
return s
|
||||
end
|
||||
|
||||
--- Adds > to touch menu items with a submenu
|
||||
function util.getMenuText(item)
|
||||
local text
|
||||
|
||||
Reference in new issue
Block a user