forked from enlightenment/terminology
24 lines
442 B
C
24 lines
442 B
C
#include "private.h"
|
|
#include "utils.h"
|
|
#include <unistd.h>
|
|
#include <pwd.h>
|
|
|
|
Eina_Bool
|
|
homedir_get(char *buf, size_t size)
|
|
{
|
|
const char *home = getenv("HOME");
|
|
if (!home)
|
|
{
|
|
uid_t uid = getuid();
|
|
struct passwd *pw = getpwuid(uid);
|
|
if (pw) home = pw->pw_dir;
|
|
}
|
|
if (!home)
|
|
{
|
|
ERR("Could not get $HOME");
|
|
return EINA_FALSE;
|
|
}
|
|
return eina_strlcpy(buf, home, size) < size;
|
|
}
|
|
|