utils: add the source files
This commit is contained in:
parent
3cbcbcd717
commit
dd7d88815c
|
@ -0,0 +1,23 @@
|
|||
#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;
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
#ifndef _UTILS_H__
|
||||
#define _UTILS_H__
|
||||
|
||||
#include <Eina.h>
|
||||
Eina_Bool homedir_get(char *buf, size_t size);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue