Exemple #1
0
gchar *
find_xdg_file (XdgDir dir, const char* basename)
{
    gchar *dirs = get_xdg_var (TRUE, dir);
    gchar *path = g_strconcat (dirs, basename, NULL);
    g_free (dirs);

    if (file_exists (path)) {
        return path; /* We found the file. */
    }

    g_free (path);

    if (dir == XDG_CACHE) {
        return NULL; /* There's no system cache directory. */
    }

    /* The file doesn't exist in the expected directory, check if it exists in
     * one of the system-wide directories. */
    char *system_dirs = get_xdg_var (FALSE, dir);
    path = find_existing_file_options (system_dirs, basename);
    g_free (system_dirs);

    return path;
}
Exemple #2
0
/*@null@*/ gchar*
find_xdg_file (enum xdg_type type, const char* basename) {
    gchar *dirs = get_xdg_var(type);
    gchar *path = g_strconcat (dirs, basename, NULL);
    g_free (dirs);

    if (file_exists(path))
        return path; /* we found the file */

    if (type == XDG_CACHE)
        return NULL; /* there's no system cache directory */

    /* the file doesn't exist in the expected directory.
     * check if it exists in one of the system-wide directories. */
    char *system_dirs = get_xdg_var(3 + type);
    path = find_existing_file2(system_dirs, basename);
    g_free(system_dirs);

    return path;
}
Exemple #3
0
void
ensure_xdg_vars (void) {
    int i;

    for (i = 0; i <= 2; ++i) {
        gchar* xdg = get_xdg_var(i);

        if (!xdg)
            continue;

        setenv(XDG[i].environmental, xdg, 0);

        g_free(xdg);
    }
}
Exemple #4
0
void
ensure_xdg_vars ()
{
    XdgDir i;

    for (i = XDG_DATA; i < XDG_END; ++i) {
        gchar *xdg = get_xdg_var (TRUE, i);

        if (!xdg) {
            continue;
        }

        g_setenv (xdg_user[i].environment, xdg, FALSE);

        g_free (xdg);
    }
}