#ifdef HAVE_REGEX_H
# include <regex.h>
#endif
+#include <pwd.h>
typedef struct {
int condition;
return 0;
}
+/* Get home directory */
+const char *get_home_dir(void)
+{
+ struct passwd *pw = getpwuid(getuid());
+ if (!pw) {
+ if (g_getenv("HOME"))
+ return g_getenv("HOME");
+ else
+ return ".";
+ }
+ return pw->pw_dir;
+}
+
/* convert ~/ to $HOME */
char *convert_home(const char *path)
{
return *path == '~' && (*(path+1) == '/' || *(path+1) == '\0') ?
- g_strconcat(g_get_home_dir(), path+1, NULL) :
+ g_strconcat((char *)get_home_dir, path+1, NULL) :
g_strdup(path);
}