Function

GLibformat_size

since: 2.30

Declaration

gchar*
g_format_size (
  guint64 size
)

Description

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 returned string is UTF-8, and may use a non-breaking space to separate the number and units, to ensure they aren’t separated when line wrapped.

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

This string should be freed with g_free() when not needed any longer.

See g_format_size_full() for more options about how the size might be formatted.

Available since: 2.30

Parameters

size

Type: guint64

A size in bytes.

Return value

Type: gchar*

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

The caller of the function takes ownership of the data, and is responsible for freeing it.
The value is a NUL terminated UTF-8 string.