aboutsummaryrefslogtreecommitdiffhomepage
path: root/player
diff options
context:
space:
mode:
Diffstat (limited to 'player')
-rw-r--r--player/lua/defaults.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/player/lua/defaults.lua b/player/lua/defaults.lua
index 1320522b26..32dfed9948 100644
--- a/player/lua/defaults.lua
+++ b/player/lua/defaults.lua
@@ -589,4 +589,14 @@ function mp_utils.getcwd()
return mp.get_property("working-directory")
end
+function mp_utils.format_bytes_humanized(b)
+ local d = {"Bytes", "KiB", "MiB", "GiB", "TiB", "PiB"}
+ local i = 1
+ while b >= 1024 do
+ b = b / 1024
+ i = i + 1
+ end
+ return string.format("%0.2f %s", b, d[i] and d[i] or "*1024^" .. (i-1))
+end
+
return {}