GLib.format_size

function format_size(size: Number(guint64)): String {
    // Gjs wrapper for g_format_size()
}
  

Formats a size (for example the size of a file) into a human readable string. Sizes are rounded to the nearest size prefix (kB, MB, GB) and are displayed rounded to the nearest tenth. E.g. the file size 3292528 bytes will be converted into the string "3.2 MB".

The prefix units base is 1000 (i.e. 1 kB is 1000 bytes).

This string should be freed with GLib.free when not needed any longer.

See GLib.format_size_full for more options about how the size might be formatted.

Since 2.30

size

a size in bytes

Returns

a newly-allocated formatted string containing a human readable file size