Handle correctly g_get_home_dir() returning NULL, assume it's the current

directory then.


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2968 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2002-10-19 17:48:10 +00:00 committed by cras
commit fe4cdce6e6
2 changed files with 19 additions and 5 deletions

View file

@ -451,9 +451,17 @@ int mkpath(const char *path, int mode)
/* 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_strdup(path);
const char *home;
if (*path == '~' && (*(path+1) == '/' || *(path+1) == '\0')) {
home = g_get_home_dir();
if (home == NULL)
home = ".";
return g_strconcat(home, path+1, NULL);
} else {
return g_strdup(path);
}
}
int g_istr_equal(gconstpointer v, gconstpointer v2)