utils: add the source files

devs/bu5hm4n/fix-for-billiob
Boris Faure 2 years ago
parent 3cbcbcd717
commit dd7d88815c
Signed by: borisfaure
GPG Key ID: 35C0410516166BE8
  1. 23
      src/bin/utils.c
  2. 7
      src/bin/utils.h

@ -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…
Cancel
Save