Logo Search packages:      
Sourcecode: pulseaudio version File versions  Download package

char* pa_get_home_dir ( char *  s,
size_t  l 
)

Return the home directory of the current user

Definition at line 130 of file util.c.

                                         {
    char *e, *dir;

#ifdef HAVE_PWD_H
    struct passwd *r;
#endif

    pa_assert(s);
    pa_assert(l > 0);

    if ((e = getenv("HOME")))
        return pa_strlcpy(s, e, l);

    if ((e = getenv("USERPROFILE")))
        return pa_strlcpy(s, e, l);

#ifdef HAVE_PWD_H
    errno = 0;
    if ((r = pa_getpwuid_malloc(getuid())) == NULL) {
        if (!errno)
            errno = ENOENT;

        return NULL;
    }

    dir = pa_strlcpy(s, r->pw_dir, l);

    pa_getpwuid_free(r);

    return dir;
#else /* HAVE_PWD_H */

    errno = ENOENT;
    return NULL;
#endif
}


Generated by  Doxygen 1.6.0   Back to index