## Miscellaneous Utilities Miscellaneous Utilities — miscellaneous file-related utility functions. |

## Functions

const gchar * | xfce_get_homedir ()
#define | xfce_get_homefile()
gchar * | xfce_get_homefile_r ()
const gchar * | xfce_get_userdir ()
#define | xfce_get_userfile()
gchar * | xfce_get_userfile_r ()
gchar * | xfce_gethostname ()
gchar * | xfce_expand_variables ()
void | xfce_append_quoted ()
gchar * | xfce_expand_desktop_entry_field_codes ()

## Includes

    #include <libxfce4util/libxfce4util.h>

## Description

Miscellaneous file-related utility functions.

## Functions

### xfce_get_homedir ()

    const gchar *
    xfce_get_homedir (void);

Similar to `g_get_homedir()` in functionality but will never return NULL. While `g_get_homedir()` may return NULL under certain circumstances, this function is garantied to never ever return NULL, but always return a valid character pointer with the absolute path to the user's home directory.

The returned string is owned by libxfce4util and must not be freed by the caller.

#### Returns

the path to the current user's home directory.

### xfce_get_homefile()

    #define             xfce_get_homefile(...)

### xfce_get_homefile_r ()

    gchar *
    xfce_get_homefile_r (gchar *buffer,
                         size_t length,
                         const gchar *format,
                         ...);

Similar in functionality to xfce_get_homefile, but uses a user defined `buffer` instead of allocating a new buffer.

xfce_get_homefile_r uses safe string operations, that says, it garanties that the resulting string is always zero terminated, as long as the `length` is greater than zero.

#### Parameters

buffer | pointer to a user provided destination buffer. |
length | size of `buffer` in bytes. |
format | printf style format string. |
... | the arguments to substitute in the output. |

#### Returns

pointer to `buffer` .

### xfce_get_userdir ()

    const gchar *
    xfce_get_userdir (void);

Safe way to retrieve the path to the user's ".xfce4" directory. The path to the current user's ".xfce4" directory is either taken from the environment variable XFCE4HOME if defined, or if unset, is gained by concatenating the path to the user's home directory and the ".xfce4". That says, it will, by default, return the path "$HOME/.xfce4", where $HOME is replaced with the absolute path to the user's home directory.

The returned string is managed by libxfce4util and must not be freed by the caller.

#### Returns

the path to the current user's ".xfce4" directory.

### xfce_get_userfile()

    #define             xfce_get_userfile(...)

### xfce_get_userfile_r ()

    gchar *
    xfce_get_userfile_r (gchar *buffer,
                         size_t length,
                         const gchar *format,
                         ...);

#### Parameters

buffer | user provided destination buffer. |
length | size of `buffer` in bytes. |
format | printf style format string. |
... | arguments to substitute in the output. |

#### Returns

pointer to `buffer` .

### xfce_gethostname ()

    gchar *
    xfce_gethostname (void);

Portable way to query the hostname of the node running the process. This function does not ever return `NULL`, but always returns a string containing the current node's hostname.

#### Returns

the current node's hostname. The string has to be freed by the caller using `g_free()`.

### xfce_expand_variables ()

    gchar *
    xfce_expand_variables (const gchar *command,
                           gchar **envp);

Expands shell like environment variables and tilde (~/ and ~user/ are both supported) in `command` .

#### Parameters

command | Input string or `NULL`. |
envp | Addition environment variables to take into account. These variables have higher priority than the ones in the process's environment. |

#### Returns

`NULL` on error, else the string, which should be freed using `g_free()` when no longer needed.

Since: 4.2

### xfce_append_quoted ()

    void
    xfce_append_quoted (GString *string,
                        const gchar *unquoted);

### xfce_expand_desktop_entry_field_codes ()

    gchar *
    xfce_expand_desktop_entry_field_codes (const gchar *command,
                                           GSList *uri_list,
                                           const gchar *icon,
                                           const gchar *name,
                                           const gchar *uri,
                                           gboolean requires_terminal);

Expands field codes in `command` according to Freedesktop.org Desktop Entry Specification.

#### Parameters

command | Input string (command to expand) or `NULL`. |
uri_list | Input string list (filename/URL field) or `NULL`. |
icon | Input string (icon field) or `NULL`. |
name | Input string (name field) or `NULL`. |
uri | Input string (URI field) or `NULL`. |
requires_terminal | Input boolean. |

#### Returns

`NULL` on error, else the string, which should be freed using `g_free()` when no longer needed.