## Utility Functions Utility Functions — |

## Synopsis

    #include <thunar-vfs/thunar-vfs.h>

    gchar*              thunar_vfs_canonicalize_filename    (const gchar *filename);
    gchar*              thunar_vfs_expand_filename          (const gchar *filename,
                                                             GError **error);
    gchar*              thunar_vfs_humanize_size            (ThunarVfsFileSize size,
                                                             gchar *buffer,
                                                             gsize buflen);

## Description

## Details

### thunar_vfs_canonicalize_filename ()

    gchar*              thunar_vfs_canonicalize_filename    (const gchar *filename);

Canonicalizes `filename` and returns a new path. The new path differs from `filename` in:

Multiple `/'s are collapsed to a single `/'.
Leading `./'s and trailing `/.'s are removed.
Non-leading `../'s and trailing `..'s are handled by removing portions of the path.

The caller is responsible to free the returned string using `g_free()` when no longer needed.

`filename` : | a local filename.
Returns : | the canonicalized path for `filename`.

### thunar_vfs_expand_filename ()

    gchar*              thunar_vfs_expand_filename          (const gchar *filename,
                                                             GError **error);

Takes a user-typed `filename` and expands a tilde at the beginning of the `filename`.

The caller is responsible to free the returned string using `g_free()` when no longer needed.

`filename` : | a local filename.
`error` : | return location for errors or `NULL`.
Returns : | the expanded `filename` or `NULL` on error.

### thunar_vfs_humanize_size ()

    gchar*              thunar_vfs_humanize_size            (ThunarVfsFileSize size,
                                                             gchar *buffer,
                                                             gsize buflen);

The caller is responsible to free the returned string using `g_free()` if you pass `NULL` for `buffer`. Else the returned string will be a pointer to `buffer`.

`size` : | size in bytes.
`buffer` : | destination buffer or `NULL` to dynamically allocate a buffer.
`buflen` : | length of `buffer` in bytes.
Returns : | a string containing a human readable description of `size`.