mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
feat: shorten unit names and add more units to ya.readable_size
This commit is contained in:
parent
a9ce714571
commit
c02d69590b
1 changed files with 2 additions and 2 deletions
|
|
@ -45,13 +45,13 @@ end
|
||||||
function ya.basename(str) return string.gsub(str, "(.*[/\\])(.*)", "%2") end
|
function ya.basename(str) return string.gsub(str, "(.*[/\\])(.*)", "%2") end
|
||||||
|
|
||||||
function ya.readable_size(size)
|
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
|
local i = 1
|
||||||
while size > 1024.0 and i < #units do
|
while size > 1024.0 and i < #units do
|
||||||
size = size / 1024.0
|
size = size / 1024.0
|
||||||
i = i + 1
|
i = i + 1
|
||||||
end
|
end
|
||||||
return string.format("%.1f %s", size, units[i])
|
return string.format("%.1f%s", size, units[i])
|
||||||
end
|
end
|
||||||
|
|
||||||
function ya.readable_path(path)
|
function ya.readable_path(path)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue